pub struct ScaleOrdinal { /* private fields */ }Expand description
Maps discrete domain values to discrete range values (typically colors).
Equivalent to D3’s scaleOrdinal().
Implementations§
Source§impl ScaleOrdinal
impl ScaleOrdinal
Sourcepub fn new(domain: Vec<String>, range: Vec<String>) -> Self
pub fn new(domain: Vec<String>, range: Vec<String>) -> Self
Create a new ordinal scale with the given domain and range.
Sourcepub fn map(&self, value: &str) -> Option<&str>
pub fn map(&self, value: &str) -> Option<&str>
Map a domain value to a range value. Uses index-based lookup: domain[i] -> range[i % range.len()] Returns None if the value is not in the domain or if the range is empty.
Auto Trait Implementations§
impl Freeze for ScaleOrdinal
impl RefUnwindSafe for ScaleOrdinal
impl Send for ScaleOrdinal
impl Sync for ScaleOrdinal
impl Unpin for ScaleOrdinal
impl UnsafeUnpin for ScaleOrdinal
impl UnwindSafe for ScaleOrdinal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more