Page 1 of 1

[Solved] chart.diagram updating

Posted: Fri Aug 27, 2021 4:12 am
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

Re: chart.diagram updating

Posted: Fri Aug 27, 2021 5:22 am
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

Re: chart.diagram updating

Posted: Fri Aug 27, 2021 3:03 pm
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