Skip to content

Commit

Permalink
version 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiandongx committed Jul 17, 2017
1 parent af9ac02 commit 8b87e3a
Show file tree
Hide file tree
Showing 97 changed files with 2,260 additions and 201 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ __pycache__/
.idea
# Distribution / packaging
.Python
/json/
/js/
/images_/
env/
build/
develop-eggs/
Expand Down
1,211 changes: 1,210 additions & 1 deletion README.md

Large diffs are not rendered by default.

114 changes: 114 additions & 0 deletions example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
```python
import math
from pyecharts import Polar

data = []
for i in range(101):
theta = i / 100 * 360
r = 5 * (1 + math.sin(theta / 180 * math.pi))
data.append([r, theta])
hour = [i for i in range(1, 25)]
polar = Polar("极坐标系示例", width=1200, height=600)
polar.add("Love", data, angle_data=hour, boundary_gap=False,start_angle=0)
polar.show_config()
polar.render()
```
![example-0](https://github.com/chenjiandongx/pyecharts/blob/master/images/example-0.png)

```python
import math
from pyecharts import Polar

data = []
for i in range(361):
t = i / 180 * math.pi
r = math.sin(2 * t) * math.cos(2 * t)
data.append([r, i])
polar = Polar("极坐标系示例", width=1200, height=600)
polar.add("Flower", data, start_angle=0, symbol=None, axis_range=[0, None])
polar.show_config()
polar.render()
```
![example-1](https://github.com/chenjiandongx/pyecharts/blob/master/images/example-1.png)

```python
from pyecharts import Scatter

scatter = Scatter("散点图示例", width=800, height=480)
v1 ,v2 = scatter.draw("../images/love.png")
scatter.add("Love", v1, v2)
scatter.render()
```
![example-2](https://github.com/chenjiandongx/pyecharts/blob/master/images/example-2.png)

```python
from pyecharts import Scatter

scatter = Scatter("散点图示例", width=1000, height=480)
v1 ,v2 = scatter.draw("../images/cup.png")
scatter.add("Cup", v1, v2)
scatter.render()
```
![example-3](https://github.com/chenjiandongx/pyecharts/blob/master/images/example-3.png)

```python
from pyecharts import Scatter

scatter = Scatter("散点图示例", width=1000, height=480)
v1 ,v2 = scatter.draw("../images/cup.png")
scatter.add("Cup", v1, v2, label_color=["#000"])
scatter.render()
```
![example-4](https://github.com/chenjiandongx/pyecharts/blob/master/images/example-4.png)

```python
from pyecharts import Line

attr = ['周一', '周二', '周三', '周四', '周五', '周六', '周日', ]
line = Line("折线图示例")
line.add("最高气温", attr, [11, 11, 15, 13, 12, 13, 10], mark_point=["max", "min"],mark_line=["average"])
line.add("最低气温", attr, [1, -2, 2, 5, 3, 2, 0], mark_point=["max", "min"], mark_line=["average"], yaxis_formatter="°C")
line.show_config()
line.render()
```
![example-5](https://github.com/chenjiandongx/pyecharts/blob/master/images/example-5.gif)

```python
from pyecharts import Pie

pie = Pie("饼图示例", title_pos='center', width=1000, height=600)
pie.add("", ['A', 'B', 'C', 'D', 'E', 'F'], [335, 321, 234, 135, 251, 148], radius=[40, 55],is_label_show=True)
pie.add("", ['H', 'I', 'J'], [335, 679, 204], radius=[0, 30], legend_orient='vertical', legend_pos='left')
pie.show_config()
pie.render()
```
![example-6](https://github.com/chenjiandongx/pyecharts/blob/master/images/example-6.png)

```python
import random
from pyecharts import Pie

attr = ['A', 'B', 'C', 'D', 'E', 'F']
pie = Pie("饼图示例", width=1000, height=600)
pie.add("", attr, [random.randint(0, 100) for _ in range(6)], radius=[50, 55], center=[25, 50],is_random=True)
pie.add("", attr, [random.randint(20, 100) for _ in range(6)], radius=[0, 45], center=[25, 50],rosetype='area')
pie.add("", attr, [random.randint(0, 100) for _ in range(6)], radius=[50, 55], center=[65, 50],is_random=True)
pie.add("", attr, [random.randint(20, 100) for _ in range(6)], radius=[0, 45], center=[65, 50],rosetype='radius')
pie.show_config()
pie.render()
```
![example-7](https://github.com/chenjiandongx/pyecharts/blob/master/images/example-7.gif)

```python
from pyecharts import Bar

attr = ["{}".format(i) for i in range(1, 13)]
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.add("蒸发量", attr, v1, mark_line=["average"], mark_point=["max", "min"])
bar.add("降水量", attr, v2, mark_line=["average"], mark_point=["max", "min"])
bar.show_config()
bar.render()
```
![example-8](https://github.com/chenjiandongx/pyecharts/blob/master/images/example-8.png)
Binary file added images/bar-0.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/bar-1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/bar-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/cup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/custom-0.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/effectscatter-0.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/effectscatter-1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/example-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/example-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/example-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/example-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/example-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/example-5.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/example-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/example-7.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/example-8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/funnel-0.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/funnel-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/gauge-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/gauge-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/geo-0.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/geo-1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/graph-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/graph-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/graph-2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/guide-0.png
Binary file added images/line-0.gif
Binary file added images/line-1.gif
Binary file added images/line-2.png
Binary file added images/line-3.png
Binary file added images/liquid-0.gif
Binary file added images/liquid-1.gif
Binary file added images/liquid-2.png
Binary file added images/love.png
Binary file added images/map-0.gif
Binary file added images/map-1.gif
Binary file added images/map-2.gif
Binary file added images/parallel-0.png
Binary file added images/parallel-1.png
Binary file added images/pie-0.gif
Binary file added images/pie-1.png
Binary file added images/pie-2.png
Binary file added images/poalr-4.png
Binary file added images/polar-0.png
Binary file added images/polar-1.png
Binary file added images/polar-2.gif
Binary file added images/polar-3.gif
Binary file added images/pyecharts-0.png
Binary file added images/pyecharts-1.png
Binary file added images/radar-0.gif
Binary file added images/radar-1.gif
Binary file added images/scatter-0.png
Binary file added images/wordcloud-0.png
Binary file added images/wordcloud-1.png
1 change: 1 addition & 0 deletions json/weibo.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyecharts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#coding=utf-8

from pyecharts.charts.bar import Bar
Expand All @@ -9,6 +8,7 @@
from pyecharts.charts.geo import Geo
from pyecharts.charts.graph import Graph
from pyecharts.charts.line import Line
from pyecharts.charts.liquid import Liquid
from pyecharts.charts.map import Map
from pyecharts.charts.parallel import Parallel
from pyecharts.charts.pie import Pie
Expand Down
3 changes: 1 addition & 2 deletions pyecharts/__version__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#coding=utf-8

__title__ = 'pyecharts'
__description__ = 'Python echarts, make charting easier'
__url__ = 'https://github.com/chenjiandongx/pyecharts'
__version__ = '1.1.4'
__version__ = '0.1.1'
__author__ = 'chenjiandongx'
__author_email__ = '[email protected]'
__license__ = 'MIT'
Expand Down
22 changes: 17 additions & 5 deletions pyecharts/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#coding=utf-8

import json
Expand Down Expand Up @@ -71,6 +70,7 @@ def add(self, angle_data=None,
angle_range=None,
area_color=None,
area_opacity=None,
axis_range=None,
border_color=None,
boundary_gap=None,
center=None,
Expand All @@ -93,6 +93,8 @@ def add(self, angle_data=None,
is_focusnode=None,
is_label_show=None,
is_legend_show=None,
is_liquid_animation=None,
is_liquid_outline_show=None,
is_random=None,
is_roam=None,
is_rotatelabel=None,
Expand All @@ -114,6 +116,7 @@ def add(self, angle_data=None,
line_opacity=None,
line_type=None,
line_width=None,
liquid_color=None,
maptype=None,
mark_line=None,
mark_point=None,
Expand All @@ -139,7 +142,8 @@ def add(self, angle_data=None,
x_axis=None,
xaxis_name_pos=None,
xaxis_name=None,
xy_font_size=None,
xy_text_size=None,
yaxis_formatter=None,
yaxis_name_pos=None,
yaxis_name=None):
""" base 父类的 add 方法只是为了提供提示选项 """
Expand All @@ -165,7 +169,8 @@ def show_config(self):
""" 打印输出 option 所有配置项 """
pprint(self._option)

def cast(self, seq):
@staticmethod
def cast(seq):
""" 转换数据序列,将带字典和元祖类型的序列转换为 k_lst,v_lst 两个列表
1.[(A1, B1),(A2, B2),(A3, B3),(A4, B4)] --> k_lst[A[i1,i2...]], v_lst[B[i1,i2...]]
2.[{A1: B1},{A2: B2},{A3: B3},{A4: B4}] --> k_lst[A[i1,i2...]], v_lst[B[i1,i2...]]
Expand Down Expand Up @@ -222,6 +227,9 @@ def render(self, path="render.html"):
if s.get('type') == "wordCloud":
temple = Tp._temple_wd
break
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
Expand All @@ -230,8 +238,12 @@ def render(self, path="render.html"):
.replace("myOption", my_option)\
.replace("myWidth", str(self._width))\
.replace("myHeight", str(self._height))
with open(path, "w+") as f:
f.write(__op)
try: # for Python3
with open(path, "w+", encoding="utf-8") as fout:
fout.write(__op)
except: # for Python2
with open(path, "w+") as fout:
fout.write(__op)

@property
def _geo_cities(self):
Expand Down
3 changes: 0 additions & 3 deletions pyecharts/charts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#coding=utf-8
1 change: 0 additions & 1 deletion pyecharts/charts/bar.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#coding=utf-8

from pyecharts.base import Base
Expand Down
1 change: 0 additions & 1 deletion pyecharts/charts/effectscatter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#coding=utf-8

from pyecharts.charts.scatter import Scatter
Expand Down
1 change: 0 additions & 1 deletion pyecharts/charts/funnel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#coding=utf-8

from pyecharts.base import Base
Expand Down
1 change: 0 additions & 1 deletion pyecharts/charts/gauge.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#coding=utf-8

from pyecharts.base import Base
Expand Down
3 changes: 1 addition & 2 deletions pyecharts/charts/geo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#coding=utf-8

from pyecharts.base import Base
Expand Down Expand Up @@ -33,7 +32,7 @@ def __add(self, name, attr, value,
:param value:
属性所对应的值
:param type:
图例类型,有 scatter/effectscatter 可选
图例类型,有'scatter', 'effectscatter'可选
:param maptype:
地图类型,目前只有 china 可选
:param symbol_size:
Expand Down
7 changes: 4 additions & 3 deletions pyecharts/charts/graph.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#coding=utf-8

from pyecharts.base import Base
Expand All @@ -16,7 +15,7 @@ def __init__(self, title="", subtitle="", **kwargs):
def add(self, *args, **kwargs):
self.__add(*args, **kwargs)

def __add(self, nodes, links, categories=None,
def __add(self, name, nodes, links, categories=None,
is_focusnode=True,
is_roam=True,
is_rotatelabel=False,
Expand All @@ -26,7 +25,8 @@ def __add(self, nodes, links, categories=None,
repulsion=50,
**kwargs):
"""
:param name:
图例名称
:param nodes:
关系图结点,包含的数据项有
# 必须!!
Expand Down Expand Up @@ -76,6 +76,7 @@ def __add(self, nodes, links, categories=None,
self._option.get('legend').get('data').append(c)
self._option.get('series').append({
"type": "graph",
"name": name,
"layout": layout,
"symbol": chart['symbol'],
"circular": {"rotateLabel": is_rotatelabel},
Expand Down
1 change: 0 additions & 1 deletion pyecharts/charts/line.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#coding=utf-8

from pyecharts.base import Base
Expand Down
62 changes: 62 additions & 0 deletions pyecharts/charts/liquid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python
#coding=utf-8

from pyecharts.base import Base

class Liquid(Base):
"""
<<< 水球图 >>>
主要用来突出数据的百分比
"""
def __init__(self, title="", subtitle="", **kwargs):
super(Liquid, self).__init__(title, subtitle, **kwargs)

def add(self, *args, **kwargs):
self.__add(*args, **kwargs)

def __add(self, name, data,
shape='circle',
liquid_color=None,
is_liquid_animation=True,
is_liquid_outline_show=True,
**kwargs):
"""
:param name:
图例名称
:param data:
数据项
:param shape:
水球外形,有'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow'可选
:param liquid_color:
波浪颜色
:param is_liquid_animation:
是否显示波浪动画
:param is_liquid_outline_show:
是否显示边框
:param kwargs:
:return:
"""
_animation_dur, _animation_dur_update = 2000, 1000
if not is_liquid_animation:
_animation_dur, _animation_dur_update = 0, 0

_color = ['#294D99', '#156ACF', '#1598ED', '#45BDFF']
if liquid_color:
_color = liquid_color

_shape = 'circle'
if shape in ('circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow'):
_shape = shape

self._option.get('series').append({
"type": "liquidFill",
"name": name,
"data": data,
"waveAnimation": is_liquid_animation,
"animationDuration": _animation_dur,
"animationDurationUpdate": _animation_dur_update,
"color": _color,
"shape": _shape,
"outline": {"show": is_liquid_outline_show}
})
1 change: 0 additions & 1 deletion pyecharts/charts/map.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#coding=utf-8

from pyecharts.base import Base
Expand Down
Loading

0 comments on commit 8b87e3a

Please sign in to comment.