安装方法
Installing echarts-python with pip
$ pip install echarts–python
Current version for Echarts 3.1.6
基本使用方法
from echarts import Echart, Legend, Bar, Axis chart = Echart('GDP', 'This is a fake chart') chart.use(Bar('China', [2, 3, 4, 5])) chart.use(Legend(['GDP'])) chart.use(Axis('category', 'bottom', data=['Nov', 'Dec', 'Jan', 'Feb'])) The chart.json property will be { "title": { "text": "GDP", "subtext": "This is a fake chart" }, "series": [ { "type": "bar", "data": [ 2, 3, 4, 5 ], "name": "China" } ], "legend": { "y": "top", "x": "center", "data": [ "GDP" ], "orient": "horizontal" }, "xAxis": [ { "position": "bottom", "data": [ "Nov", "Dec", "Jan", "Feb" ], "type": "category" } ], "yAxis": {} }
代码在mac上也是一样可以运行的
使用chart.plot()可以调用浏览器来显示图表。