Page 1 of 1
[Solved] Use cell reference for chart's scale maximum
Posted: Sat Mar 23, 2024 12:21 pm
by giavvns
Can I replace the max values of the scales for x or y axes to a reference to a cell, something like INDIRECT("N3") or anything similar to that? Thanks! png file.
Re: Doing graphs: x and y axes question
Posted: Sat Mar 23, 2024 12:39 pm
by robleyd
Not an answer to your question, but your signature shows
OpenOffice 3.2 on SuSE 10.0 If you have upgraded from those elderly packages, perhaps you might
update your signature to reflect the software and operating system you currently use.
From a quick test, it seems the answer to your question may be No.
Re: Doing graphs: x and y axes questionT
Posted: Sat Mar 23, 2024 2:36 pm
by giavvns
Thanks! I updated my signature.
Re: Use cell reference for chart's scale maximum
Posted: Sat Mar 23, 2024 6:54 pm
by Hagar Delest
I don't think you can directly with a link to a cell.
But maybe a macro could do that.
You can ask for it, I think it would be a nice feature:
[Tutorial] Reporting bugs or suggestions.
Re: Use cell reference for chart's scale maximum
Posted: Sat Mar 23, 2024 8:26 pm
by Lupp
A macro can do it, but it must be written and called.
Charts have complicated models, and I'm not sure for which types the proposed (roughly sketched) solution will work.
(Tested with AOO V 4.1.7.)
Re: Use cell reference for chart's scale maximum
Posted: Sun Mar 24, 2024 8:14 am
by Zizi64
Here is a "solution" with macro cell function. It for the Ymin value only, but you can modify the macro code. It will refresh automatically, when the passed parameters are changed.(Tested in the LibreOffice 7.5.8):
The macro code:
Code: Select all
REM ***** BASIC *****
Option explicit
function RescaleYmin(ShNr as integer, ChartName as string, Ymin as double) as string
dim oDoc as object
dim oSheets, oSheet as object
dim oGrObjects, oGrObject as object
dim oCharts, oChart as object
dim oChartModel as object
dim oYAxisProp as object
dim iNumOfGrObjects, iNumOfCharts, i as integer
dim sResult as string
sResult = "Error"
oDoc = Thiscomponent
oSheets = oDoc.Sheets
oSheet = oSheets.getByIndex(ShNr-1)
oGrObjects = oSheet.DrawPage
iNumOfGrObjects = oGrObjects.Count
For i = 0 to iNumOfGrObjects-1
oGrObject = oGrObjects.getByIndex(i)
If oGrObject.Name = ChartName then
oYAxisProp = oGrObject.Model.Diagram.YAxis
oYAxisProp.AutoMin = false
oYAxisProp.Min = Ymin
sResult = "Done"
end if
next i
RescaleYmin = sResult
End function
Re: Use cell reference for chart's scale maximum
Posted: Tue Mar 26, 2024 9:48 pm
by giavvns
Thank you all for your replies! They were helpfull and answerd my question!