TickLayout

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

Constructors

TickLayout

#
public TickLayout(Tick[] ticks, LineF axis, decimal t0, decimal t1)
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.
ticks (Tick[])
axis (LineF)
t0 (decimal)
t1 (decimal)

Properties

Axis

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

Bounds

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

T0

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

T1

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

TickCount

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

Indexers

this[]

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

Methods

Clip

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

Create

#
public static TickLayout Create(LineF axis, decimal t0, decimal t1, Properties properties, int finest, Func<int, float> tickLength, LabelOpacity labelOpacity)
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.
axis (LineF)Visible portion of the numberline. Must be strictly horizontal.
t0 (decimal)Limit value along left end of axis.
t1 (decimal)Limit value along right end of axis.
properties (Properties)Properties.
finest (int)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 (Func<int, float>)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 (TickLayout.LabelOpacity)Opacity per label rung. Callers that do not animate can return one when the rung fits and zero otherwise.

Create

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

Create

#
public static TickLayout Create(RectangleF bounds, decimal t0, decimal t1, Properties properties)
Create a number line layout within a box.
bounds (RectangleF)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 (decimal)Limit value along left end of box.
t1 (decimal)Limit value along right end of box.
properties (Properties)Properties.

Draw

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

Evaluate

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

FormatLabel

#
public static string FormatLabel(decimal value)
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.
value (decimal)Tick value.
Label text.

Project

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

SmallestTickExponent

#
public static int SmallestTickExponent(decimal range, float width, float spacing)
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.
range (decimal)Numeric range spanned by the axis.
width (float)Pixel width of the axis.
spacing (float)Minimum pixel spacing between adjacent ticks.
Exponent e such that the smallest ticks are 10^e apart.

ToInfiniteSnapSpace

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

ToSnapSpace

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