Skip to main content

nominal_api/conjure/objects/scout/chartdefinition/api/
numeric_bar_visualisation_v2.rs

1/// A numeric visualisation that will fill the cell from left to right with a colored background
2/// representing where the value falls inside a set range.
3/// The lowest and highest values in the thresholds determine the start and end of the range.
4/// Middle threshold values will still affect the cell's coloration.
5#[derive(
6    Debug,
7    Clone,
8    conjure_object::serde::Serialize,
9    conjure_object::serde::Deserialize,
10    conjure_object::private::DeriveWith
11)]
12#[serde(crate = "conjure_object::serde")]
13#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
14#[conjure_object::private::staged_builder::staged_builder]
15#[builder(crate = conjure_object::private::staged_builder, update, inline)]
16pub struct NumericBarVisualisationV2 {
17    #[builder(default, into)]
18    #[serde(rename = "thresholds", skip_serializing_if = "Option::is_none", default)]
19    thresholds: Option<Vec<super::Threshold>>,
20}
21impl NumericBarVisualisationV2 {
22    /// Constructs a new instance of the type.
23    #[inline]
24    pub fn new() -> Self {
25        Self::builder().build()
26    }
27    /// Modifies the visualisation based on the highest threshold value that
28    /// the computed value equals or surpasses. The lowest and highest value will determine
29    /// the 0% and 100% values of the bar.
30    #[inline]
31    pub fn thresholds(&self) -> Option<&[super::Threshold]> {
32        self.thresholds.as_ref().map(|o| &**o)
33    }
34}