Understanding Numerical Axes and Automatic Axis Scaling
When you populate a chart, Chart FX for Java will automatically calculate the scale values for all numerical axes in the chart. Scale values include: Minimum (or where the axis starts), Maximum (or where the axis ends) and Step (or major unit).

These values are chosen according to the data and the chart's size (in the form) and then adjusted so the axis shows "nice" values in the chart. For example, if you pass the following data array to a chart:
[17.3, 78, 34.5, 58.9, 90.5, 35.3]
|
Chart FX will automatically select "nice" scale values to show in the Y-axis as depicted in the figure shown. Then the markers will be plotted in the chart area according to their value and the position in the chosen scale.
The Step property controls where labels and tick marks are shown in a numerical axis. This fraction is usually called the major unit. A numerical axis also supports a MinorStep property that allows you to set a minor unit on which you can only show and configure tick marks and gridlines.
For more information on tick marks please refer to Gridlines and Tick Marks later in this section.
If new data is set for a chart, Chart FX will then recalculate the scale values according to the new data set. This behavior is controlled by the AutoScale property of the axis, which is enabled by default. If you don't want to recalculate scale values every time data is sent to the chart you can simply disable this behavior as follows:
chart1.getAxisY().setAutoScale(false);
|
Note: you must set Min and Max if you set AutoScale = False.
Also, you can use the Min, Max, and Step properties of the AxisY object to force specific scale values, for example:
Axis axis = chart1.getAxisY(); axis.setMin(10); axis.setMax(200); axis.setStep(5);
|
However, if you force scale values, Chart FX will not recalculate them when new data is set to the chart. This behavior can be altered by invoking the chart's recalcScale method. This method recalculates scale values associated to ALL numerical axes, and can be invoked as follows:
Important Note: Please keep in mind that recalcScale method applies to ALL numerical axes and reads the entire data array. In other words, you should avoid calling this method repeatedly as it will adversely affect the performance of your application.
|