pub trait TimeFormatter: Send + Sync {
// Required methods
fn format(&self, time: DateTime<Utc>, mark_type: TickMarkType) -> String;
fn clone_box(&self) -> Box<dyn TimeFormatter>;
// Provided methods
fn format_tick(&self, context: TickMarkContext<'_>) -> Option<String> { ... }
fn wall_time(&self, time: DateTime<Utc>) -> DateTime<Utc> { ... }
fn utc_time(&self, wall_time: DateTime<Utc>) -> Option<DateTime<Utc>> { ... }
fn time_visible(&self) -> bool { ... }
fn format_crosshair(&self, time: DateTime<Utc>, bar_seconds: i64) -> String { ... }
}Expand description
Trait for custom time formatting Allows users to customize how time labels are displayed on the axis
Required Methods§
Sourcefn clone_box(&self) -> Box<dyn TimeFormatter>
fn clone_box(&self) -> Box<dyn TimeFormatter>
Clone this formatter into a Box
Provided Methods§
Sourcefn format_tick(&self, context: TickMarkContext<'_>) -> Option<String>
fn format_tick(&self, context: TickMarkContext<'_>) -> Option<String>
Formats one axis tick with the active chart locale and display-time fields.
Return None to use the chart’s normal locale and clock settings for this tick.
Some(String::new()) keeps an empty label. The default calls format,
preserving existing formatters. Builders and the chart call this after time-zone
conversion; hidden intraday clocks still use date labels instead.
This hook does not change format_crosshair.
Sourcefn wall_time(&self, time: DateTime<Utc>) -> DateTime<Utc>
fn wall_time(&self, time: DateTime<Utc>) -> DateTime<Utc>
Clock-face time used to identify calendar boundaries. The returned UTC value holds local fields, not another instant.
Sourcefn utc_time(&self, wall_time: DateTime<Utc>) -> Option<DateTime<Utc>>
fn utc_time(&self, wall_time: DateTime<Utc>) -> Option<DateTime<Utc>>
Converts local calendar fields from wall_time back to an instant.
Repeated times use the first instant; skipped times use the clock jump.
Sourcefn time_visible(&self) -> bool
fn time_visible(&self) -> bool
Whether intraday marks and hover labels include the clock.
Trait Implementations§
Source§impl HorizontalScale for Box<dyn TimeFormatter>
The time scale: calendar and clock boundaries in the formatter’s zone.
impl HorizontalScale for Box<dyn TimeFormatter>
The time scale: calendar and clock boundaries in the formatter’s zone.
Source§fn tick_marks(
&self,
points: &[(DateTime<Utc>, usize)],
layout: &TickMarkLayout,
) -> Vec<TickMark>
fn tick_marks( &self, points: &[(DateTime<Utc>, usize)], layout: &TickMarkLayout, ) -> Vec<TickMark>
points, the key and logical index of each bar in view in
order, extended into whitespace on both sides using the chart’s full-history time
mapping. When the keys reach before the first bar, every index is shifted by the same
number of slots, so only the order of the indices and their differences carry meaning.
The renderer places each mark at its key and skips labels that would overlap.Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".