Skip to content

Commit

Permalink
修改 temple, 增加 custom 示例
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiandongx committed Jul 21, 2017
1 parent ecb68c9 commit da2b4a6
Show file tree
Hide file tree
Showing 7 changed files with 294 additions and 2,187 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ wordcloud.render()


# 用户自定义
用户还可以自定义结合 Line/Bar 图表
用户还可以自定义结合 Line/Bar, Scatter/EffectScatter 图表
需使用 ```get_series()``````custom()``` 方法

```python
Expand All @@ -1238,6 +1238,7 @@ custom(series)

先用 ```get_series()``` 获取数据,再使用 ```custom()``` 将图表结合在一起

Line + Bar
```python
from pyecharts import Bar, Line

Expand All @@ -1255,6 +1256,27 @@ bar.render()
```
![custom-0](https://github.com/chenjiandongx/pyecharts/blob/master/images/custom-0.gif)

Scatter + EffectScatter
```python
from pyecharts import Scatter, EffectScatter

v1 = [10, 20, 30, 40, 50, 60]
v2 = [30, 30, 30, 30, 30, 30]
v3 = [50, 50, 50, 50, 50, 50]
v4 = [10, 10, 10, 10, 10, 10]
es = EffectScatter("Scatter - EffectScatter 示例")
es.add("es", v1, v2)
scatter = Scatter()
scatter.add("scatter", v1, v3)
es.custom(scatter.get_series())
es_1 = EffectScatter()
es_1.add("es_1", v1, v4, symbol='pin', effect_scale=5)
es.custom(es_1.get_series())
es.show_config()
es.render()
```
![custom-1](https://github.com/chenjiandongx/pyecharts/blob/master/images/custom-1.gif)

# 更多示例

* 更多示例请参考 [example.md](https://github.com/chenjiandongx/pyecharts/blob/master/example.md)
Expand Down
Binary file added images/custom-1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions pyecharts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,6 @@ def render(self, path="render.html"):
if s.get('type') == "liquidFill":
temple = Tp._temple_lq
break
if s.get('type') in ("scatter", "pie", "bar", "line") and 'coordinateSystem' not in s:
temple = Tp.temple
break
my_option = json.dumps(self._option, indent=4, ensure_ascii=False)
__op = temple\
.replace("myOption", my_option)\
Expand Down
107 changes: 42 additions & 65 deletions pyecharts/temple.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,6 @@
#!/usr/bin/env python
#coding=utf-8

_temple = """
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ECharts</title>
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/echarts-all-3.js"></script>
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts-stat/ecStat.min.js"></script>
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/dataTool.min.js"></script>
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/china.js"></script>
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/world.js"></script>
<script type="text/javascript" src="http://oog4yfyu0.bkt.clouddn.com/wordcloud.js"></script>
<script type="text/javascript" src="http://oog4yfyu0.bkt.clouddn.com/anhui.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/aomen.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/beijing.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/chongqing.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/fujian.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/gansu.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/guangdong.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/guangxi.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/guizhou.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/hainan.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/hebei.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/heilongjiang.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/henan.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/hubei.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/hunan.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/jiangsu.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/jiangxi.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/jilin.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/liaoning.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/neimenggu.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/ningxia.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/qinghai.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/shangdong.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/shanghai.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/shanxi.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/sichuan.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/taiwan.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/tianjin.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/xianggang.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/xinjiang.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/xizang.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/yunnan.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/zhejiang.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/guangdong.js "></script>
<script type="text/javascript " src="http://api.map.baidu.com/api?v=2.0&ak=ZUONbpqGBsYGXNIYHicvbAbM "></script>
<script type="text/javascript " src="http://echarts.baidu.com/gallery/vendors/echarts/extension/bmap.min.js "></script>
</head>
<body>
<div id="main" style="width: myWidthpx;height:myHeightpx; "></div>
<script type="text/javascript ">
var myChart = echarts.init(document.getElementById('main'));
var option = myOption;
myChart.setOption(option);
</script>
</body>
</html>
"""

_temple_wd = """
<!DOCTYPE html>
Expand Down Expand Up @@ -120,15 +58,54 @@
</html>
"""

temple = """

_temple="""
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ECharts</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/3.5.4/echarts.common.min.js"></script>
<script src="http://oog4yfyu0.bkt.clouddn.com/echarts.min.js"></script>
<script type="text/javascript " src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/china.js"></script>
<script type="text/javascript " src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/world.js"></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/wordcloud.js"></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/anhui.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/aomen.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/beijing.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/chongqing.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/fujian.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/gansu.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/guangdong.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/guangxi.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/guizhou.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/hainan.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/hebei.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/heilongjiang.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/henan.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/hubei.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/hunan.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/jiangsu.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/jiangxi.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/jilin.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/liaoning.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/neimenggu.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/ningxia.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/qinghai.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/shangdong.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/shanghai.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/shanxi.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/sichuan.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/taiwan.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/tianjin.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/xianggang.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/xinjiang.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/xizang.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/yunnan.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/zhejiang.js "></script>
<script type="text/javascript " src="http://oog4yfyu0.bkt.clouddn.com/guangdong.js "></script>
<script type="text/javascript " src="http://api.map.baidu.com/api?v=2.0&ak=ZUONbpqGBsYGXNIYHicvbAbM "></script>
<script type="text/javascript " src="http://echarts.baidu.com/gallery/vendors/echarts/extension/bmap.min.js "></script>
</head>
<body>
Expand Down
Loading

0 comments on commit da2b4a6

Please sign in to comment.