[GH-ISSUE #505] Feature Request: Sparklines #393

Open
opened 2026-05-05 12:14:33 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @kruftindustries on GitHub (Jan 12, 2026).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/505

Originally assigned to: @jmcnamara on GitHub.

API Changes:

New header file: sparkline.h

New enums:
typedef enum lxw_sparkline_type {
LXW_SPARKLINE_LINE, /* Line sparkline (default) */
LXW_SPARKLINE_COLUMN, /* Column sparkline */
LXW_SPARKLINE_WIN_LOSS /* Win/Loss sparkline */
} lxw_sparkline_type;

typedef enum lxw_sparkline_empty_cells {
LXW_SPARKLINE_EMPTY_CELLS_GAPS, /* Show gaps */
LXW_SPARKLINE_EMPTY_CELLS_ZERO, /* Treat as zero */
LXW_SPARKLINE_EMPTY_CELLS_CONNECT /* Connect points */
} lxw_sparkline_empty_cells;

typedef enum lxw_sparkline_axis_type {
LXW_SPARKLINE_AXIS_INDIVIDUAL, /* Individual axis per sparkline */
LXW_SPARKLINE_AXIS_GROUP, /* Same axis for group */
LXW_SPARKLINE_AXIS_CUSTOM /* Custom axis value */
} lxw_sparkline_axis_type;

New struct:
typedef struct lxw_sparkline_options {
const char *range; /* Data range (e.g., "Sheet1!A1:E1") */
const char *location; /* Cell location (optional) */
lxw_sparkline_type type; /* Sparkline type */
uint8_t style; /* Style index (0-35) */
uint8_t markers; /* Show markers */
lxw_color_t series_color; /* Series color */
uint8_t negative_points; /* Highlight negative */
uint8_t high_point; /* Highlight high point */
uint8_t low_point; /* Highlight low point */
uint8_t first_point; /* Highlight first point */
uint8_t last_point; /* Highlight last point */
lxw_color_t markers_color; /* Marker color */
double min; /* Min axis value */
double max; /* Max axis value */
double weight; /* Line weight */
/* ... additional options */
} lxw_sparkline_options;

New function:
lxw_error worksheet_add_sparkline(lxw_worksheet *worksheet,
lxw_row_t row, lxw_col_t col,
lxw_sparkline_options *options);

Code Example:

#include "xlsxwriter.h"

int main() {
lxw_workbook *workbook = workbook_new("sparklines.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

/* Write data */
for (int col = 1; col <= 5; col++)
worksheet_write_number(worksheet, 0, col, col * 10, NULL);

/* Add a column sparkline with markers */
lxw_sparkline_options options = {
.range = "Sheet1!B1:F1",
.type = LXW_SPARKLINE_COLUMN,
.high_point = LXW_TRUE,
.low_point = LXW_TRUE,
};
worksheet_add_sparkline(worksheet, 0, 6, &options);

return workbook_close(workbook);
}

Image
Originally created by @kruftindustries on GitHub (Jan 12, 2026). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/505 Originally assigned to: @jmcnamara on GitHub. ### In-cell mini charts that show trends in data at a glance. Supports line, column, and win/loss sparkline types with customizable colors, markers, and high/low point indicators. ### API Changes: **New header file:** sparkline.h **New enums:** `typedef enum lxw_sparkline_type {` ` LXW_SPARKLINE_LINE, /* Line sparkline (default) */` ` LXW_SPARKLINE_COLUMN, /* Column sparkline */` ` LXW_SPARKLINE_WIN_LOSS /* Win/Loss sparkline */` `} lxw_sparkline_type;` `typedef enum lxw_sparkline_empty_cells {` ` LXW_SPARKLINE_EMPTY_CELLS_GAPS, /* Show gaps */` ` LXW_SPARKLINE_EMPTY_CELLS_ZERO, /* Treat as zero */` ` LXW_SPARKLINE_EMPTY_CELLS_CONNECT /* Connect points */` `} lxw_sparkline_empty_cells;` `typedef enum lxw_sparkline_axis_type {` ` LXW_SPARKLINE_AXIS_INDIVIDUAL, /* Individual axis per sparkline */` ` LXW_SPARKLINE_AXIS_GROUP, /* Same axis for group */` ` LXW_SPARKLINE_AXIS_CUSTOM /* Custom axis value */` `} lxw_sparkline_axis_type;` **New struct:** `typedef struct lxw_sparkline_options {` ` const char *range; /* Data range (e.g., "Sheet1!A1:E1") */` ` const char *location; /* Cell location (optional) */` ` lxw_sparkline_type type; /* Sparkline type */` ` uint8_t style; /* Style index (0-35) */` ` uint8_t markers; /* Show markers */` ` lxw_color_t series_color; /* Series color */` ` uint8_t negative_points; /* Highlight negative */` ` uint8_t high_point; /* Highlight high point */` ` uint8_t low_point; /* Highlight low point */` ` uint8_t first_point; /* Highlight first point */` ` uint8_t last_point; /* Highlight last point */` ` lxw_color_t markers_color; /* Marker color */` ` double min; /* Min axis value */` ` double max; /* Max axis value */` ` double weight; /* Line weight */` ` /* ... additional options */` `} lxw_sparkline_options;` **New function:** `lxw_error worksheet_add_sparkline(lxw_worksheet *worksheet,` ` lxw_row_t row, lxw_col_t col,` ` lxw_sparkline_options *options);` ### Code Example: `#include "xlsxwriter.h"` `int main() {` ` lxw_workbook *workbook = workbook_new("sparklines.xlsx");` ` lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);` ` /* Write data */` ` for (int col = 1; col <= 5; col++)` ` worksheet_write_number(worksheet, 0, col, col * 10, NULL);` ` /* Add a column sparkline with markers */` ` lxw_sparkline_options options = {` ` .range = "Sheet1!B1:F1",` ` .type = LXW_SPARKLINE_COLUMN,` ` .high_point = LXW_TRUE,` ` .low_point = LXW_TRUE,` ` };` ` worksheet_add_sparkline(worksheet, 0, 6, &options);` ` return workbook_close(workbook);` `}` <img width="65" height="21" alt="Image" src="https://github.com/user-attachments/assets/4ddbb02c-872f-4af2-9169-5c6247762edc" />
gitea-mirror added the
feature request
long term
labels 2026-05-05 12:14:33 -06:00
Author
Owner

@jmcnamara commented on GitHub (Jan 12, 2026):

I have almost never had any feature requests, bug reports or feedback on sparklines across any of the Python/Perl/Rust variants and as far as I can see this isn't a feature that is used very often by end users. The only example that I can think of is Pandas which uses it as an option in the write_excel() function.

So for me this is very low priority.

<!-- gh-comment-id:3737777948 --> @jmcnamara commented on GitHub (Jan 12, 2026): I have almost never had any feature requests, bug reports or feedback on sparklines across any of the Python/Perl/Rust variants and as far as I can see this isn't a feature that is used very often by end users. The only example that I can think of is Pandas which uses it as an option in the `write_excel()` function. So for me this is very low priority.
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#393
No description provided.