Struct Chart

Source
pub struct Chart { /* private fields */ }
Expand description

§Supported chart types

  • AreaChart
  • Area3DChart
  • BarChart
  • Bar3DChart
  • BubbleChart
  • DoughnutChart
  • LineChart
  • Line3DChart
  • OfPieChart
  • PieChart
  • RadarChart
  • ScatterChart

Other types will be supported sequentially.

§Example

Result Image

extern crate umya_spreadsheet;
let mut book = umya_spreadsheet::new_file();

// Add Chart
let mut from_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default();
let mut to_marker = umya_spreadsheet::structs::drawing::spreadsheet::MarkerType::default();
from_marker.set_coordinate("C1");
to_marker.set_coordinate("D11");
let area_chart_series_list = vec![
    "Sheet1!$A$1:$A$10",
    "Sheet1!$B$1:$B$10",
];
let mut chart = umya_spreadsheet::structs::Chart::default();
chart.new_chart(
    umya_spreadsheet::structs::ChartType::LineChart,
    from_marker,
    to_marker,
    area_chart_series_list,
);
book.get_sheet_by_name_mut("Sheet1").unwrap()
    .add_chart(chart);

// Get Chart by Worksheet.
let mut worksheet = book.get_sheet_by_name_mut("Sheet1").unwrap();
let chart = worksheet.get_chart("C1");
let chart = worksheet.get_chart_by_column_and_row(&3, &1);
let chart = worksheet.get_chart_mut("C1");
let chart = worksheet.get_chart_by_column_and_row_mut(&3, &1);

// Use this if there are multiple Charts in a given cell.
let charts = worksheet.get_charts("C1");
let charts = worksheet.get_charts_by_column_and_row(&3, &1);
let charts = worksheet.get_charts_mut("C1");
let charts = worksheet.get_charts_by_column_and_row_mut(&3, &1);

// Set Chart Title, Series Title, Horizonal Title and Vertical Title.
let mut chart = book.get_sheet_by_name_mut("Sheet1").unwrap().get_chart_mut("C1").unwrap();
chart
    .set_series_title(vec!["Line1", "Line2"])
    .set_series_point_title(vec!["Point1", "Point2", "Point3", "Point4"])
    .set_title("Chart Title")
    .set_horizontal_title("Horizontal Title")
    .set_vertical_title("Vertical Title");

// line chart is a stack line chart by default.
// To change it to an actual line chart, configure as follows
chart
    .set_grouping(umya_spreadsheet::drawing::charts::GroupingValues::Standard);

Implementations§

Source§

impl Chart

Source

pub fn set_title<S: Into<String>>(&mut self, value: S) -> &mut Self

Source

pub fn set_grouping(&mut self, value: GroupingValues) -> &mut Self

Source

pub fn set_vertical_title<S: Into<String>>(&mut self, value: S) -> &mut Self

Source

pub fn set_horizontal_title<S: Into<String>>(&mut self, value: S) -> &mut Self

Source

pub fn set_series_title<S: Into<String>>(&mut self, value: Vec<S>) -> &mut Self

Source

pub fn set_series_point_title<S: Into<String>>( &mut self, value: Vec<S>, ) -> &mut Self

Source

pub fn get_plot_area_mut(&mut self) -> &mut PlotArea

Source

pub fn get_area_chart_series_list_mut(&mut self) -> &mut AreaChartSeriesList

Source

pub fn get_two_cell_anchor(&self) -> &TwoCellAnchor

Source

pub fn get_two_cell_anchor_mut(&mut self) -> &mut TwoCellAnchor

Source

pub fn set_two_cell_anchor(&mut self, value: TwoCellAnchor) -> &mut Self

Source

pub fn set_default_language<S: Into<String>>(&mut self, value: S) -> &mut Self

Source

pub fn get_chart_space(&self) -> &ChartSpace

Source

pub fn get_chart_space_mut(&mut self) -> &mut ChartSpace

Source

pub fn new_chart( &mut self, chart_type: ChartType, from_marker: MarkerType, to_marker: MarkerType, area_chart_series_list: Vec<&str>, ) -> &mut Self

Source

pub fn get_coordinate(&self) -> String

Trait Implementations§

Source§

impl Clone for Chart

Source§

fn clone(&self) -> Chart

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Chart

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Chart

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Chart

§

impl RefUnwindSafe for Chart

§

impl Send for Chart

§

impl Sync for Chart

§

impl Unpin for Chart

§

impl UnwindSafe for Chart

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.