Skip to main content

ContourConfig

Struct ContourConfig 

Source
pub struct ContourConfig {
    pub levels: Vec<f64>,
    pub line: DataLineStyleConfig,
    pub per_level_color: Option<Vec<Color>>,
    pub labels: Option<ContourLabelConfig>,
}
Expand description

Contour lines over a field.

Fields§

§levels: Vec<f64>

The levels to draw, in data units, with at most MAX_CONTOUR_LEVELS entries. An explicit list only — there is no “auto” variant, because a level set inferred at draw time is a value the config does not contain. A helper computes levels and writes them here.

§line: DataLineStyleConfig§per_level_color: Option<Vec<Color>>

Per-level colours, indexed by level. None means every level is line.line_color — colours are not derived from the colormap here. A helper that wants colormap colours computes them and writes them in.

§labels: Option<ContourLabelConfig>

Implementations§

Source§

impl ContourConfig

Source

pub fn nice_levels( axis: &AxisOptions, target_count: usize, ) -> Result<Vec<f64>, TickError>

About target_count round levels inside a colourbar’s z range.

There is no Auto level variant, and this is why there does not need to be one: the levels a chart draws are always the ones in Self::levels, and a caller who wants them chosen for it calls this and stores the answer. What is drawn is then still exactly what the config says.

Levels are strictly inside the range. One sitting exactly on axis.min or axis.max coincides with the field’s outer boundary or has no visible coverage at all, and it would also make the banded fill’s n + 1 bands come out wrong by one.

The spacing is the axis machinery’s own: compute_nice_ticks picks it, and the walk anchors to absolute multiples of it, so the levels are round numbers even when the range ends are not. A logarithmic colourbar gets decades from the same call, with no separate rule here.

Source

pub fn set_nice_levels( &mut self, axis: &AxisOptions, target_count: usize, ) -> Result<(), TickError>

Replace Self::levels with Self::nice_levels.

Self::per_level_color is left alone: a colour list that no longer lines up with the new levels falls back to Self::line’s colour per level rather than being silently thrown away. Call Self::set_colormap_colors after this to re-derive it.

Source

pub fn set_colormap_colors(&mut self, bar: &ColorBarOptions)

Colour every level by where it sits on the colourbar’s ramp.

The helper the per_level_color doc means by “a helper that wants colormap colours computes them and writes them in” — the field’s fill and the lines over it then agree about what a value looks like, because both go through ColorBarOptions::color_for_z. A level the ramp cannot place takes nan_color, the same as a cell with that value.

Trait Implementations§

Source§

impl Clone for ContourConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ContourConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ContourConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ContourConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ContourConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ContourConfig

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.