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§
Provided Methods§
Sourcefn is_discrete(&self) -> bool
fn is_discrete(&self) -> bool
Whether this is a discrete scale.
Sourcefn map_to_color(&self, _value: &Value) -> Option<(u8, u8, u8)>
fn map_to_color(&self, _value: &Value) -> Option<(u8, u8, u8)>
Map a data value to an RGB color. Default returns None.
Sourcefn map_to_shape(&self, _value: &Value) -> Option<PointShape>
fn map_to_shape(&self, _value: &Value) -> Option<PointShape>
Map a data value to a point shape. Default returns None.
Sourcefn map_to_linetype(&self, _value: &Value) -> Option<Linetype>
fn map_to_linetype(&self, _value: &Value) -> Option<Linetype>
Map a data value to a linetype. Default returns None.
Sourcefn map_to_size(&self, _value: &Value) -> Option<f64>
fn map_to_size(&self, _value: &Value) -> Option<f64>
Map a data value to a point size (radius in pixels). Default returns None.
Sourcefn map_to_alpha(&self, _value: &Value) -> Option<f64>
fn map_to_alpha(&self, _value: &Value) -> Option<f64>
Map a data value to an alpha (opacity) value. Default returns None.
Sourcefn set_limits(&mut self, _min: f64, _max: f64)
fn set_limits(&mut self, _min: f64, _max: f64)
Override the trained domain limits (used by coord_cartesian zoom).
Sourcefn filter_limits(&self) -> Option<(f64, f64)>
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.
Sourcefn domain(&self) -> Option<(f64, f64)>
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().
Sourcefn reset_training(&mut self)
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".