-
-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Add support for Chart date axes #91
Comments
+1 |
+1 |
Hi, Note, it is currently possible to use an implicit date axis by using date input data for the X-axis, see the example below. This Feature Request is mainly to add an explicit chart date axis option (like Excel) to enable max and min values and a few other features. Also note, the max and min is also currently available if you use a scatter chart (although the units won't be clear). Example: #include "xlsxwriter.h"
/* Create a worksheet with a chart. */
int main() {
lxw_workbook *workbook = new_workbook("chart_date.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
/* Add an Excel date format. */
lxw_format *date_format = workbook_add_format(workbook);
format_set_num_format(date_format, "yyyy-mm-dd");
/* Widen the first column to make the text clearer. */
worksheet_set_column(worksheet, 0, 0, 20, NULL);
/* Write some data for the chart. */
lxw_datetime datetime1 = {.year = 2016, .month = 1, .day = 13};
lxw_datetime datetime2 = {.year = 2016, .month = 1, .day = 14};
lxw_datetime datetime3 = {.year = 2016, .month = 1, .day = 15};
lxw_datetime datetime4 = {.year = 2016, .month = 1, .day = 16};
lxw_datetime datetime5 = {.year = 2016, .month = 1, .day = 17};
lxw_datetime datetime6 = {.year = 2016, .month = 1, .day = 18};
lxw_datetime datetime7 = {.year = 2016, .month = 1, .day = 19};
worksheet_write_datetime(worksheet, 0, 0, &datetime1, date_format);
worksheet_write_datetime(worksheet, 1, 0, &datetime2, date_format);
worksheet_write_datetime(worksheet, 2, 0, &datetime3, date_format);
worksheet_write_datetime(worksheet, 3, 0, &datetime4, date_format);
worksheet_write_datetime(worksheet, 4, 0, &datetime5, date_format);
worksheet_write_datetime(worksheet, 5, 0, &datetime6, date_format);
worksheet_write_datetime(worksheet, 6, 0, &datetime7, date_format);
worksheet_write_number(worksheet, 0, 1, 10, NULL);
worksheet_write_number(worksheet, 1, 1, 20, NULL);
worksheet_write_number(worksheet, 2, 1, 30, NULL);
worksheet_write_number(worksheet, 3, 1, 10, NULL);
worksheet_write_number(worksheet, 4, 1, 30, NULL);
worksheet_write_number(worksheet, 5, 1, 10, NULL);
worksheet_write_number(worksheet, 6, 1, 20, NULL);
/* Create a chart object. */
lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN);
/* Add a chart series. */
chart_add_series(chart, "=Sheet1!$A$1:$A$7", "=Sheet1!$B$1:$B$7");
/* Rotate the axis data text to make it easier to read. */
lxw_chart_font font = {.rotation = -30};
chart_axis_set_num_font(chart->x_axis, &font);
/* Insert the chart into the worksheet. */
worksheet_insert_chart(worksheet, CELL("D2"), chart);
return workbook_close(workbook);
} |
Add functionality like Python XlsxWriter Data Axes.
See http://xlsxwriter.readthedocs.io/working_with_charts.html#date-category-axes
Add +1 as a comment to vote for this feature and to get an update when it is implemented.
The text was updated successfully, but these errors were encountered: