Class AxisScaleMath
- Namespace
- DocWright.Core.Primitives
- Assembly
- DocWright.Core.dll
The arithmetic every value axis shares: the 1/2/5 ladder, the axis top a step implies, and the projection of a value onto the axis.
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 (Phase 54e,
facts 61–62). 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 NiceStep(max / 6) and does not consider the plot's size at all. Over
twenty data maxima the two agree on every answer by different routes, and a tall chart is
where they part. 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.
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
unitthat is strictly greater than the data.
- Fraction(double, double, double)
Where a value sits on the axis, as a fraction from
minimum(0) tomaximum(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.