Skip to main content

Scale

Trait Scale 

Source
pub trait Scale: Send + Sync {
Show 19 methods // Required methods fn aesthetic(&self) -> Aesthetic; fn train(&mut self, values: &[Value]); fn map(&self, value: &Value) -> f64; fn breaks(&self) -> Vec<(f64, String)>; fn name(&self) -> &str; fn set_name(&mut self, name: &str); fn clone_box(&self) -> Box<dyn Scale>; // Provided methods fn transform(&self, value: &Value) -> Value { ... } fn is_discrete(&self) -> bool { ... } fn map_to_color(&self, _value: &Value) -> Option<(u8, u8, u8)> { ... } fn map_to_shape(&self, _value: &Value) -> Option<PointShape> { ... } fn map_to_linetype(&self, _value: &Value) -> Option<Linetype> { ... } fn map_to_size(&self, _value: &Value) -> Option<f64> { ... } fn map_to_alpha(&self, _value: &Value) -> Option<f64> { ... } fn sec_axis(&self) -> Option<&SecAxis> { ... } fn set_limits(&mut self, _min: f64, _max: f64) { ... } fn filter_limits(&self) -> Option<(f64, f64)> { ... } fn domain(&self) -> Option<(f64, f64)> { ... } fn reset_training(&mut self) { ... }
}
Expand description

Trait for scales that map data values to visual properties.

Required Methods§

Source

fn aesthetic(&self) -> Aesthetic

Which aesthetic this scale is for.

Source

fn train(&mut self, values: &[Value])

Incorporate data values to determine domain.

Source

fn map(&self, value: &Value) -> f64

Map a data value to a [0, 1] normalized position (position scales) or to a concrete visual value index (color/size scales).

Source

fn breaks(&self) -> Vec<(f64, String)>

Generate break positions and labels for axis/legend.

Source

fn name(&self) -> &str

Human-readable name (axis title).

Source

fn set_name(&mut self, name: &str)

Set the scale name.

Source

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

Clone this scale into a boxed trait object.

Provided Methods§

Source

fn transform(&self, value: &Value) -> Value

Apply transformation to raw data (e.g., log10).

Source

fn is_discrete(&self) -> bool

Whether this is a discrete scale.

Source

fn map_to_color(&self, _value: &Value) -> Option<(u8, u8, u8)>

Map a data value to an RGB color. Default returns None.

Source

fn map_to_shape(&self, _value: &Value) -> Option<PointShape>

Map a data value to a point shape. Default returns None.

Source

fn map_to_linetype(&self, _value: &Value) -> Option<Linetype>

Map a data value to a linetype. Default returns None.

Source

fn map_to_size(&self, _value: &Value) -> Option<f64>

Map a data value to a point size (radius in pixels). Default returns None.

Source

fn map_to_alpha(&self, _value: &Value) -> Option<f64>

Map a data value to an alpha (opacity) value. Default returns None.

Source

fn sec_axis(&self) -> Option<&SecAxis>

Get the secondary axis specification, if any.

Source

fn set_limits(&mut self, _min: f64, _max: f64)

Override the trained domain limits (used by coord_cartesian zoom).

Source

fn filter_limits(&self) -> Option<(f64, f64)>

Return OOB filter limits if this scale was created with explicit limits (e.g., via xlim/ylim). Data outside these limits should be removed before stats.

Source

fn domain(&self) -> Option<(f64, f64)>

Return the trained data domain (min, max) for continuous scales. Used by the colorbar legend to pass data-space values to map_to_color().

Source

fn reset_training(&mut self)

Reset training state so the scale can be retrained on new data.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§