Skip to main content

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

1/// The root figure definition for a plotly instance
2#[derive(
3    Debug,
4    Clone,
5    conjure_object::serde::Serialize,
6    conjure_object::serde::Deserialize,
7    PartialEq,
8    Eq,
9    PartialOrd,
10    Ord,
11    Hash
12)]
13#[serde(crate = "conjure_object::serde")]
14#[conjure_object::private::staged_builder::staged_builder]
15#[builder(crate = conjure_object::private::staged_builder, update, inline)]
16pub struct Figure {
17    #[builder(default, list(item(type = super::Trace)))]
18    #[serde(rename = "data", skip_serializing_if = "Vec::is_empty", default)]
19    data: Vec<super::Trace>,
20    #[builder(custom(type = super::Layout, convert = Box::new))]
21    #[serde(rename = "layout")]
22    layout: Box<super::Layout>,
23    #[builder(into)]
24    #[serde(rename = "plotlyConfig")]
25    plotly_config: String,
26}
27impl Figure {
28    /// Constructs a new instance of the type.
29    #[inline]
30    pub fn new(layout: super::Layout, plotly_config: impl Into<String>) -> Self {
31        Self::builder().layout(layout).plotly_config(plotly_config).build()
32    }
33    #[inline]
34    pub fn data(&self) -> &[super::Trace] {
35        &*self.data
36    }
37    #[inline]
38    pub fn layout(&self) -> &super::Layout {
39        &*self.layout
40    }
41    /// The json config definition according to plotly's schema
42    /// https://plotly.com/python/figure-structure/#the-toplevel-config-attribute
43    #[inline]
44    pub fn plotly_config(&self) -> &str {
45        &*self.plotly_config
46    }
47}