TickLayout

References
public sealed class TickLayout
A numberline layout for a specific portion of the number line.

Constructors

TickLayout

#
Create a new numberline layout. Note you would almost never do this yourself, as the Create(LineF, decimal, decimal, Properties) and Create(RectangleF, decimal, decimal, Properties) methods do all the heavy lifting. You only need to populate your own numberline layout if you want non-standard things such as custom formatting or non-linear mapping.
public TickLayout(
Tick[]
ticks,
axis,
t0,
t1
)

Properties

Axis

#
Gets the visible portion of the numberline.
public LineF Axis { get; }

Bounds

#
Gets the bounds of all layout elements.
public RectangleF Bounds { get; }

T0

#
Gets the numeric value at the left end of the axis.
public decimal T0 { get; }

T1

#
Gets the numeric value at the right end of the axis.
public decimal T1 { get; }

TickCount

#
Gets the number of ticks in this layout.
public int TickCount { get; }

Indexers

this[]

#
Gets the tick at the given index.
public Tick this[
index
] { get; }

Methods

Clip

#
Create a new layout with all ticks outside of the given range removed.
public TickLayout Clip(
lower,
upper
)

Create

#
Create a number line layout with an explicit finest tick class. Unlike Create(LineF, decimal, decimal, Properties) the visibility of ticks is not derived from their spacing. Every power-of-ten class is either drawn or not, and its tick length is supplied by the caller, which allows the caller to animate classes in and out over time. Labels are organised in rungs, from coarse to fine: all labels of a class, then the halfway labels between them, then all labels of the class below, and so on. A rung fits when its label pitch exceeds the widest label visible at that rung.
public static TickLayout Create(
axis,
Visible portion of the numberline. Must be strictly horizontal.
t0,
Limit value along left end of axis.
t1,
Limit value along right end of axis.
properties,
Properties.
finest,
Exponent of the finest tick class. Ticks of this class are drawn in the SHORT style, coarser ticks in the LONG style. Labels are only considered for the finest class and coarser.
tickLength,
Pixel length per power-of-ten class exponent. Zero or less means the class is not drawn. The class directly below the finest one is included while it still has a positive length, so it can animate away.
labelOpacity
Opacity per label rung. Callers that do not animate can return one when the rung fits and zero otherwise.
)

Create

#
Create a number line layout.
public static TickLayout Create(
axis,
Visible portion of the numberline. Must be strictly horizontal.
t0,
Limit value along left end of axis.
t1,
Limit value along right end of axis.
properties
Properties.
)

Create

#
Create a number line layout within a box.
public static TickLayout Create(
RectangleF
bounds,
Bounds. The number-line will either be aligned along the top, middle or bottom of the bounds depending on the tick and label style.
t0,
Limit value along left end of box.
t1,
Limit value along right end of box.
properties
Properties.
)

Draw

#
Draw this layout to a graphics context.
public void Draw(
Graphics
graphics,
Graphics object to draw with.
Pen
axisPen = null,
Optional pen for axis line.
Func<decimal, Color>
tickColour = null,
Optional colour override for ticks.
Func<decimal, Color>
labelColour = null
Optional colour override for labels.
)

Evaluate

#
Evaluate a parameter and return its point on the number line.
public PointF Evaluate()

FormatLabel

#
Format a tick label. Round values of a hundred thousand and up use an SI prefix (k, M, G, T) so that 10,000,000 reads as 10M. Tick values are small multiples of a power of ten, so the mantissa is always short.
public static string FormatLabel(
value
Tick value.
)
Label text.

Project

#
Project a point (y-coordinate is ignored) onto the number line.
public decimal Project(
PointF
p
)

SmallestTickExponent

#
Compute the power-of-ten exponent of the smallest tick class that would be laid out along an axis of the given range and pixel width.
public static int SmallestTickExponent(
range,
Numeric range spanned by the axis.
width,
Pixel width of the axis.
spacing
Minimum pixel spacing between adjacent ticks.
)
Exponent e such that the smallest ticks are 10^e apart.

ToInfiniteSnapSpace

#
Create a snapping space based on this numberline. Snapping will occur on the infinite line, based on some subdivision of the smallest visible ticks.
public SnapSpace ToInfiniteSnapSpace(
division = 1
Tick division. 1=only at visible ticks.
)

ToSnapSpace

#
Create a snapping space based on this numberline. Snapping will only happen at visible ticks, not implied ticks outside of the bounds.
public SnapSpace ToSnapSpace()