Comments (7)
Currently only Bar charts are supported. Here is an example:
from xlsxwriter.workbook import Workbook
workbook = Workbook('chart_bar01.xlsx')
worksheet = workbook.add_worksheet()
chart = workbook.add_chart({'type': 'bar', 'embedded': True})
data = [
[1, 2, 3, 4, 5],
[2, 4, 6, 8, 10],
[3, 6, 9, 12, 15],
]
worksheet.write_column('A1', data[0])
worksheet.write_column('B1', data[1])
worksheet.write_column('C1', data[2])
chart.add_series({'categories': '=Sheet1!$A$1:$A$5',
'values': '=Sheet1!$B$1:$B$5'})
chart.add_series({'categories': '=Sheet1!$A$1:$A$5',
'values': '=Sheet1!$C$1:$C$5})
worksheet.insert_chart('E9', chart)
workbook.close()
The output looks like this:
Formatting and other chart types are in progress. This thread will be updated as they become available.
See the following for a full list of feature that are available in Excel::Writer::XLSX charts that will be added to XlsxWriter.
from xlsxwriter.
Nice example. I am interested in stacked column charts. Is it planned to add this feature in the near future ?
from xlsxwriter.
Yes, column charts will be added next (1-2 days) and they will come with stacked
and percent_stacked
variants.
For example the above code could be modified with either of the following subtypes:
chart = workbook.add_chart({'type': 'bar',
'subtype': 'stacked',
'embedded': True})
...
chart = workbook.add_chart({'type': 'bar',
'subtype': 'percent_stacked',
'embedded': True})
Note, the embedded
option may be dropped in the final API since it is implicit (non-embedded chart sheets will use a different add_ method).
from xlsxwriter.
This is the full list of chart types and sub-types that will be supported:
- area
- stacked
- percent_stacked
- bar
- stacked
- percent_stacked
- column
- stacked
- percent_stacked
- scatter
- straight_with_markers
- straight
- smooth_with_markers
- smooth
- line (with and without markers)
- stock
- radar
- with_markers
- filled
from xlsxwriter.
Column and Line charts have been added. Here is an example of a stacked column chart:
from xlsxwriter.workbook import Workbook
workbook = Workbook('chart_column02.xlsx')
worksheet = workbook.add_worksheet()
chart = workbook.add_chart({'type': 'column', 'subtype': 'stacked'})
data = [
[1, 2, 3, 4, 5],
[2, 4, 6, 8, 10],
[3, 6, 9, 12, 15],
]
worksheet.write_column('A1', data[0])
worksheet.write_column('B1', data[1])
worksheet.write_column('C1', data[2])
chart.add_series({'categories': '=Sheet1!$A$1:$A$5',
'values': '=Sheet1!$B$1:$B$5'})
chart.add_series({'categories': '=Sheet1!$A$1:$A$5',
'values': '=Sheet1!$C$1:$C$5'})
worksheet.insert_chart('E9', chart)
workbook.close()
from xlsxwriter.
All chart types and subtypes have been added. Now working on chart formatting and features.
37/161 integration tests complete.
from xlsxwriter.
Charts are now available in the master branch and in PyPI version 0.3.1.
from xlsxwriter.
Related Issues (20)
- Feature Request: Support leader lines for more chart types. HOT 3
- Bug: Strange problem with calculation using xl_rowcol_to_cell HOT 2
- feature request: Add circle shape to XlsxWriter HOT 1
- Bug: Inconsistent Calculated Column Formula when applying columns[:].formula using table range references HOT 7
- question: OSS-Fuzz Integration HOT 3
- Docs: Links to Microsoft documentation for Worksheet Tables are broken
- Bug: Using leader_lines leads to corrupted Excel HOT 1
- Bug: Failed compilation of online documentation HOT 4
- Bug: A typo in the "working with memory" documentation - more of less HOT 1
- feature request: custom `default_col_width` [HAS PATCH] HOT 4
- Is there a way to enbale multi-select dropdown? HOT 3
- feature request: argument type check for Worksheet.insert_image() HOT 3
- XlsxWriter Roadmap v2 HOT 5
- High memory usage by workbook when row to be written increases HOT 9
- EOL (End of Life) for PDF version of the documentation HOT 1
- Bug: When generating a xlsx, invalid file created with unrecoverable errors HOT 10
- How do I preserve formatting when writing a dataframme to an XLS file HOT 3
- How is append mode supposed to work when the target doesn't exist? HOT 4
- Bug: Ignoring multiple, different errors over same column range HOT 6
- worksheet.autofit() not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xlsxwriter.