Charts > Using the Charts Library > Scales Display > Advanced Features for Customizing Scales > Applying a Transformation to the Data Values Represented by a Scale
 
Applying a Transformation to the Data Values Represented by a Scale
Different types of transformations can be applied to the data values that are represented by a given scale. These transformations are defined by means of transformer objects that are all instances of subclasses of the IlvChartCoordinateTransformer class. Several subclasses are provided in the Charts Library:
*IlvChartCoordinateTransformer
This class is the base class permitting you to define transformations that consist of an elementary transformation, possibly followed by a logarithmic transformation.
The following subclasses are defined:
*IlvSimpleChartTransformer has an identity transformation as the elementary transformation. This means that no transformation will be applied before the logarithmic transformation (if a logarithmic transformation is defined).
*IlvAffineChartTransformer has an affine transformation as the elementary transformation. This means that an affine transformation will be applied before the logarithmic transformation (if a logarithmic transformation is defined).
The logarithmic transformation that is applied to the data values depends on the defined logarithmic base. If the logarithmic base is equal to 0 or 1, no logarithmic transformation is applied. Otherwise, the following transformation is applied:
c_transformed = log(c) / log(base)
where c is the initial coordinate, base is the logarithmic base, log is the natural logarithm, and c_transformed is the coordinate transformed using the logarithmic transformation.
The transformer object defining the transformation to be applied to a given coordinate is stored in the coordinate information object associated with the coordinate.
The following code lines show how to apply a logarithmic transformation to the data values represented along the abscissa of a chart.
IlvSingleScaleDisplayer* abscissaScale = chart->getAbscissaScale();
IlvChartCoordinateInfo* abscissaInfo = abscissaScale->getCoordinateInfo();
abscissaInfo->setTransformer(new IlvSimpleChartTransformer(10));
The base of the logarithmic transformation that will be applied is set to 10.
Warning: If you want the abscissa scale to be graduated with logarithmic graduations, you must also set a logarithmic scale steps updater on the scale.
To set a logarithmic scale steps updater on the abscissa scale use the following code:
IlvLogScaleStepsUpdater* logUpdater =
new IlvLogScaleStepsUpdater(abscissaScale);
delete IlvScaleStepsUpdater::Set(abscissaScale, logUpdater);
*IlvZoomCoordinateTransformer
This class allows you to define a transformation that is applied locally on a part of the data to display that data as zoomed.
Warning: If such a transformer is set on a given coordinate a zoom scale steps updater must also be set on the scale representing this coordinate in order to compute the corresponding graduations for 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 the IlvZoomCoordinateTransformer and IlvZoomScaleStepsUpdater classes.

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.