Skip to main content

plotlars_core/components/
mode.rs

1/// An enumeration representing different drawing modes for scatter-type plots.
2///
3/// The `Mode` enum specifies how data points should be displayed in plots like
4/// scatter plots, line plots, and polar scatter plots.
5///
6/// # Example
7///
8/// ```rust
9/// use plotlars::{Line, Mode, Plot, Rgb, ScatterPolar, Shape, Text};
10/// use polars::prelude::*;
11///
12/// // Create sample data - radar chart style
13/// let categories = vec![0., 72., 144., 216., 288., 360.];
14/// let performance = vec![8.0, 6.5, 7.0, 9.0, 5.5, 8.0];
15///
16/// let dataset = DataFrame::new(categories.len(), vec![
17///     Column::new("category".into(), categories),
18///     Column::new("performance".into(), performance),
19/// ])
20/// .unwrap();
21///
22/// ScatterPolar::builder()
23///     .data(&dataset)
24///     .theta("category")
25///     .r("performance")
26///     .mode(Mode::LinesMarkers)
27///     .color(Rgb(255, 0, 0))
28///     .shape(Shape::Diamond)
29///     .line(Line::Solid)
30///     .width(3.0)
31///     .size(12)
32///     .opacity(0.8)
33///     .plot_title(
34///         Text::from("Performance Radar Chart")
35///             .font("Arial")
36///             .size(22)
37///             .x(0.5)
38///     )
39///     .build()
40///     .plot();
41/// ```
42///
43/// ![Example](https://imgur.com/PKDr2RJ.png)
44#[derive(Clone, Copy)]
45pub enum Mode {
46    /// Draw only lines connecting the data points
47    Lines,
48    /// Draw only markers at each data point
49    Markers,
50    /// Draw only text labels at each data point
51    Text,
52    /// Draw both lines and markers
53    LinesMarkers,
54    /// Draw both lines and text labels
55    LinesText,
56    /// Draw both markers and text labels
57    MarkersText,
58    /// Draw lines, markers, and text labels
59    LinesMarkersText,
60    /// Do not draw any visual elements (useful for invisible traces)
61    None,
62}