[Solved] chart.diagram updating

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Philippe.s.Lévi
Posts: 2
Joined: Fri Aug 27, 2021 3:56 am

[Solved] chart.diagram updating

Post by Philippe.s.Lévi »

may be a basic question ... did not find answer ! :(
this code run ... but the axis position does not change
worst : checking with XRay, the Position.Y is not change

Code: Select all

sub x
dim Chart, Feuille, Position, p, sxa
feuille = thisComponent.currentController.activeSheet
Chart = Feuille.Charts(1)
sxa = Chart.EmbeddedObject.Diagram.SecondaryXAxis
p = sxa.getPosition
p.Y = 3000
sxa.setPosition(p)
end sub
using next code, checking by XRay, the value changed, but nothing changed in the diagram and if running the sub again the previous value is back !

Code: Select all

sxa.position.Y = 3000
I'll apreciate any tip ! :)
thanks
Last edited by Hagar Delest on Wed Sep 01, 2021 10:53 am, edited 1 time in total.
Reason: tagged solved.
LibreOffice 7.1.4.2.
windows 7
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: chart.diagram updating

Post by FJCC »

I also cannot change sxa.Position with code. I can change where the secondary x axis crosses the y axis with code like the following.

Code: Select all

sub x
dim Chart, Feuille, Position, sxa
feuille = thisComponent.currentController.activeSheet
Chart = Feuille.Charts(1)
sxa = Chart.EmbeddedObject.Diagram.SecondaryXAxis
sxa.CrossoverPosition = com.sun.star.chart.ChartAxisPosition.VALUE
sxa.CrossoverValue = 5
end sub
In my chart, the y axis runs from 0 to 7, so a value of 5 makes sense. You will have to adjust that for your chart. Does that help you with your problem?
I guess that CrossoverPosition and CrossoverValue take precedence over sxa.Position. See CrossoverPosition
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Philippe.s.Lévi
Posts: 2
Joined: Fri Aug 27, 2021 3:56 am

Re: chart.diagram updating

Post by Philippe.s.Lévi »

Working fine ! Thanks !

but I was more interrested to understand why the ways I tried did not work than in the (fine) solution you gave me !

your solution use a value of the Y scale, which is nicer than trying to use position which looks to be pixel !

thanks again
LibreOffice 7.1.4.2.
windows 7
Post Reply