mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 06:06:09 -06:00
[GH-ISSUE #505] Feature Request: Sparklines #393
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#393
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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);}@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.