Skip to main content

PriceFormatter

Trait PriceFormatter 

Source
pub trait PriceFormatter: Send + Sync {
    // Required methods
    fn format(&self, price: f64) -> String;
    fn clone_box(&self) -> Box<dyn PriceFormatter>;

    // Provided method
    fn format_tick(&self, price: f64) -> String { ... }
}
Expand description

Trait for custom price formatting on the Y axis.

Implement this trait to control how numeric prices are displayed as labels. All formatters must be Send + Sync so they can be shared across the render pipeline.

Required Methods§

Source

fn format(&self, price: f64) -> String

Format a price value into a display string

§Arguments
  • price - The price value to format
§Returns

Formatted string to display on the price axis

Source

fn clone_box(&self) -> Box<dyn PriceFormatter>

Clone this formatter into a Box

Provided Methods§

Source

fn format_tick(&self, price: f64) -> String

Format a price axis tick. Defaults to format; override it to write ticks differently from crosshair and price tag labels.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§