♚ \

Author: Jiandong Chen is a columnist for the Python Chinese community and a core developer of the open source project Pyecharts. The Pyecharts project was featured on Github Trending in Open Source and currently has over 7100 stars. GitHub:github.com/chenjiandon…

The project address

Github.com/chenjiandon…

* * * *

While wandering around Github, I found an interesting chart library, Chart.xkcd, which has lovely hand-drawn charts. So there was an idea to combine Chart.xkcd with Python, which eventually became the Cutecharts you see today.

Chart.xkcd has far fewer chart types than Echarts and supports only a few basic charts without many configuration items. Pyecharts may be a better choice if you want to use richer charts. My personal idea for Cutecharts is as a project to learn how to combine Javascript with Python/Notebook. There’s no denying that the JS library has a natural advantage in interactivity and animation, and combining that advantage with the Notebook environment can lead to a lot of interesting projects.

The cutecharts project structure is basically the same as Pyecharts and has all the core functions of Pyecharts. But the whole thing is smaller and the code is more streamlined. If you read through the Cutecharts code and then look at the Pyecharts code, you’ll probably find that there’s really nothing mysterious about it. Hopefully the Python community will have more excellent third-party libraries that combine JS with Python/Notebook. Cutecharts are much more valuable to learn than to use.

Install the * * * *

PIP install

$ pip(3) install cutecharts
Copy the code

The source code to install

$ git clone https://github.com/chenjiandongx/cutecharts.git
$ cd cutecharts
$ pip install -r requirements.txt
$ python setup.py install
Copy the code

Use * * * *

  • Chart documentation: docs/charts.md
  • Component documentation: docs/components.md
  • Version log: docs/ Changelog.md

Local Environment ****

Generate HTML * * * *

from cutecharts.charts import Line


chart = Line("Sales at a department store")
chart.set_options(
    labels=["Shirt"."Sweater"."Tie"."Pants"."Trench coat"."High heels"."Socks"], 
    x_label="I'm xlabel", 
    y_label="I'm ylabel",
)
chart.add_series("series-A"[57.134.137.129.145.60.49])
chart.add_series("series-B"[114.55.27.101.125.27.105])
chart.render()
Copy the code

The render method generates a render. HTML file locally and opens it in a browser.

Notebook environment

Jupyter Notebook

JupyterLab

Use of JupyterLab requires caution

1.Introduce a declaration at the topfrom cutecharts.globals import use_jupyter_lab; use_jupyter_lab()

# 2.The diagram is called the first time it is used in Notebook`load_javascript`Only once. chart.load_javascript()Copy the code

Demo****

The Demo code is located in the Example folder

Code quality ****

Unit testing

Copy the code

Integration testing

Use Travis CI and AppVeyor continuous integration environments.

Code specification

Use Flake8, Codecov, and PyLint to improve code quality.

License****

MIT © chenjiandongx

Copy the code