Skip to main content

Module ticks

Module ticks 

Source
Expand description

Where an axis’s ticks fall: on nice numbers, 1, 2 or 5 times a power of ten, or on calendar boundaries such as hours, days, months and years. Pure arithmetic; crate::widgets::axes decides how many fit and draws them.

Structs§

CalendarStep
Every n of a unit. Each step divides the unit above it, so a new day, month or year always lands on a tick.

Enums§

Unit
A calendar unit a time axis ticks on.

Functions§

calendar_labels
Labels for ticks on unit boundaries, each naming the coarsest unit that turns there: 2026 at a new year, Apr at a new month, Mar 5 at a new day among hours, otherwise the tick in its own unit (12, 06:00). With context the first tick also names the year (and the day, for hours) the axis starts in. A time of day reads as a clock.
calendar_steps
The calendar steps a kind axis can take, finest first: a date ticks on days at the finest, a time of day on hours at the coarsest.
calendar_ticks
The ticks of step from lo to hi, on its boundaries; none when there would be too many to consider.
from_datetime
The axis value a date and time stands at, the inverse of to_datetime.
minor_steps
A finer step that ticks between those of step, 1-2-5 as well: tenths of a 1-step, fifths, halves; halves or quarters of a 2-step; fifths of a 5-step. Finest first.
multiples
The multiples of step from lo to hi.
nice_steps
The 1-2-5 steps for an axis from lo to hi, finest first: from the finest no finer than finest to the first that spans the whole axis. 25, 250 and so on step between 20 and 50 where they need no more places than their neighbors. A whole axis steps by whole numbers only.
to_datetime
An axis value as the date and time it stands for; a time of day falls on the epoch’s day.
widen
lo to hi widened out to multiples of step, never to nothing.
widen_snug
widen, except that an end a whole tick would leave more than three quarters of a step empty stops at the coarsest minor tick past the data instead. A mean a hair under zero widened a step-10 axis down to -10, a fifth of the plot holding nothing.