Setting LineChart plot-area width

懵懂的女人 提交于 2019-12-11 11:28:17

问题


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 LineCharts 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:

My attempt is to use 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!