Options > Charts > Using the Charts Library > Scales Display > Using Scale Steps Updaters to Compute Scales Graduations
Using Scale Steps Updaters to Compute Scales Graduations
The computation of the steps and substeps is performed by a dedicated object called scale steps updater that is set on the scale.
The base class used to represent a scale steps updater is the IlvScaleStepsUpdater class. Several subclasses are provided in the Charts Library:
*IlvConstantScaleStepsUpdater
This class allows you to define graduations with constant spacing.
The steps and the substeps can be defined by:
*Fixing the number of steps and substeps. This can be done by means of the IlvConstantScaleStepsUpdater::fixStepsCount method.
*Fixing the step and substep units. This can be done by means of the IlvConstantScaleStepsUpdater::fixStepsCount method.
In the case of a fixed number of steps and substeps, the first major tick of the scale is drawn for the minimum value of the data interval represented by the scale and the last major tick is drawn for the maximum value of the dat interval represented by the scale. However, the data values associated with the first and the last steps can also be set by hand by means of the IlvConstantScaleStepsUpdater::setFirstStepData and the IlvConstantScaleStepsUpdater::setLastStepData methods respectively.
*IlvAutoScaleStepsUpdater
This class is a subclass of IlvConstantScaleStepsUpdater which enables automatic computation of the step and substeps.
This automatic computation can be customized in several ways:
*The precision can be automatic or it can be set by hand by means of the setPrecision method.
*The precision base is set to 10 by default. It can be modified by means of the setPrecision method.
*The step label format can be automatic or not.
*The substeps computing can be automatic or the number of substeps between two steps can be set by hand by means of the setAutoSubSteps method.
*The steps spacing is set to 10 by default. It can be modified by means of the setStepsSpacing method.
*IlvLogScaleStepsUpdater
This class allows you to compute logarithmic graduations.
Warning: This class can be used to compute the steps for a given scale only when a logarithmic transformation is set on the coordinate represented by the scale.
*IlvZoomScaleStepsUpdater
This class allows you to display graduations that are zoomed locally on part of the scale, while the steps and substeps are displayed normally on the rest of the scale.
Warning: This class can be used to compute the steps for a given scale only if a transformer of the IlvZoomCoordinateTransformer type is also set on the coordinate represented by the scale.
You can look at the lens.cpp file located in the $ILVHOME/samples/charts/lens/src directory for an example of how to use both the IlvZoomScaleStepsUpdater and IlvZoomCoordinateTransformer classes.
*IlvTimeScaleStepsUpdater
This class allows you to compute graduations based on time units (seconds, minutes, hour, calendar dates, and so on).
You can either manually set which time unit to use (with setTimeUnit(), passing one of the predefined units in charts/date.h), or, like with IlvAutoScaleStepsUpdater, you can let it choose the "best" unit automatically, which is the default behavior. You can change this behavior with IlvTimeScaleStepsUpdater::setAutoUnit().
Look at the stock.cpp file located in $ILVHOME/samples/chart/interactors/src directory for an example of how to use the IlvTimeScaleStepsUpdater.
Published date: 05/24/2022
Last modified date: 02/24/2022