umya_spreadsheet/structs/
chart_type.rs

1use super::EnumTrait;
2use std::str::FromStr;
3#[derive(Clone, Debug)]
4pub enum ChartType {
5    LineChart,
6    Line3DChart,
7    PieChart,
8    Pie3DChart,
9    DoughnutChart,
10    ScatterChart,
11    BarChart,
12    Bar3DChart,
13    RadarChart,
14    BubbleChart,
15    AreaChart,
16    Area3DChart,
17    OfPieChart,
18}
19impl Default for ChartType {
20    fn default() -> Self {
21        Self::LineChart
22    }
23}
24impl EnumTrait for ChartType {
25    #[inline]
26    fn get_value_string(&self) -> &str {
27        match &self {
28            Self::LineChart => "line_chart",
29            Self::Line3DChart => "line_3d_chart",
30            Self::PieChart => "pie_chart",
31            Self::Pie3DChart => "pie_3d_chart",
32            Self::DoughnutChart => "doughnut_chart",
33            Self::ScatterChart => "scatter_chart",
34            Self::BarChart => "bar_chart",
35            Self::Bar3DChart => "bar_3d_chart",
36            Self::RadarChart => "radar_chart",
37            Self::BubbleChart => "bubble_chart",
38            Self::AreaChart => "area_chart",
39            Self::Area3DChart => "area_3d_chart",
40            Self::OfPieChart => "of_pie_chart",
41        }
42    }
43}
44impl FromStr for ChartType {
45    type Err = ();
46
47    #[inline]
48    fn from_str(input: &str) -> Result<Self, Self::Err> {
49        match input {
50            "line_chart" => Ok(Self::LineChart),
51            "line_3d_chart" => Ok(Self::Line3DChart),
52            "pie_chart" => Ok(Self::PieChart),
53            "pie_3d_chart" => Ok(Self::Pie3DChart),
54            "doughnut_chart" => Ok(Self::DoughnutChart),
55            "scatter_chart" => Ok(Self::ScatterChart),
56            "bar_chart" => Ok(Self::BarChart),
57            "bar_3d_chart" => Ok(Self::Bar3DChart),
58            "radar_chart" => Ok(Self::RadarChart),
59            "bubble_chart" => Ok(Self::BubbleChart),
60            "area_chart" => Ok(Self::AreaChart),
61            "area_3d_chart" => Ok(Self::Area3DChart),
62            "of_pie_chart" => Ok(Self::OfPieChart),
63            _ => Err(()),
64        }
65    }
66}