Available chart types .
@brief Add a data series to a chart.
@brief Set the name caption of the an axis.
@brief Set a chart axis name formula using row and column values.
@brief Set a series "categories" range using row and column values.
@brief Set the name of a chart series range.
@brief Set a series name formula using row and column values.
@brief Set a series "values" range using row and column values.
@brief Set the chart style type.
@brief Turn off an automatic chart title.
@brief Set the title of the chart.
@brief Set a chart title formula using row and column values.
@brief Struct to represent an Excel chart.
@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.
@brief Struct to represent an Excel chart data series.
@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().
@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