Setting LineChart Chart Width

I am trying to code a class called MultipleAxisLineChart . As its name says, it will be a LineChart that will have several axes (I assume that all additional axes will be placed either on Side.LEFT or Side.RIGHT ).

All axes on the given side will be located on tickLabelGapProperty . The right axes must be additionally x-translated by the sum of the axes of the left side.

The problem arose when I came to the point of calculating the preferred width of the chart (given my previous assumptions, the areas of the graphs will be the same size, so they can be placed on top of each other). The LineChart#widthProperty property LineChart#widthProperty returns the width of the whole LineChart object (including the y-axis property and the space property) - therefore, this certainly will not be the best candidate for setting the same width for all areas of the LineChart chart (as I would for calculating a different width for each chart - remember that tickLabelGap is different for everyone).

I can get (and even set) the width of the axis (only Axis#widthProperty ), but not the LineChart section width. So my question is: is there a way to arbitrarily set the width of the LineChart chart so that all areas in different charts have the same width?

Update

I am trying to achieve an effect similar to HighCharts several axes: (C) Screen from HighCharts Demo website My attempt is to use StackPane and add all the charts as children. I could control the size of the chart by setting the width of the StackPane.

+1
source share
1 answer

The problem is resolved. There was no need to use tickLabelGapProperty to host LineChart . This can ruin the whole idea, because the transition is considered the width of the component.

Axis movement can simply be done using Axis#setTranslateX(double) .

Returning to MultipleAxisLineChart - I created something similar to what I presented. You can find out more here.

+1
source

Source: https://habr.com/ru/post/910499/


All Articles