[Solved] Use cell reference for chart's scale maximum

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
giavvns
Posts: 19
Joined: Thu Feb 25, 2010 8:38 pm

[Solved] Use cell reference for chart's scale maximum

Post 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.

 Edit: Changed subject, was Doing graphs: x and y axes question 
Make your post understandable by others 
-- MrProgrammer, forum moderator 
Attachments
snap1.png
snap1.png (23.91 KiB) Viewed 1034 times
Last edited by MrProgrammer on Wed Mar 27, 2024 12:30 am, edited 2 times in total.
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
OpenOffice 4 on SuSE opensuse-lean 15.0
User avatar
robleyd
Moderator
Posts: 5087
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Doing graphs: x and y axes question

Post 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.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
giavvns
Posts: 19
Joined: Thu Feb 25, 2010 8:38 pm

Re: Doing graphs: x and y axes questionT

Post by giavvns »

Thanks! I updated my signature.
OpenOffice 4 on SuSE opensuse-lean 15.0
User avatar
Hagar Delest
Moderator
Posts: 32670
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Use cell reference for chart's scale maximum

Post 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.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
User avatar
Lupp
Volunteer
Posts: 3553
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Use cell reference for chart's scale maximum

Post 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.
aoo111382chartAxesRangesFromCellRange.ods
(18.07 KiB) Downloaded 95 times
(Tested with AOO V 4.1.7.)
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
Zizi64
Volunteer
Posts: 11364
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Use cell reference for chart's scale maximum

Post 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
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
giavvns
Posts: 19
Joined: Thu Feb 25, 2010 8:38 pm

Re: Use cell reference for chart's scale maximum

Post by giavvns »

Thank you all for your replies! They were helpfull and answerd my question!
OpenOffice 4 on SuSE opensuse-lean 15.0
Post Reply