https://github.com/doglooksgood/py-echarts
https://github.com/doglooksgood/py-echarts
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/doglooksgood/py-echarts
- Owner: DogLooksGood
- Created: 2015-07-08T10:32:27.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-07-08T10:40:19.000Z (almost 11 years ago)
- Last Synced: 2025-03-29T12:11:35.475Z (about 1 year ago)
- Language: Python
- Size: 81.1 KB
- Stars: 4
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# py-echarts
```python
from flask import Flask, render_template
import json
from models import Chart
app = Flask(__name__)
@app.route("/")
def index():
chart1 = Chart().pie("饼图", data={
u"衬衫": 100,
u"羊毛衫": 360,
u"雪纺衫": 120,
u"裤子": 500,
u"高跟鞋": 300
})
chart2 = Chart() \
.legend(data=[u"最高气温", u"最低气温"]) \
.x_axis(data=[u"周一", u"周二", u"周三", u"周四", u"周五", u"周六", u"周日"]) \
.y_axis(formatter="{value} C") \
.line(u"最高气温", [10, 20, 30, 40, 30, 20, 10], mark_max_point=True, show_item_label=True) \
.bar(u"最低气温", [5, 10, 5, 10, 5, 6, 7]) \
.pie(name="测试", data={"Java": 50, "PHP": 50, "Python": 100}, center=["20%", "30%"], radius="15%")
print json.dumps(chart2, indent=2)
render = {
"title": u"测试的标题",
"templates": [
{"type": "radio"},
{"type": "table"},
{"type": "chart", "option": json.dumps(chart1, indent=2)},
{"type": "chart", "option": json.dumps(chart2, indent=2)}
]
}
return render_template("main.html", **render)
```