[GH-ISSUE #83] Feature request: Set line width in Charts #67

Closed
opened 2026-05-05 11:36:08 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @Diddlik on GitHub (Dec 20, 2016).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/83

Originally assigned to: @jmcnamara on GitHub.

Is it possible to set a with of the chart line? Default value is 3.25 points and I need variable width of lines...

Originally created by @Diddlik on GitHub (Dec 20, 2016). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/83 Originally assigned to: @jmcnamara on GitHub. Is it possible to set a with of the chart line? Default value is 3.25 points and I need variable width of lines...
gitea-mirror 2026-05-05 11:36:08 -06:00
Author
Owner

@jmcnamara commented on GitHub (Dec 20, 2016):

That isn't currently possible but is is on the TODO list: https://github.com/jmcnamara/libxlsxwriter/issues/51

I'll turn this into a Feature Request as well so that you can track it.

<!-- gh-comment-id:268197418 --> @jmcnamara commented on GitHub (Dec 20, 2016): That isn't currently possible but is is on the TODO list: https://github.com/jmcnamara/libxlsxwriter/issues/51 I'll turn this into a Feature Request as well so that you can track it.
Author
Owner

@jmcnamara commented on GitHub (Dec 31, 2016):

I've added initial support for this to the charts branch. You can now do something like this:

#include "xlsxwriter.h"

int main() {

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

    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"
    );

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

    lxw_chart_line line = {.color     = LXW_COLOR_RED,
                           .width     = 1.25,
                           .dash_type = LXW_CHART_LINE_DASH_SQUARE_DOT};

    chart_series_set_line(series1, &line);

    worksheet_insert_chart(worksheet, CELL("E9"), chart);

    return workbook_close(workbook);
}


I'll merge it up onto master with docs etc sometime in the next week.

<!-- gh-comment-id:269867854 --> @jmcnamara commented on GitHub (Dec 31, 2016): I've added initial support for this to the `charts` branch. You can now do something like this: ```C #include "xlsxwriter.h" int main() { lxw_workbook *workbook = new_workbook("test_chart.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_LINE); 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" ); chart_add_series(chart, "=Sheet1!$A$1:$A$5", "=Sheet1!$C$1:$C$5" ); lxw_chart_line line = {.color = LXW_COLOR_RED, .width = 1.25, .dash_type = LXW_CHART_LINE_DASH_SQUARE_DOT}; chart_series_set_line(series1, &line); worksheet_insert_chart(worksheet, CELL("E9"), chart); return workbook_close(workbook); } ``` I'll merge it up onto master with docs etc sometime in the next week.
Author
Owner

@jmcnamara commented on GitHub (Jan 1, 2017):

Added in 0.4.6. http://libxlsxwriter.github.io/working_with_charts.html#chart_lines

<!-- gh-comment-id:269919726 --> @jmcnamara commented on GitHub (Jan 1, 2017): Added in 0.4.6. http://libxlsxwriter.github.io/working_with_charts.html#chart_lines
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#67
No description provided.