user377628
user377628

Reputation:

How can the range be adjusted on a JavaFX stacked area chart?

I have a JavaFX stacked area chart, and I'd like to fix the range that it automatically adjusts when data is added. Currently, the Y axis (which is just a NumberAxis) goes up to a number that is way too high:

stacked area chart

I tried lowering the upper limit of the Y axis by doing:

((NumberAxis)chart.getYAxis()).setUpperBound(2000);

where chart is a StackedAreaChart. This doesn't seem to have any effect, unfortunately. How can I set the upper limit of the Y axis in a JavaFX chart?

Upvotes: 3

Views: 3165

Answers (1)

sarcan
sarcan

Reputation: 3165

Chart axes in JavaFX will require you to set the 'autoRanging' property to false before applying a custom range.

Arguably, it would be nice if the chart node raised an error when you attempt to set the value for an axis with autoranging == true, but at least for JavaFX 2.2 that is not the case.

Upvotes: 6

Related Questions