Sangram Mohite
Sangram Mohite

Reputation: 754

JavaFX Charts: Change the ChartType of the XYChart at runtime?

I want to change the type of chart that is being displayed for e.g. LineChart extends XYChart and AreaChart also extends XYChart. Can I switch the LineChart drawn to AreaChart at runtime?

For XYChart,

Direct Known Subclasses:
AreaChart, BarChart, BubbleChart, LineChart, ScatterChart, StackedAreaChart, StackedBarChart

Any help would be great! Thanks.

Upvotes: 1

Views: 339

Answers (1)

Alexander Kirov
Alexander Kirov

Reputation: 3654

Charts show information according to the list of data, and according to the settings of chart and of 2 axes. Charts don't modify list of data.

So, you have to put list of data into 2 charts, make 2 pairs (or 1 pair, if applicable) of axes, and phisically exchange chart at specific location in scenegraph.

It theory, it should work. If it doesn't work in practise - it should be investigated (possibly, it is a bug). But there is no trouble to show info in several charts and replace charts.

Upvotes: 1

Related Questions