charts.css.py brings charts.css to Python.
Project description
charts.css.py
As implied by its name, charts.css.py
brings charts.css
to Python.
Charts.css is a pure-CSS data visualization framework. It offers advantages over traditional JS-heavy chart libraries.
charts.css.py
provides a pythonic API on top of charts.css
,
so that you can largely avoid working directly at HTML and CSS level.
Installation
pip install charts.css.py
Usage
charts.css.py
process data by converting your 2-dimension number list into an HTML table, which is properly styled with CSS classes.
Then you write such a string into your HTML page, together with
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/charts.css/dist/charts.min.css">
,
the visual representation will be rendered by browser.
For example, the following code snippet can convert a 2-dimension list into bar chart:
from charts.css import bar, STYLESHEET
chart = bar(
[
["Continent", "1st year", "2nd year", "3rd year", "4th year", "5th year"],
["Asia", 20.0, 30.0, 40.0, 50.0, 75.0],
["Euro", 40.0, 60.0, 75.0, 90.0, 100.0],
],
headers_in_first_row=True,
headers_in_first_column=True,
)
open("output.html", "w").write(STYLESHEET + chart)
The output.html will be rendered in browser like this:
Advanced Usage
There are currently 4 different charts implemented: bar
, column
, line
, area
.
All those methods support these parameters
to further customize the chart appearance.
bar()
and column()
also support two extra parameters:
stacked: boolean
and percentage: boolean
.
There is another experimental helper wrapper(...)
which can be used to:
- customize the display position of legend (you would need to use your HTML and CSS skill for this)
- potentially mixed multiple charts and overlay them together.
Please read the unit test for more examples.
Lastly, this package also provides a command-line tool csv2chart
.
You can use it to convert csv file into an html file.
For example, csv2chart sample.csv output.html
.
You can also run csv2chart -h
to know all the parameters it supports.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for charts.css.py-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 503abe1e9e7b0deb81c5589ab71686f4dd539eefd2c42c4848b2f09f313c1bf8 |
|
MD5 | ea283ef60d937e8a86851dd29b2e0d5f |
|
BLAKE2b-256 | 0eea82dc8a0b2a01aa527745711c4128ade517304669d77266c7abf47d7648d7 |