pub struct Scale {
pub kind: ScaleKind,
pub domain_min: f64,
pub domain_max: f64,
pub range_min: f64,
pub range_max: f64,
pub categories: Vec<String>,
pub log_base: f64,
pub band: f64,
pub count: usize,
}Expand description
A mapping from data values to pixel positions.
One scale serves one axis. The scale knows the data domain (the range of values the data cover) and the pixel range (the extent of the grid along the axis), and maps between them.
Fields§
§kind: ScaleKindThe kind of the scale.
domain_min: f64The lower end of the data domain.
domain_max: f64The upper end of the data domain.
range_min: f64The lower end of the pixel range.
range_max: f64The upper end of the pixel range.
categories: Vec<String>The categories of an ordinal scale.
log_base: f64The base of a logarithmic scale.
band: f64The width of one band of an ordinal scale, in pixels.
A band is the space one category occupies. It is larger than the distance between two category centres by exactly one band, which is what lets a bar chart draw a bar that fills its band without spilling into the neighbouring one.
count: usizeThe number of categories of an ordinal scale.
The count is kept apart from the names because the two are not the same: a chart over a million unnamed points has a million categories and not one name.
Implementations§
Source§impl Scale
Inherent implementation of Scale.
impl Scale
Inherent implementation of Scale.
Sourcepub fn log(
domain_min: f64,
domain_max: f64,
range_min: f64,
range_max: f64,
base: f64,
) -> Self
pub fn log( domain_min: f64, domain_max: f64, range_min: f64, range_max: f64, base: f64, ) -> Self
Returns a logarithmic scale covering the given domain and range.
§Arguments
f64- A 64-bit float (f64).
Sourcepub fn category(
categories: Vec<String>,
range_min: f64,
range_max: f64,
band: f64,
) -> Self
pub fn category( categories: Vec<String>, range_min: f64, range_max: f64, band: f64, ) -> Self
Returns an ordinal scale over the given categories.
range_min and range_max are the positions of the centres of
the first and the last band, and band is the width of one band.
§Arguments
Vec<String>- AVec<String>parameter.f64- A 64-bit float (f64).
Sourcepub fn category_count(
count: usize,
range_min: f64,
range_max: f64,
band: f64,
) -> Self
pub fn category_count( count: usize, range_min: f64, range_max: f64, band: f64, ) -> Self
Returns an ordinal scale over the given number of categories.
The scale has no names: it is used for a chart whose points are not named, where keeping a million empty strings would be pure waste.
§Arguments
usize- A non-negative integer (usize).f64- A 64-bit float (f64).
Sourcepub fn band_width(&self) -> f64
pub fn band_width(&self) -> f64
Returns the width of one band of an ordinal scale, in pixels.
Returns 0.0 for a scale that is not ordinal.
§Returns
f64- A 64-bit float.