Struct xlsxwriter::ChartSeries[][src]

pub struct ChartSeries<'a> { /* fields omitted */ }

Struct to represent an Excel chart data series. This struct is created using the chart.add_series() function. It is used in functions that modify a chart series but the members of the struct aren’t modified directly.

Implementations

impl<'a> ChartSeries<'a>[src]

pub fn set_categories(
    &mut self,
    sheet_name: &str,
    first_row: WorksheetRow,
    first_column: WorksheetCol,
    last_row: WorksheetRow,
    last_column: WorksheetCol
)
[src]

The categories and values of a chart data series are generally set using the chart_add_series() function and Excel range formulas like “=Sheet1!$A$2:$A$7”.

The ChartSeries.set_categories() function is an alternative method that is easier to generate programmatically. It requires that you set the categories and values parameters in Chart.add_series() to None and then set them using row and column values in ChartSeries.set_categories() and ChartSeries.set_values():

let mut series = chart.add_series(None, None);
series.set_categories("Sheet1", 0, 0, 4, 0); // "=Sheet1!$A$1:$A$5"
series.set_values("Sheet1", 0, 1, 4, 1);     // "=Sheet1!$B$1:$B$5"

pub fn set_values(
    &mut self,
    sheet_name: &str,
    first_row: WorksheetRow,
    first_column: WorksheetCol,
    last_row: WorksheetRow,
    last_column: WorksheetCol
)
[src]

The categories and values of a chart data series are generally set using the Chart.add_series() function and Excel range formulas like “=Sheet1!$A$2:$A$7”.

The Chart.series_set_values() function is an alternative method that is easier to generate programmatically. See the documentation for ChartSeries.set_categories() above.

pub fn set_name(&mut self, name: &str)[src]

This function is used to set the name for a chart data series. The series name in Excel is displayed in the chart legend and in the formula bar. The name property is optional and if it isn’t supplied it will default to Series 1..n.

use xlsxwriter::*;
let mut series = chart.add_series(None, Some("=Sheet1!$A$2:$A$6"));
series.set_name("Quarterly budget data");

The name parameter can also be a formula such as =Sheet1!$A$1 to point to a cell in the workbook that contains the name:

use xlsxwriter::*;
let mut series = chart.add_series(None, Some("=Sheet1!$A$2:$A$6"));
series.set_name("=Sheet1!$A$1:$A$1");

pub fn set_name_range(
    &mut self,
    sheet_name: &str,
    row: WorksheetRow,
    column: WorksheetCol
)
[src]

The ChartSeries.set_name_range() function can be used to set a series name range and is an alternative to using ChartSeries.set_name() and a string formula:

let mut series = chart.add_series(None, Some("=Sheet1!$B$2:$B$6"));
series.set_name_range("Sheet1", 0, 1); // =Sheet1!$B$1

pub fn set_line(&mut self, line: &ChartLine)[src]

Set the line/border properties of a chart series:

let mut series1 = chart.add_series(None, Some("=Sheet1!$A$2:$A$6"));
let mut series2 = chart.add_series(None, Some("=Sheet1!$B$2:$B$6"));
let mut series3 = chart.add_series(None, Some("=Sheet1!$C$2:$C$6"));
let mut chart_line = ChartLine::new();
chart_line.color = FormatColor::Red;
series1.set_line(&chart_line);
series2.set_line(&chart_line);
series3.set_line(&chart_line);

Result Image

pub fn set_fill(&mut self, fill: &ChartFill)[src]

Set the fill properties of a chart series:

let mut chart_fill_1 = ChartFill::new();
chart_fill_1.color = FormatColor::Red;
let mut chart_fill_2 = ChartFill::new();
chart_fill_2.color = FormatColor::Yellow;
let mut chart_fill_3 = ChartFill::new();
chart_fill_3.color = FormatColor::Green;
series1.set_fill(&chart_fill_1);
series2.set_fill(&chart_fill_2);
series3.set_fill(&chart_fill_3);

Result Image

pub fn set_invert_if_negative(&mut self)[src]

Invert the fill color for negative values. Usually only applicable to column and bar charts.

series1.set_invert_if_negative();

pub fn set_pattern(&mut self, pattern: &ChartPattern)[src]

Set the pattern properties of a chart series:

let pattern1 = ChartPattern::new(FormatColor::Custom(0x804000), FormatColor::Custom(0xC68C53), ChartPatternType::Shingle);
series1.set_pattern(&pattern1);
let pattern2 = ChartPattern::new(FormatColor::Custom(0xB30000), FormatColor::Custom(0xFF6666), ChartPatternType::HorizontalBrick);
series2.set_pattern(&pattern2);

Result Image

pub fn set_marker_type(&mut self, maker_type: ChartMarkerType)[src]

In Excel a chart marker is used to distinguish data points in a plotted series. In general only Line and Scatter and Radar chart types use markers.

series1.set_marker_type(ChartMarkerType::MarkerDiamond);

Result Image

pub fn set_marker_size(&mut self, maker_size: u8)[src]

This function is used to specify the size of the series marker.

series1.set_marker_type(ChartMarkerType::MarkerDiamond);
series1.set_marker_size(10);

pub fn set_marker_line(&mut self, chart_line: &ChartLine)[src]

Set the line/border properties of a chart marker.

series1.set_marker_type(ChartMarkerType::MarkerDiamond);
let mut marker_line = ChartLine::new();
marker_line.color = FormatColor::Red;
series1.set_marker_line(&marker_line);
series1.set_marker_size(10);

pub fn set_marker_fill(&mut self, chart_fill: &ChartFill)[src]

Set the line/border properties of a chart marker.

series1.set_marker_type(ChartMarkerType::MarkerDiamond);
let mut marker_line = ChartLine::new();
marker_line.color = FormatColor::Red;
series1.set_marker_line(&marker_line);
let mut marker_fill = ChartFill::new();
marker_fill.color = FormatColor::Yellow;
series1.set_marker_fill(&marker_fill);
series1.set_marker_size(10);

pub fn set_smooth(&mut self, smooth: bool)[src]

This function is used to set the smooth property of a line series. It is only applicable to the line and scatter chart types.

series1.set_smooth(true);

Result Image

pub fn set_labels(&mut self)[src]

This function is used to turn on data labels for a chart series. Data labels indicate the values of the plotted data points.

series1.set_marker_type(ChartMarkerType::MarkerDiamond);
series1.set_labels();

Result Image

Auto Trait Implementations

impl<'a> !RefUnwindSafe for ChartSeries<'a>

impl<'a> !Send for ChartSeries<'a>

impl<'a> !Sync for ChartSeries<'a>

impl<'a> Unpin for ChartSeries<'a>

impl<'a> !UnwindSafe for ChartSeries<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.