问题
I am trying to code a class named MultipleAxisLineChart
. As its name says - it will be a LineChart
which will have multiple axis (I assume that all additional axes will be placed either on Side.LEFT
or Side.RIGHT
).
All axes on given side will be positioned by tickLabelGapProperty
.
Right axes should be additionaly x-translated by the sum of left side axes' width.
The problem arised when I came to the moment of computing the preferred chart width (given my previous assumptions the charts plot areas would be of the same size, so they could be placed on the top of each other). Property LineChart#widthProperty
returns the width of whole LineChart
object (including y-axis and gap property) - so this one will certainly not be the best candidate for setting the same width for all LineChart
s plot areas (as I would have to compute different width for each chart - remember that tickLabelGap is different for each one).
I am able to get (and even set) axis width (just Axis#widthProperty
), but not LineChart
plot area width. So, my question is - is there a way to arbitrary set the width of LineChart
plot area so that all areas in different charts would have the same width?
update
I am trying to achieve effect similar to HighCharts
multiple axes:
StackPane
and add all charts as children. I would be able to control the size of Chart by setting StackPane width.
回答1:
The problem has been solved. There was no need to use tickLabelGapProperty
to position LineChart
. It can only spoil all idea, because it's transition is counted to component width.
Moving axis can be simply done by Axis#setTranslateX(double)
.
Coming back to MultipleAxisLineChart - I have created something similar to the one I have presented. Here you can find out more.
来源:https://stackoverflow.com/questions/26538542/setting-linechart-plot-area-width