umya-spreadsheet 2.3.3

umya-spreadsheet is a library written in pure Rust to read and write xlsx file.
Documentation
// c:scatterChart
use super::AreaChartSeries;
use super::AreaChartSeriesList;
use super::AxisId;
use super::DataLabels;
use super::ScatterStyle;
use super::VaryColors;
use crate::reader::driver::*;
use crate::structs::Spreadsheet;
use crate::writer::driver::*;
use quick_xml::events::{BytesStart, Event};
use quick_xml::Reader;
use quick_xml::Writer;
use std::io::Cursor;
use thin_vec::ThinVec;

#[derive(Clone, Default, Debug)]
pub struct ScatterChart {
    scatter_style: ScatterStyle,
    vary_colors: VaryColors,
    area_chart_series_list: AreaChartSeriesList,
    data_labels: DataLabels,
    axis_id: ThinVec<AxisId>,
}

impl ScatterChart {
    pub fn get_scatter_style(&self) -> &ScatterStyle {
        &self.scatter_style
    }

    pub fn get_scatter_style_mut(&mut self) -> &mut ScatterStyle {
        &mut self.scatter_style
    }

    pub fn set_scatter_style(&mut self, value: ScatterStyle) -> &mut ScatterChart {
        self.scatter_style = value;
        self
    }

    pub fn get_vary_colors(&self) -> &VaryColors {
        &self.vary_colors
    }

    pub fn get_vary_colors_mut(&mut self) -> &mut VaryColors {
        &mut self.vary_colors
    }

    pub fn set_vary_colors(&mut self, value: VaryColors) -> &mut ScatterChart {
        self.vary_colors = value;
        self
    }

    pub fn get_area_chart_series_list(&self) -> &AreaChartSeriesList {
        &self.area_chart_series_list
    }

    pub fn get_area_chart_series_list_mut(&mut self) -> &mut AreaChartSeriesList {
        &mut self.area_chart_series_list
    }

    pub fn set_area_chart_series_list(&mut self, value: AreaChartSeriesList) -> &mut Self {
        self.area_chart_series_list = value;
        self
    }

    pub fn get_data_labels(&self) -> &DataLabels {
        &self.data_labels
    }

    pub fn get_data_labels_mut(&mut self) -> &mut DataLabels {
        &mut self.data_labels
    }

    pub fn set_data_labels(&mut self, value: DataLabels) -> &mut ScatterChart {
        self.data_labels = value;
        self
    }

    pub fn get_axis_id(&self) -> &[AxisId] {
        &self.axis_id
    }

    pub fn get_axis_id_mut(&mut self) -> &mut ThinVec<AxisId> {
        &mut self.axis_id
    }

    pub fn set_axis_id(&mut self, value: impl Into<ThinVec<AxisId>>) -> &mut ScatterChart {
        self.axis_id = value.into();
        self
    }

    pub fn add_axis_id(&mut self, value: AxisId) -> &mut ScatterChart {
        self.axis_id.push(value);
        self
    }

    pub(crate) fn set_attributes<R: std::io::BufRead>(
        &mut self,
        reader: &mut Reader<R>,
        _e: &BytesStart,
    ) {
        xml_read_loop!(
            reader,
            Event::Start(ref e) => {
                match e.name().0 {
                b"c:ser" => {
                    let mut obj = AreaChartSeries::default();
                    obj.set_attributes(reader, e);
                    self.get_area_chart_series_list_mut()
                        .add_area_chart_series(obj);
                }
                b"c:dLbls" => {
                    self.data_labels.set_attributes(reader, e);
                }
                _ => (),
                }
            },
            Event::Empty(ref e) => {
                match e.name().0 {
                b"c:scatterStyle" => {
                    self.scatter_style.set_attributes(reader, e);
                }
                b"c:varyColors" => {
                    self.vary_colors.set_attributes(reader, e);
                }
                b"c:axId" => {
                    let mut obj = AxisId::default();
                    obj.set_attributes(reader, e);
                    self.add_axis_id(obj);
                }
                _ => (),
                }
            },
            Event::End(ref e) => {
                if e.name().0 == b"c:scatterChart" {
                    return;
                }
            },
            Event::Eof => panic!("Error: Could not find {} end element", "c:scatterChart")
        );
    }

    pub(crate) fn write_to(&self, writer: &mut Writer<Cursor<Vec<u8>>>, spreadsheet: &Spreadsheet) {
        // c:scatterChart
        write_start_tag(writer, "c:scatterChart", vec![], false);

        // c:scatterStyle
        self.scatter_style.write_to(writer);

        // c:varyColors
        self.vary_colors.write_to(writer);

        // c:ser
        for v in self.area_chart_series_list.get_area_chart_series() {
            v.write_to(writer, spreadsheet);
        }

        // c:dLbls
        self.data_labels.write_to(writer);

        // c:axId
        for v in &self.axis_id {
            v.write_to(writer);
        }

        write_end_tag(writer, "c:scatterChart");
    }
}