AutomaticNumericScaleOptions.AutomaticMeasureUnitsCalculator Property
Gets or sets the automatic numeric measure unit calculator.
Namespace: DevExpress.Xpf.Charts
Assembly: DevExpress.Xpf.Charts.v19.1.dll
Declaration
[Browsable(false)]
public INumericMeasureUnitsCalculator AutomaticMeasureUnitsCalculator { get; set; }
Property Value
Type | Description |
---|---|
INumericMeasureUnitsCalculator | An object of the class implementing the INumericMeasureUnitsCalculator interface. |
Example
The automatic numeric scale options provide the capability to use a custom measurement unit calculator to determine the current measurement unit if the predefined one does not fit your requirements. Design a class that implements the INumericMeasureUnitsCalculator interface and assign it to the AutomaticNumericScaleOptions.AutomaticMeasureUnitsCalculator
property to use a custom measurement units calculation algorithm:
public class CustomAutomaticNumericMeasureUnitsCalculator : INumericMeasureUnitsCalculator {
public double CalculateMeasureUnit(
IEnumerable<Series> series,
double axisLength, int pixelsPerUnit,
double visualMin, double visualMax,
double wholeMin, double wholeMax
) {
double rawMeasureUnit = (visualMax - visualMin) * pixelsPerUnit / axisLength;
return Math.Pow(10, GetDigitCount((int)Math.Abs(rawMeasureUnit)));
}
private static readonly int[] valueStops = {
9, 99, 999, 9999, 99999, 999999, 9999999,
99999999, 999999999, Int32.MaxValue
};
private static int GetDigitCount(int value) {
for (int i = 0; ; i++)
if (value <= valueStops[i])
return i + 1;
}
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AutomaticMeasureUnitsCalculator property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.