diff --git a/plotly/src/common/mod.rs b/plotly/src/common/mod.rs index cd866c3a..df2dc9ba 100644 --- a/plotly/src/common/mod.rs +++ b/plotly/src/common/mod.rs @@ -1180,7 +1180,10 @@ pub struct Marker { size_mode: Option, line: Option, gradient: Option, + /// Marker option specific for Scatter and other common traces color: Option>>, + /// Marker option specific for Pie charts to set the colors of the sectors + colors: Option>>, cauto: Option, cmin: Option, cmax: Option, @@ -1260,6 +1263,11 @@ impl Marker { self } + pub fn colors(mut self, colors: Vec) -> Self { + self.colors = Some(ColorArray(colors).into()); + self + } + pub fn color_array(mut self, colors: Vec) -> Self { self.color = Some(Dim::Vector(ColorArray(colors).into())); self @@ -2330,6 +2338,7 @@ mod tests { .line(Line::new()) .gradient(Gradient::new(GradientType::Radial, "#FFFFFF")) .color(NamedColor::Blue) + .colors(vec![NamedColor::Black, NamedColor::Blue]) .color_array(vec![NamedColor::Black, NamedColor::Blue]) .cauto(true) .cmin(0.0) @@ -2359,6 +2368,7 @@ mod tests { "line": {}, "gradient": {"type": "radial", "color": "#FFFFFF"}, "color": ["black", "blue"], + "colors": ["black", "blue"], "colorbar": {}, "cauto": true, "cmin": 0.0,