Skip to main content

ScaleSqrt

Struct ScaleSqrt 

Source
pub struct ScaleSqrt { /* private fields */ }
Expand description

Square root scale for bubble sizes. Maps continuous domain to continuous range via sqrt transformation. Equivalent to D3’s scaleSqrt(). This is a power scale with exponent 0.5.

Implementations§

Source§

impl ScaleSqrt

Source

pub fn new(domain: (f64, f64), range: (f64, f64)) -> Self

Create a new sqrt scale with the given domain and range.

Source

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

Map a domain value to a range value using sqrt interpolation. Negative domain values are clamped to 0 before sqrt.

Source

pub fn invert(&self, value: f64) -> f64

Inverse mapping: range value back to domain value.

Source

pub fn ticks(&self, count: usize) -> Vec<f64>

Generate ticks by computing them in sqrt-transformed space, then squaring back to the original domain.

Source

pub fn domain(&self) -> (f64, f64)

Get the domain extent.

Source

pub fn range(&self) -> (f64, f64)

Get the range extent.

Trait Implementations§

Source§

impl ContinuousScale for ScaleSqrt

Source§

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

Map a domain value to a range value.
Source§

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

Get the domain extent as (min, max).
Source§

fn range(&self) -> (f64, f64)

Get the range extent as (min, max).
Source§

fn ticks(&self, count: usize) -> Vec<f64>

Generate approximately count nice tick values within the domain.
Source§

fn clamp(&self, value: f64) -> f64

Clamp a value to domain bounds.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,