Feature request: Set line width in Charts #83

Closed
Diddlik opened this Issue Dec 20, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@Diddlik

Diddlik commented Dec 20, 2016

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

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Dec 20, 2016

Owner

That isn't currently possible but is is on the TODO list: #51

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

Owner

jmcnamara commented Dec 20, 2016

That isn't currently possible but is is on the TODO list: #51

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

@jmcnamara jmcnamara changed the title from Set line width in Line-Charts to Feature request: Set line width in Charts Dec 20, 2016

@jmcnamara jmcnamara self-assigned this Dec 20, 2016

@jmcnamara

This comment has been minimized.

Show comment
Hide comment
@jmcnamara

jmcnamara Dec 31, 2016

Owner

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.

Owner

jmcnamara commented 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.

@jmcnamara

This comment has been minimized.

Show comment
Hide comment

@jmcnamara jmcnamara closed this Jan 1, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment