[GH-ISSUE #36] Feature request: workbook_add_chart() #31

Closed
opened 2026-05-05 11:26:40 -06:00 by gitea-mirror · 12 comments
Owner

Originally created by @jmcnamara on GitHub (Dec 10, 2015).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/36

Originally assigned to: @jmcnamara on GitHub.

Add workbook_add_chart() function like the Python XlsxWriter Workbook method add_chart().
See https://xlsxwriter.readthedocs.org/index.html

  • Difficulty: 5 (Easy 1 - 5 Hard)
  • Priority: 1 (High 1 - 5 Low)

Add +1 as a comment to vote for this feature and to get an update when it is implemented.

Originally created by @jmcnamara on GitHub (Dec 10, 2015). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/36 Originally assigned to: @jmcnamara on GitHub. Add `workbook_add_chart()` function like the Python XlsxWriter Workbook method `add_chart()`. See https://xlsxwriter.readthedocs.org/index.html - Difficulty: 5 (Easy 1 - 5 Hard) - Priority: 1 (High 1 - 5 Low) Add +1 as a comment to vote for this feature and to get an update when it is implemented.
gitea-mirror 2026-05-05 11:26:40 -06:00
Author
Owner

@mts749 commented on GitHub (Dec 10, 2015):

+1

<!-- gh-comment-id:163752995 --> @mts749 commented on GitHub (Dec 10, 2015): +1
Author
Owner

@nelson2005 commented on GitHub (Dec 10, 2015):

+1

<!-- gh-comment-id:163757357 --> @nelson2005 commented on GitHub (Dec 10, 2015): +1
Author
Owner

@jmcnamara commented on GitHub (Jan 3, 2016):

Note, the Phase 1 features are now complete. Since there seems to be more interest in charts than in other features I've move this to the next in line feature.

It will take several months. I'll post updates as soon as there is some working code.

<!-- gh-comment-id:168534231 --> @jmcnamara commented on GitHub (Jan 3, 2016): Note, the Phase 1 features are now complete. Since there seems to be more interest in charts than in other features I've move this to the next in line feature. It will take several months. I'll post updates as soon as there is some working code.
Author
Owner

@mts749 commented on GitHub (Jan 3, 2016):

Great!! Many thanks. If I can help in any way please let me know.

<!-- gh-comment-id:168534907 --> @mts749 commented on GitHub (Jan 3, 2016): Great!! Many thanks. If I can help in any way please let me know.
Author
Owner

@slugdev commented on GitHub (Mar 22, 2016):

+1

<!-- gh-comment-id:200005219 --> @slugdev commented on GitHub (Mar 22, 2016): +1
Author
Owner

@jmcnamara commented on GitHub (May 2, 2016):

Just a note that I have started the chart implementation. It is on a development branch called charts but it is not ready for general consumption yet.

Nevertheless, I wanted to share the first working example:

#include "xlsxwriter.h"

int main() {

    lxw_workbook  *workbook  = new_workbook("chart_bar.xlsx");
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
    int row, col;

    /* Some data for the chart. */
    uint8_t data[5][3] = {
        {1, 2,  3},
        {2, 4,  6},
        {3, 6,  9},
        {4, 8,  12},
        {5, 10, 15}
    };

    /* Write the data to the worksheet. */
    for (row = 0; row < 5; row++)
        for (col = 0; col < 3; col++)
            worksheet_write_number(worksheet, row, col, data[row][col] , NULL);


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

    /* Add two series to the chart. */
    chart_add_series(chart, NULL, "Sheet1!$A$1:$A$5");
    chart_add_series(chart, NULL, "Sheet1!$B$1:$B$5");

    /* Position the chart in the worksheet. */
    worksheet_insert_chart(worksheet, CELL("B7"), chart);

    return workbook_close(workbook);
}

Which gives this output:

screen shot 2016-05-03 at 00 17 20

I'll post an update when there is something usable for testing.

<!-- gh-comment-id:216396462 --> @jmcnamara commented on GitHub (May 2, 2016): Just a note that I have started the chart implementation. It is on a development branch called charts but it is **not** ready for general consumption yet. Nevertheless, I wanted to share the first working example: ``` C #include "xlsxwriter.h" int main() { lxw_workbook *workbook = new_workbook("chart_bar.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); int row, col; /* Some data for the chart. */ uint8_t data[5][3] = { {1, 2, 3}, {2, 4, 6}, {3, 6, 9}, {4, 8, 12}, {5, 10, 15} }; /* Write the data to the worksheet. */ for (row = 0; row < 5; row++) for (col = 0; col < 3; col++) worksheet_write_number(worksheet, row, col, data[row][col] , NULL); /* Create a chart object. */ lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_BAR); /* Add two series to the chart. */ chart_add_series(chart, NULL, "Sheet1!$A$1:$A$5"); chart_add_series(chart, NULL, "Sheet1!$B$1:$B$5"); /* Position the chart in the worksheet. */ worksheet_insert_chart(worksheet, CELL("B7"), chart); return workbook_close(workbook); } ``` Which gives this output: ![screen shot 2016-05-03 at 00 17 20](https://cloud.githubusercontent.com/assets/94267/14971097/dc4d2ad8-10c6-11e6-98c7-a51ff5fa37f7.png) I'll post an update when there is something usable for testing.
Author
Owner

@nelson2005 commented on GitHub (May 4, 2016):

Sweet!  It's great to see this progress on the charting!

<!-- gh-comment-id:216895738 --> @nelson2005 commented on GitHub (May 4, 2016): Sweet!  It's great to see this progress on the charting!
Author
Owner

@jmcnamara commented on GitHub (May 23, 2016):

The chart work is stable now and I have moved it to the master branch in preparation for a release in the next few days.

This took a bit of work:

$ git diff master --stat
...
235 files changed, 10238 insertions(+), 583 deletions(-)

I've updated the documentation see: chart.h and the chart example.

The documentation still needs some additional work before the release but the code is well tested and useable.

Note, not all of the chart features in the Perl/Python versions are available yet. That will take some time and I will open other issues trackers to track the progress of those.

I would be good if you could try the current version on master and let me know what you think.

<!-- gh-comment-id:220865044 --> @jmcnamara commented on GitHub (May 23, 2016): The chart work is stable now and I have moved it to the master branch in preparation for a release in the next few days. This took a bit of work: ``` $ git diff master --stat ... 235 files changed, 10238 insertions(+), 583 deletions(-) ``` I've updated the documentation see: [chart.h](http://libxlsxwriter.github.io/chart_8h.html) and the [chart example](http://libxlsxwriter.github.io/examples.html). The documentation still needs some additional work before the release but the code is well tested and useable. Note, not all of the chart features in the Perl/Python versions are available yet. That will take some time and I will open other issues trackers to track the progress of those. I would be good if you could try the current version on master and let me know what you think.
Author
Owner

@nelson2005 commented on GitHub (May 23, 2016):

Wow, you've been busy!  This is such a cool project.  Great work, I imagine it must be a little tedious for you, having done similar work a number of times before in Python/Perl/Lua
My main interest is the Lua end of things.  Have  you run into anyone else who has an interest in a Lua binding for libxlsxwriter?
Erik

<!-- gh-comment-id:220866725 --> @nelson2005 commented on GitHub (May 23, 2016): Wow, you've been busy!  This is such a cool project.  Great work, I imagine it must be a little tedious for you, having done similar work a number of times before in Python/Perl/Lua My main interest is the Lua end of things.  Have  you run into anyone else who has an interest in a Lua binding for libxlsxwriter? Erik
Author
Owner

@jmcnamara commented on GitHub (May 24, 2016):

@nelson2005 I'll open up a new Feature Request issue for Lua bindings to let people know. There are a couple of people who were active on the pure Lua port who might be interested in helping out. I'm not. :-)

<!-- gh-comment-id:221187440 --> @jmcnamara commented on GitHub (May 24, 2016): @nelson2005 I'll open up a new Feature Request issue for Lua bindings to let people know. There are a couple of people who were active on the pure Lua port who might be interested in helping out. I'm not. :-)
Author
Owner

@jmcnamara commented on GitHub (May 24, 2016):

The chart feature has been merged to master and released. I'll close this issue shortly when I open up some others to track the missing features.

<!-- gh-comment-id:221187629 --> @jmcnamara commented on GitHub (May 24, 2016): The chart feature has been merged to master and released. I'll close this issue shortly when I open up some others to track the missing features.
Author
Owner

@jmcnamara commented on GitHub (Jun 13, 2016):

See #51 for additional chart features. Closing this since the basic chart functionality has been added.

<!-- gh-comment-id:225728316 --> @jmcnamara commented on GitHub (Jun 13, 2016): See #51 for additional chart features. Closing this since the basic chart functionality has been added.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#31
No description provided.