xlsxwriter.chart

@page chart_page The Chart object

The Chart object represents an Excel chart. It provides functions for adding data series to the chart and for configuring the chart.

See @ref chart.h for full details of the functionality.

@file chart.h

@brief Functions related to adding data to and configuring a chart.

The Chart object represents an Excel chart. It provides functions for adding data series to the chart and for configuring the chart.

A Chart object isn't created directly. Instead a chart is created by calling the workbook_add_chart() function from a Workbook object. For

Members

Enums

lxw_chart_axis_positions
enum lxw_chart_axis_positions
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_chart_groupings
enum lxw_chart_groupings
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_chart_positions
enum lxw_chart_positions
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_chart_subtypes
enum lxw_chart_subtypes
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_chart_types
enum lxw_chart_types

Available chart types .

Functions

chart_add_series
lxw_chart_series* chart_add_series(lxw_chart* chart, char* categories, char* values)

@brief Add a data series to a chart.

chart_axis_set_name
void chart_axis_set_name(lxw_chart_axis* axis, char* name)

@brief Set the name caption of the an axis.

chart_axis_set_name_range
void chart_axis_set_name_range(lxw_chart_axis* axis, char* sheetname, lxw_row_t row, lxw_col_t col)

@brief Set a chart axis name formula using row and column values.

chart_series_set_categories
void chart_series_set_categories(lxw_chart_series* series, char* sheetname, lxw_row_t first_row, lxw_col_t first_col, lxw_row_t last_row, lxw_col_t last_col)

@brief Set a series "categories" range using row and column values.

chart_series_set_name
void chart_series_set_name(lxw_chart_series* series, char* name)

@brief Set the name of a chart series range.

chart_series_set_name_range
void chart_series_set_name_range(lxw_chart_series* series, char* sheetname, lxw_row_t row, lxw_col_t col)

@brief Set a series name formula using row and column values.

chart_series_set_values
void chart_series_set_values(lxw_chart_series* series, char* sheetname, lxw_row_t first_row, lxw_col_t first_col, lxw_row_t last_row, lxw_col_t last_col)

@brief Set a series "values" range using row and column values.

chart_set_hole_size
void chart_set_hole_size(lxw_chart* chart, uint8_t size)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
chart_set_rotation
void chart_set_rotation(lxw_chart* chart, uint16_t rotation)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
chart_set_style
void chart_set_style(lxw_chart* chart, uint8_t style_id)

@brief Set the chart style type.

chart_title_off
void chart_title_off(lxw_chart* chart)

@brief Turn off an automatic chart title.

chart_title_set_name
void chart_title_set_name(lxw_chart* chart, char* name)

@brief Set the title of the chart.

chart_title_set_name_range
void chart_title_set_name_range(lxw_chart* chart, char* sheetname, lxw_row_t row, lxw_col_t col)

@brief Set a chart title formula using row and column values.

lxw_chart_add_data_cache
int lxw_chart_add_data_cache(lxw_series_range* range, uint8_t* data, uint16_t rows, uint8_t cols, uint8_t col)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_chart_assemble_xml_file
void lxw_chart_assemble_xml_file(lxw_chart* chart)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_chart_free
void lxw_chart_free(lxw_chart* chart)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_chart_new
lxw_chart* lxw_chart_new(uint8_t type)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.

Manifest constants

LXW_CHART_NUM_FORMAT_LEN
enum LXW_CHART_NUM_FORMAT_LEN;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.

Structs

lxw_chart
struct lxw_chart

@brief Struct to represent an Excel chart.

lxw_chart_axis
struct lxw_chart_axis

@brief Struct to represent an Excel chart axis. It is used in functions that modify a chart axis but the members of the struct aren't modified directly.

lxw_chart_font
struct lxw_chart_font
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_chart_series
struct lxw_chart_series

@brief Struct to represent an Excel chart data series.

lxw_chart_title
struct lxw_chart_title
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_series_data_point
struct lxw_series_data_point
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
lxw_series_range
struct lxw_series_range
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.

Examples

@code

#include "xlsxwriter.h"

int main() {

lxw_workbook *workbook = new_workbook("chart.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

// User function to add data to worksheet, not shown here. write_worksheet_data(worksheet);

// Create a chart object. lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN);

// In the simplest case we just add some value data series. // The NULL categories will default to 1 to 5 like in Excel. chart_add_series(chart, NULL, "=Sheet1!$A$1:$A$5"); chart_add_series(chart, NULL, "=Sheet1!$B$1:$B$5"); chart_add_series(chart, NULL, "=Sheet1!$C$1:$C$5");

// Insert the chart into the worksheet worksheet_insert_chart(worksheet, CELL("B7"), chart);

return workbook_close(workbook); }

@endcode

The chart in the worksheet will look like this: @image html chart_simple.png

The basic procedure for adding a chart to a worksheet is:

1. Create the chart with workbook_add_chart(). 2. Add one or more data series to the chart which refers to data in the workbook using chart_add_series(). 3. Configure the chart with the other available functions shown below. 4. Insert the chart into a worksheet using worksheet_insert_chart().

Meta