Closed deerpasta closed 1 year ago
I try to set line chart with date_axis,but did' work
It should work. Here is an example:
from datetime import date
from xlsxwriter import Workbook
workbook = Workbook("test_chart.xlsx")
worksheet = workbook.add_worksheet()
chart = workbook.add_chart({"type": "line"})
date_format = workbook.add_format({"num_format": 14})
worksheet.set_column("A:A", 12)
dates = [
date(2023, 1, 1),
date(2023, 1, 2),
date(2023, 1, 3),
date(2023, 1, 4),
date(2023, 1, 5),
date(2023, 1, 6),
date(2023, 1, 7),
date(2023, 1, 8),
date(2023, 1, 9),
date(2023, 1, 10),
]
values = [10, 30, 20, 40, 20, 60, 50, 40, 30, 30]
worksheet.write_column("A1", dates, date_format)
worksheet.write_column("B1", values)
chart.add_series(
{
"categories": "=Sheet1!$A$1:$A$10",
"values": "=Sheet1!$B$1:$B$10",
}
)
chart.set_x_axis(
{
"date_axis": True,
}
)
worksheet.insert_chart("D1", chart)
workbook.close()
Output:
I found text_axis in the x_axis folder, but there is no date_axis Is this a bug?
No. It is just that the editor isn't showing it. VS Code (and other editors) aren't always 100% accurate when they display Python code internals like this, since some parts of the code need to be interpreted.
Is this a bug, or did I make a mistake somewhere
I don't think it is a bug. If you do then you can submit a bug report with a complete sample application that shows the problem.
Closing.
Question
Hi
I try to set line chart with date_axis,but did' work So I'm trying to identify where the bug I found text_axis in the x_axis folder, but there is no date_axis Is this a bug? Thank you for looking into this. This isn't my major subject, so I might be a bit slow on understanding Is this a bug, or did I make a mistake somewhere