New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
examples/ including datetime in axis 'max' and 'min' #73
Comments
The Here is a workaround using an internal function to convert the dates: from datetime import date
import xlsxwriter
workbook = xlsxwriter.Workbook('chart.xlsx')
date_format = workbook.add_format({'num_format': 'yyyy-mm-dd'})
worksheet = workbook.add_worksheet()
chart = workbook.add_chart({'type': 'scatter', 'subtype': 'straight'})
dates = [date(2013, 11, 1),
date(2013, 11, 2),
date(2013, 11, 3),
date(2013, 11, 4),
date(2013, 11, 5),
date(2013, 11, 6),
date(2013, 11, 7),
date(2013, 11, 8),
date(2013, 11, 9)]
values = [6, 9, 5, 12, 5, 4, 6, 10, 9]
worksheet.set_column('A:A', 12);
worksheet.write_column('A1', dates, date_format)
worksheet.write_column('B1', values)
chart.add_series({
'categories': '=Sheet1!$A$1:$A$9',
'values': '=Sheet1!$B$1:$B$9',
})
chart.set_x_axis({
'min': worksheet._convert_date_time(date(2013, 11, 2)),
'max': worksheet._convert_date_time(date(2013, 11, 8)),
'num_font': {'rotation': -45}
})
worksheet.insert_chart('E9', chart)
workbook.close() Note, Chart Value and Category Axes
|
although your test program worked fine, the same code interpolated into my sorry to beg debug but can you point out the error? ./mkxls.py < testdata.csv test test.xlsx 2 should make the .xlsx I have appended. the text slant function has worked, -G |
Only |
I've been able to see the limit manually on these charts fine. Hmmm. Confused! |
What type of charts are you creating using XlsxWriter? |
I sent you an example dataset, .py and .xls file. Sorry, noe in handheld and disconnected from my source code. I think its a |
I didn't see those. GitHub strips off attachments if you reply via email. :-(
Line charts in Excel don't support max and min on the primary category axis. See, for example, the following discussion on StackExchange. |
Cool. So I was wrong. It is possible. Note, if you click the Text option at the top the min and max go away, which is the case that XlsxWriter is defaulting to. The good news is that support for the "date" case is already in the module so it is just a matter of re-wiring it. I'll push a fix in the next few days. Thanks for the input. |
Support for Date Axes (and max and min values) has been added to version 0.5.2 of XlsxWriter now on PyPI. See this example program. |
And P.S., thanks for pointing this out. |
works like a charm. many thanks!! On Wed, Jan 1, 2014 at 3:02 AM, John McNamara notifications@github.comwrote:
|
Could you write a short example/ .py which shows using 'max' and 'min' with date in charts? I have been trying to get this to work. simple numerical values in y axis seem to work fine btw.
The text was updated successfully, but these errors were encountered: