[GH-ISSUE #204] Series name is ignored for chart type LXW_CHART_SCATTER #168

Closed
opened 2026-05-05 11:49:31 -06:00 by gitea-mirror · 7 comments
Owner

Originally created by @saedelman on GitHub (Nov 9, 2018).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/204

Originally assigned to: @jmcnamara on GitHub.

The chart_series_set_name() call does nothing when the chart type is set to LXW_CHART_SCATTER or LXW_CHART_SCATTER_SMOOTH. Excel shows "Series 1", "Series 2", etc. instead of the defined name.

Looking at chart.c, the function call _chart_write_xcal_ser(...) does not call _chart_write_series_name(...). Once this is added (after _chart_write_order(..)), Excel properly reflects the name identified by the chart_series_set_name() user call.

Originally created by @saedelman on GitHub (Nov 9, 2018). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/204 Originally assigned to: @jmcnamara on GitHub. The chart_series_set_name() call does nothing when the chart type is set to LXW_CHART_SCATTER or LXW_CHART_SCATTER_SMOOTH. Excel shows "Series 1", "Series 2", etc. instead of the defined name. Looking at chart.c, the function call _chart_write_xcal_ser(...) does not call _chart_write_series_name(...). Once this is added (after _chart_write_order(..)), Excel properly reflects the name identified by the chart_series_set_name() user call.
gitea-mirror 2026-05-05 11:49:31 -06:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@jmcnamara commented on GitHub (Nov 9, 2018):

Thanks.

Can you add a small, compile-able example that demonstrates the issue.

John

<!-- gh-comment-id:437382470 --> @jmcnamara commented on GitHub (Nov 9, 2018): Thanks. Can you add a small, compile-able example that demonstrates the issue. John
Author
Owner

@saedelman commented on GitHub (Nov 9, 2018):

Sure, but just compare the _chart_write_xval_ser(...) and _chart_write_ser(...) functions, the latter function is called for everything other than scatter graphs and the _chart_write_series_name(..) is included there. It should be immediately obvious that it is missing from _chart_write_xval_ser(..) call.

<!-- gh-comment-id:437384494 --> @saedelman commented on GitHub (Nov 9, 2018): Sure, but just compare the _chart_write_xval_ser(...) and _chart_write_ser(...) functions, the latter function is called for everything other than scatter graphs and the _chart_write_series_name(..) is included there. It should be immediately obvious that it is missing from _chart_write_xval_ser(..) call.
Author
Owner

@jmcnamara commented on GitHub (Nov 9, 2018):

It should be immediately obvious that it is missing from _chart_write_xval_ser(..) call.

Maybe or maybe not. I prefer to start with a sample program to make sure everyone is on the same page.

For example I created this test case:


#include "xlsxwriter.h"

int main() {

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

    uint8_t data[5][3] = {
        {1, 2,  3},
        {2, 4,  6},
        {3, 6,  9},
        {4, 8,  12},
        {5, 10, 15}
    };

    int row, col;
    for (row = 0; row < 5; row++)
        for (col = 0; col < 3; col++)
            worksheet_write_number(worksheet, row, col, data[row][col], NULL);

    lxw_chart_series *series1 = chart_add_series(chart,
         "=Sheet1!$A$1:$A$5",
         "=Sheet1!$B$1:$B$5"
    );

    lxw_chart_series *series2 = chart_add_series(chart,
         "=Sheet1!$A$1:$A$5",
         "=Sheet1!$C$1:$C$5"
    );

    chart_series_set_name(series1, "Apple");
    chart_series_set_name(series2, "Pear");
    
    worksheet_insert_chart(worksheet, CELL("D4"), chart);

    return workbook_close(workbook);
}

Which creates this output:

aa_image

|

Which looks okay. Is this the type of scenario that you are talking about?

<!-- gh-comment-id:437395192 --> @jmcnamara commented on GitHub (Nov 9, 2018): > It should be immediately obvious that it is missing from _chart_write_xval_ser(..) call. Maybe or maybe not. I prefer to start with a sample program to make sure everyone is on the same page. For example I created this test case: ```C #include "xlsxwriter.h" int main() { lxw_workbook *workbook = new_workbook("test_chart_scatter.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_SCATTER); uint8_t data[5][3] = { {1, 2, 3}, {2, 4, 6}, {3, 6, 9}, {4, 8, 12}, {5, 10, 15} }; int row, col; for (row = 0; row < 5; row++) for (col = 0; col < 3; col++) worksheet_write_number(worksheet, row, col, data[row][col], NULL); lxw_chart_series *series1 = chart_add_series(chart, "=Sheet1!$A$1:$A$5", "=Sheet1!$B$1:$B$5" ); lxw_chart_series *series2 = chart_add_series(chart, "=Sheet1!$A$1:$A$5", "=Sheet1!$C$1:$C$5" ); chart_series_set_name(series1, "Apple"); chart_series_set_name(series2, "Pear"); worksheet_insert_chart(worksheet, CELL("D4"), chart); return workbook_close(workbook); } ``` Which creates this output: ![aa_image](https://user-images.githubusercontent.com/94267/48271514-6a70a680-e434-11e8-989f-53d08bdb2210.png) | Which looks okay. Is this the type of scenario that you are talking about?
Author
Owner

@saedelman commented on GitHub (Nov 9, 2018):

It looks like I may have an older library. My output shows "Series 1" for "Apple" and "Series 2" for Pear.

<!-- gh-comment-id:437398545 --> @saedelman commented on GitHub (Nov 9, 2018): It looks like I may have an older library. My output shows "Series 1" for "Apple" and "Series 2" for Pear.
Author
Owner

@jmcnamara commented on GitHub (Nov 9, 2018):

Ok to close then?

<!-- gh-comment-id:437403945 --> @jmcnamara commented on GitHub (Nov 9, 2018): Ok to close then?
Author
Owner

@saedelman commented on GitHub (Nov 9, 2018):

Let me try it with the latest library for good measure and report back.

<!-- gh-comment-id:437407913 --> @saedelman commented on GitHub (Nov 9, 2018): Let me try it with the latest library for good measure and report back.
Author
Owner

@jmcnamara commented on GitHub (Nov 15, 2018):

Closing. If you isolate an issue you can open another issue with an example.

<!-- gh-comment-id:439029637 --> @jmcnamara commented on GitHub (Nov 15, 2018): Closing. If you isolate an issue you can open another issue with an example.
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#168
No description provided.