[GH-ISSUE #503] Feature request: Stock Charts #388

Open
opened 2026-05-05 12:14:27 -06:00 by gitea-mirror · 2 comments
Owner

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

Originally assigned to: @jmcnamara on GitHub.

Support for stock chart types that display High-Low-Close or Open-High-Low-Close financial data, suitable for visualizing stock prices and other data showing variation over time.

API Changes:

New enum value in lxw_chart_type:
LXW_CHART_STOCK

Code Example:
#include "xlsxwriter.h"

int main() {
lxw_workbook *workbook = workbook_new("stock.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_STOCK);

/* add High-Low-Close series (3 series required for stock charts) */
chart_add_series(chart, "=Sheet1!$A$2:$A$6", "=Sheet1!$B$2:$B$6", 0); /* High */
chart_add_series(chart, "=Sheet1!$A$2:$A$6", "=Sheet1!$C$2:$C$6", 0); /* Low */
chart_add_series(chart, "=Sheet1!$A$2:$A$6", "=Sheet1!$D$2:$D$6", 0); /* Close */

worksheet_insert_chart(worksheet, CELL("E2"), chart);
return workbook_close(workbook);
}

Image
Originally created by @kruftindustries on GitHub (Jan 12, 2026). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/503 Originally assigned to: @jmcnamara on GitHub. ### Support for stock chart types that display High-Low-Close or Open-High-Low-Close financial data, suitable for visualizing stock prices and other data showing variation over time. API Changes: New enum value in `lxw_chart_type:` `LXW_CHART_STOCK` Code Example: `#include "xlsxwriter.h"` `int main() {` ` lxw_workbook *workbook = workbook_new("stock.xlsx");` ` lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);` ` lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_STOCK);` ` /* add High-Low-Close series (3 series required for stock charts) */` ` chart_add_series(chart, "=Sheet1!$A$2:$A$6", "=Sheet1!$B$2:$B$6", 0); /* High */` ` chart_add_series(chart, "=Sheet1!$A$2:$A$6", "=Sheet1!$C$2:$C$6", 0); /* Low */` ` chart_add_series(chart, "=Sheet1!$A$2:$A$6", "=Sheet1!$D$2:$D$6", 0); /* Close */` ` worksheet_insert_chart(worksheet, CELL("E2"), chart);` ` return workbook_close(workbook);` `}` <img width="480" height="288" alt="Image" src="https://github.com/user-attachments/assets/aa3d0c0c-4723-475f-a723-c93fda23a27b" />
gitea-mirror added the
feature request
medium term
labels 2026-05-05 12:14:27 -06:00
Author
Owner

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

You are sort of spamming me by opening five feature requests in a row but anyway I'll answer as best as I can.

This is low priority. Stock charts are just a combination of different series with high-low bars. They can be constructed with the following steps:

  • Add 3 series for High, Low and Close, in that order.
  • Hide the default lines in all 3 series.
  • Hide the default markers for the High and Low series.
  • Set a dash marker for the Close series.
  • Turn on the chart High-Low bars.

This is basically what Excel does internally. It adds a "stock" type but that doesn't make a big difference.

<!-- gh-comment-id:3737757811 --> @jmcnamara commented on GitHub (Jan 12, 2026): You are sort of spamming me by opening five feature requests in a row but anyway I'll answer as best as I can. This is low priority. Stock charts are just a combination of different series with high-low bars. They can be constructed with the following steps: - Add 3 series for High, Low and Close, in that order. - Hide the default lines in all 3 series. - Hide the default markers for the High and Low series. - Set a dash marker for the Close series. - Turn on the chart High-Low bars. This is basically what Excel does internally. It adds a "stock" type but that doesn't make a big difference.
Author
Owner

@kruftindustries commented on GitHub (Jan 13, 2026):

Ready for review

<!-- gh-comment-id:3742256420 --> @kruftindustries commented on GitHub (Jan 13, 2026): Ready for review
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#388
No description provided.