Table of Contents

Class AxisScaleMath

Namespace
DocWright.Core.Primitives
Assembly
DocWright.Core.dll

The arithmetic of a value axis that does not belong to one chart engine: the axis top a step implies, the projection of a value onto the axis, and the 1/2/5 ladder.

public static class AxisScaleMath
Inheritance
AxisScaleMath
Inherited Members

Remarks

Why this is in Core. Two chart engines drive it — DocWright.Layout draws DrawingML charts out of a Word document, and DocWright.Reporting draws RDL charts out of a report — and they share no other code and reference each other not at all. The precedent is FixedPointMath: pure arithmetic that several layers need lives here rather than being copied into each, because a copy is a thing that drifts.

What is deliberately not here: choosing the step. The two engines pick a different unit for the same data, and that was measured rather than assumed (oracle facts 61, 62 and 79). Word's DrawingML ladder divides the plot's height by a label's height and coarsens the step until the labels fit, so a taller chart can carry a finer axis; Reporting Services takes the range over five, rounds its mantissa on a ladder of its own (to 2 below 3, to 5 below 7, to 10 otherwise) and does not consider the plot's size at all. A shared "compute the axis" function would therefore have to carry both policies behind a flag, which is two algorithms wearing one name; the policies stay with their engines and only the arithmetic below is common.

Who calls what. Both engines call AxisMaximum(double, double, double) and the report engine calls Fraction(double, double, double). NiceStep(double) is called by the DrawingML engine alone: the report engine used it while its interval was read as NiceStep(max / 6), a reading that fitted the twenty data maxima it was taken from and that thirty-two later replaced with the rule above.

This is a sanctioned floating-point island for the same reason chart geometry is: a scale is a ratio of data values, which are double by the time they reach an axis. The result is rounded to integer twips once, by the caller, at the point it becomes geometry.

Methods

AxisMaximum(double, double, double)

The axis top for a step: the smallest multiple of unit that is strictly greater than the data.

Fraction(double, double, double)

Where a value sits on the axis, as a fraction from minimum (0) to maximum (1).

NiceStep(double)

Rounds a raw interval up to the 1/2/5 ladder: the smallest of 1, 2, 5 or 10 times a power of ten that is not smaller than it.