Ticks
Mojo struct 🡭
Ticks
@memory_only
struct TicksLinearScale.ticks()’s result: the tick positions plus how many decimal places they need for display, both from the same _nice_step computation.
Fields
- values (
List[Float64]): The tick positions themselves, in the scale’s data domain. - decimals (
Int): How many decimal places every tick value needs for display, from_nice_step. Unused whenoverride_labelsis non-empty. - override_labels (
List[String]): Pre-formatted labels, one pervaluesentry; empty (the default) when every tick shares onedecimalscount. Non-empty only for_log_ticks(), where each tick needs its own decimal count (0.01 needs 2 places, 100 needs 0). - minor_values (
List[Float64]): Unlabeled subdivisions between the majorvalues, empty when the scale has no opinion about them – which is what a categorical or zero-span axis says, so nothing moves for it. Never contains a value that is also invalues: a minor tick drawn on top of a major one is invisible at best and, in a lighter color, a smudge on the major one at worst.
These carry no labels by construction, so they never enter the
dynamic left margin – that margin is measured from tick label
widths, and a reader of frame.mojo will want to know minor ticks
cannot widen it.
Implemented traits
AnyType, Deinitable, Movable
Methods
__init__
fn def __init__(out self, var values: List[Float64], decimals: Int, var override_labels: List[String] = List(), var minor_values: List[Float64] = List())Construct a Ticks from already-computed positions and a decimal count; normally built by LinearScale.ticks().
Args:
- values (
List[Float64]): The tick positions, in the scale’s data domain. - decimals (
Int): How many decimal places every tick value needs for display. Ignored ifoverride_labelsis given. - override_labels (
List[String]): Pre-formatted labels, one pervaluesentry; left empty (the default) to format every tick viadecimalsinstead. - minor_values (
List[Float64]): Unlabeled subdivisions between the major values; left empty (the default) for an axis with no minor level. - self (
Self)
Returns:
Self
labels
fn def labels(self, format: TickFormat = TickFormat.AUTO) -> List[String]Each tick value formatted via _format_tick() at this Ticks’ decimals, or override_labels unchanged when set – format doesn’t apply to override_labels (only _log_ticks() sets it today, and each of its labels already carries its own per-tick decimal count; log-axis ticks keep their default format).
Args:
- self (
Self) - format (
TickFormat): How to render each value;AUTO(the default) preserves this method’s default behavior.
Returns:
List[String]: One formatted string per values entry, same order.