Skip to main content

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

1/// Line thresholds are used to mark values or demarcate regions along a single axis.
2#[derive(
3    Debug,
4    Clone,
5    conjure_object::serde::Serialize,
6    conjure_object::serde::Deserialize,
7    conjure_object::private::DeriveWith
8)]
9#[serde(crate = "conjure_object::serde")]
10#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
11#[conjure_object::private::staged_builder::staged_builder]
12#[builder(crate = conjure_object::private::staged_builder, update, inline)]
13pub struct LineThresholdGroup {
14    #[serde(rename = "shadingConfig")]
15    shading_config: super::ThresholdShadingConfig,
16    #[builder(default, list(item(type = super::LineThreshold)))]
17    #[serde(rename = "lines", skip_serializing_if = "Vec::is_empty", default)]
18    lines: Vec<super::LineThreshold>,
19    #[builder(
20        default,
21        custom(
22            type = impl
23            Into<Option<super::DefaultFill>>,
24            convert = |v|v.into().map(Box::new)
25        )
26    )]
27    #[serde(rename = "defaultFill", skip_serializing_if = "Option::is_none", default)]
28    default_fill: Option<Box<super::DefaultFill>>,
29}
30impl LineThresholdGroup {
31    /// Constructs a new instance of the type.
32    #[inline]
33    pub fn new(shading_config: super::ThresholdShadingConfig) -> Self {
34        Self::builder().shading_config(shading_config).build()
35    }
36    #[inline]
37    pub fn shading_config(&self) -> &super::ThresholdShadingConfig {
38        &self.shading_config
39    }
40    #[inline]
41    pub fn lines(&self) -> &[super::LineThreshold] {
42        &*self.lines
43    }
44    /// To supplement a set of line thresholds, the default fill configures how the remaining space (either
45    /// above or below) should be colored. Transparent if empty.
46    #[inline]
47    pub fn default_fill(&self) -> Option<&super::DefaultFill> {
48        self.default_fill.as_ref().map(|o| &**o)
49    }
50}