# pyecharts **Repository Path**: pythonista/pyecharts ## Basic Information - **Project Name**: pyecharts - **Description**: Python Echarts Plotting Library - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-05-21 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
pyecharts is a library to generate charts using Echarts. It simply provides the interface of 28+ kinds of charts between Echarts and Python.
## Introduction [Echarts](https://github.com/ecomfe/echarts) is an open source library from Baidu for data visualization in javascript. It has awesome demo pages so I started to look out for an interface library so that I could use it in Python. I ended up with [echarts-python](https://github.com/yufeiminds/echarts-python) on github but it lacks of documentation and was not updated for a while. Just like many other Python projects, I started my own project, pyecharts, referencing echarts-python and another library [pygal](https://github.com/Kozea/pygal). ## Installation ### Python Compatibility pyecharts works on Python2.7 and Python3.4+. pyecharts handles all strings and files with unicode encoding and you **MUST** use unicode string on Python 2. ```python #coding=utf-8 from __future__ import unicode_literals ``` ### pyecharts You can install it via pip ```shell $ pip install pyecharts ``` or clone it and install it ```shell $ git clone https://github.com/pyecharts/pyecharts.git $ cd pyecharts $ pip install -r requirements.txt $ python setup.py install ``` Please note: since version 0.3.2, **NO LONGER** pyecharts comes with any map files. Please read next section for more informations. ### Map extensions Here is a list of map extensions from pyecharts dev team: 1. [World countries include China map and World map](https://echarts-maps.github.io/echarts-countries-js/): [echarts-countries-pypkg](https://github.com/pyecharts/echarts-countries-pypkg) (1.9MB) 2. [Chinese provinces and regions](https://echarts-maps.github.io/echarts-china-provinces-js/): [echarts-china-provinces-pypkg](https://github.com/pyecharts/echarts-china-provinces-pypkg) (730KB) 3. [Chinese cities](https://echarts-maps.github.io/echarts-china-cities-js/): [echarts-china-cities-pypkg](https://github.com/pyecharts/echarts-china-cities-pypkg) (3.8MB) 4. [Chinese counties](https://echarts-maps.github.io/echarts-china-counties-js/): [echarts-china-counties-pypkg](https://github.com/pyecharts/echarts-china-counties-pypkg) (4.1MB) 5. [Custom Chinese regions](https://echarts-maps.github.io/echarts-china-misc-js/): [echarts-china-misc-pypkg](https://github.com/pyecharts/echarts-china-misc-pypkg) (148KB) 6. [United Kingdom map](https://echarts-maps.github.io/echarts-united-kingdom-js/): [echarts-united-kingdom-pypkg](https://github.com/pyecharts/echarts-united-kingdom-pypkg) (1MB) In order to install them, you can try one or all of them below: ```shell $ pip install echarts-countries-pypkg $ pip install echarts-china-provinces-pypkg $ pip install echarts-china-cities-pypkg $ pip install echarts-china-counties-pypkg $ pip install echarts-china-misc-pypkg $ pip install echarts-united-kingdom-pypkg ``` ## Basic Usage ### Render to Local Html File ```python from pyecharts import Bar attr = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] v1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3] v2 = [2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3] bar = Bar("Bar chart", "precipitation and evaporation one year") bar.add("precipitation", attr, v1, mark_line=["average"], mark_point=["max", "min"]) bar.add("evaporation", attr, v2, mark_line=["average"], mark_point=["max", "min"]) bar.render() ``` It will create a file named *render.html* in the root directory, open file with your borwser.  ### Export as Images or Pdf [pyecharts-snapshot](https://github.com/pyecharts/pyecharts-snapshot) is [a command line utility](https://github.com/pyecharts/pyecharts-snapshot#usage) and [a library extension](https://github.com/pyecharts/pyecharts-snapshot#example-programs) which renders the output of pyecharts as a svg, png, jpeg, gif image or a pdf file. After you will have installed pyecharts-snapshot, you can modify previous example file slightly and get png output directly: ```python bar.render(path="render.png") ``` So please see installation instruction and other usage at that repository. ## Platform Support pyecharts exposes chart API and template API so that it can work on other python frameworks. ### Integration with Jupyter Notebook/nteract #### Notebook In the Notebook cell, you can simply pass on chart instance itself to Jupyter, which will diplay the chart. Please note **render_notebook** function has been removed. All chart classes in pyecharts implement the `_repr_html_` interface about [IPython Rich Display](http://ipython.readthedocs.io/en/stable/config/integrating.html#rich-display) . In the case of online jshost mode, you can also download as some file formats (ipynb/py/html/pdf) and run without jupyter notebook enviromnment.  #### nteract Since pyecharts 0.5.5+, [nteract](https://nteract.io) is supported. Once the following two lines should added to your notebook, you could use pyecharts in nteract in the same way as in jupyter notebook. ```python from pyecharts import enable_nteract enable_nteract() ```  However, when rendering output as image, the instructions are the same as jupyter notebook. Only default html(including js) output should call `enable_nteract()`. ### Integrate With Web Framework With the help of pyecharts API, it is easy to integrate pyecharts to your web projects, such as Flask and Django. Demo  ## Advanced Topics ### Custom Template Files and Layout pyecharts exposes engine API so that you can use your own template file and custom CSS. In addition, pyecharts also ships a lot of jinja2 template functions used in template files. ### Custom Map Libraries All maps are developed and maintained by [echarts-maps](https://github.com/echarts-maps) github organisation. ## Documentation * [中文文档](http://pyecharts.org/#/zh-cn/) * [English Documentation](http://pyecharts.org/#/en-us/) ## Examples All examples is hosted on the repository [pyecharts-users-cases](https://github.com/pyecharts/pyecharts-users-cases). ## Test ### Unit Test You should install the libraries in the requirements.txt files. ```shell $ pip install -r test\requirements.txt ``` And run with the [nose](https://nose.readthedocs.io/en/latest/) commands. ```shell $ make ``` ### Quality Assurance [flake8](http://flake8.pycqa.org/en/latest/index.html), [Codecov](https://codecov.io/) and [pylint](https://www.pylint.org/) are used to improve the quality of code. ### Continuous Integration The project is developed with [Travis CI](https://travis-ci.org/) and [AppVeyor](https://ci.appveyor.com/). ## Author [](https://github.com/chenjiandongx) [](https://github.com/chfw) [](https://github.com/kinegratii) ## License pyecharts is released under the MIT License. See LICENSE for more information.