Skip to content

Commit

Permalink
version 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiandongx committed Jul 10, 2017
1 parent 679c7f9 commit 0e5f13d
Show file tree
Hide file tree
Showing 23 changed files with 347 additions and 155 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ __pycache__/
.Python
/json/
/js/
/_images/
/images_/
env/
build/
develop-eggs/
Expand Down
2 changes: 2 additions & 0 deletions pyecharts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyecharts.charts.bar import Bar
from pyecharts.charts.effectscatter import EffectScatter
Expand Down
13 changes: 13 additions & 0 deletions pyecharts/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

__title__ = 'pyecharts'
__description__ = 'Python echarts, make charting easier'
__url__ = 'https://github.com/chenjiandongx/pyecharts'
__version__ = '1.0.1'
__author__ = 'chenjiandongx'
__author_email__ = '[email protected]'
__license__ = 'MIT'
__requires__ = ['pprint']
__packages__ = ['pyecharts', 'pyecharts/charts']
__keywords__ = ['echarts', 'charts']
4 changes: 3 additions & 1 deletion pyecharts/base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import json

Expand Down Expand Up @@ -205,7 +207,7 @@ def _legend_visualmap_colorlst(self, is_visualmap=False, **kwargs):
self._option.get('legend').update(chart['legend'])
self._option.update(color=chart['color'])

def render(self, path=r"E:\Python\pyecharts\render.html"):
def render(self, path="render.html"):
""" 渲染数据项,生成 html 文件
:param path:
Expand Down
2 changes: 2 additions & 0 deletions pyecharts/charts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
6 changes: 5 additions & 1 deletion pyecharts/charts/bar.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyecharts.base import Base
from pyecharts.option import get_all_options

Expand All @@ -14,7 +17,8 @@ def add(self, *args, **kwargs):
self.__add(*args, **kwargs)

def __add(self, name, x_axis, y_axis, *,
is_stack=False, **kwargs):
is_stack=False,
**kwargs):
"""
:param name:
Expand Down
19 changes: 5 additions & 14 deletions pyecharts/charts/effectscatter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyecharts.charts.scatter import Scatter
from pyecharts.option import get_all_options

Expand All @@ -14,9 +17,7 @@ def add(self, *args, **kwargs):

def __add(self, name, x_value, y_value, *,
symbol_size=10,
effect_brushtype="stroke",
effect_scale=2.5,
effect_period=4, **kwargs):
**kwargs):
"""
:param name:
Expand All @@ -27,12 +28,6 @@ def __add(self, name, x_value, y_value, *,
y 坐标轴数据
:param symbol_size:
标记图形大小
:param effect_brushtype:
波纹绘制方式,有 stroke/fill 可选
:param effect_scale:
动画中波纹的最大缩放比例
:param effect_period:
动画的时间
:param kwargs:
"""
if isinstance(x_value, list) and isinstance(y_value, list):
Expand All @@ -46,11 +41,7 @@ def __add(self, name, x_value, y_value, *,
"type": "effectScatter",
"name": name,
"showEffectOn":"render",
"rippleEffect":{
"brushType": effect_brushtype,
"scale": effect_scale,
"period":effect_period
},
"rippleEffect": chart['effect'],
"symbol": chart['symbol'],
"symbolSize": symbol_size,
"data": [list(z) for z in zip(x_value, y_value)],
Expand Down
3 changes: 3 additions & 0 deletions pyecharts/charts/funnel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyecharts.base import Base
from pyecharts.option import get_all_options

Expand Down
8 changes: 7 additions & 1 deletion pyecharts/charts/gauge.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyecharts.base import Base

class Gauge(Base):
Expand All @@ -12,7 +15,8 @@ def add(self, *args, **kwargs):

def __add(self, name, attr, value, *,
scale_range=None,
angle_range=None, **kwargs):
angle_range=None,
**kwargs):
"""
:param name:
Expand All @@ -27,10 +31,12 @@ def __add(self, name, attr, value, *,
仪表盘角度范围
:param kwargs:
"""
# 数据范围默认为 [0,100]
_min, _max = 0, 100
if scale_range:
if len(scale_range) == 2:
_min, _max = scale_range
# 角度范围默认为 [225,-45]
_start, _end = 225, -45
if angle_range:
if len(angle_range) == 2:
Expand Down
21 changes: 7 additions & 14 deletions pyecharts/charts/geo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyecharts.base import Base
from pyecharts.option import get_all_options

Expand All @@ -19,9 +22,7 @@ def __add(self, name, attr, value, *,
border_color="#111",
geo_normal_color="#323c48",
geo_emphasis_color="#2a333d",
effect_brushtype="stroke",
effect_scale=2.5,
effect_period=4, **kwargs):
**kwargs):
"""
:param name:
Expand All @@ -42,12 +43,6 @@ def __add(self, name, attr, value, *,
正常状态下地图区域的颜色
:param geo_emphasis_color:
高亮状态下地图区域的颜色
:param effect_brushtype:
波纹绘制方式,有 stroke/fill 可选
:param effect_scale:
动画中波纹的最大缩放比例
:param effect_period:
动画的时间
:param kwargs:
"""
if isinstance(attr, list) and isinstance(value, list):
Expand Down Expand Up @@ -87,14 +82,12 @@ def __add(self, name, attr, value, *,
"name": name,
"coordinateSystem": 'geo',
"showEffectOn": "render",
"rippleEffect": {
"brushType": effect_brushtype,
"scale": effect_scale,
"period": effect_period
},
"rippleEffect": chart['effect'],
"symbol": chart['symbol'],
"symbolSize": symbol_size,
"data": _data,
"label": chart['label'],
})
self._legend_visualmap_colorlst(**kwargs)
else:
raise TypeError("attr and value must be list")
6 changes: 5 additions & 1 deletion pyecharts/charts/graph.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyecharts.base import Base
from pyecharts.option import get_all_options

Expand All @@ -19,7 +22,8 @@ def __add(self, nodes, links, categories=None, *,
layout="force",
edge_length=50,
gravity=0.2,
repulsion=50, **kwargs):
repulsion=50,
**kwargs):
"""
:param nodes:
Expand Down
6 changes: 5 additions & 1 deletion pyecharts/charts/line.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyecharts.base import Base
from pyecharts.option import get_all_options

Expand All @@ -17,7 +20,8 @@ def __add(self, name, x_axis, y_axis, *,
is_smooth=False,
is_stack=False,
is_step=False,
is_fill=False, **kwargs):
is_fill=False,
**kwargs):
"""
:param name:
Expand Down
8 changes: 7 additions & 1 deletion pyecharts/charts/map.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyecharts.base import Base
from pyecharts.option import get_all_options

Expand All @@ -14,7 +17,8 @@ def add(self, *args, **kwargs):

def __add(self, name, attr, value, *,
is_roam=True,
maptype='china', **kwargs):
maptype='china',
**kwargs):
"""
:param name:
Expand Down Expand Up @@ -47,3 +51,5 @@ def __add(self, name, attr, value, *,
"roam": is_roam
})
self._legend_visualmap_colorlst(**kwargs)
else:
raise TypeError("attr and value must be list")
3 changes: 3 additions & 0 deletions pyecharts/charts/parallel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyecharts.base import Base

class Parallel(Base):
Expand Down
6 changes: 5 additions & 1 deletion pyecharts/charts/pie.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyecharts.base import Base
from pyecharts.option import get_all_options

Expand All @@ -15,7 +18,8 @@ def add(self, *args, **kwargs):
def __add(self, name, attr, value, *,
radius=None,
center=None,
rosetype="radius", **kwargs):
rosetype="radius",
**kwargs):
"""
:param name:
Expand Down
19 changes: 5 additions & 14 deletions pyecharts/charts/polar.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyecharts.base import Base
from pyecharts.option import get_all_options

Expand All @@ -21,9 +24,7 @@ def __add(self, name, data, *,
rotate_step=0,
boundary_gap=True,
clockwise=True,
effect_brushtype="stroke",
effect_scale=2.5,
effect_period=4, **kwargs):
**kwargs):
"""
:param name:
Expand All @@ -49,12 +50,6 @@ def __add(self, name, data, *,
默认为 true,这时候刻度只是作为分隔线,标签和数据点都会在两个刻度之间的带(band)中间
:param clockwise:
刻度增长是否按顺时针,默认顺时针
:param effect_brushtype:
波纹绘制方式,有 stroke/fill 可选
:param effect_scale:
动画中波纹的最大缩放比例
:param effect_period:
动画的时间
:param kwargs:
"""
chart = get_all_options(**kwargs)
Expand All @@ -76,11 +71,7 @@ def __add(self, name, data, *,
"name": name,
"coordinateSystem": 'polar',
"showEffectOn": "render",
"rippleEffect": {
"brushType": effect_brushtype,
"scale": effect_scale,
"period": effect_period
},
"rippleEffect": chart['effect'],
"symbol": chart['symbol'],
"symbolSize": symbol_size,
"data": data,
Expand Down
6 changes: 5 additions & 1 deletion pyecharts/charts/radar.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pyecharts.base import Base
from pyecharts.option import get_all_options

Expand All @@ -12,7 +15,8 @@ def __init__(self, title="", subtitle="", **kwargs):
def config(self, schema=None, *,
c_schema=None,
shape="",
rader_text_color="#000", **kwargs):
rader_text_color="#000",
**kwargs):
""" 配置 rader 组件选项
:param schema:
Expand Down
10 changes: 8 additions & 2 deletions pyecharts/charts/scatter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from PIL import Image

from pyecharts.base import Base
from pyecharts.option import get_all_options

Expand All @@ -14,7 +18,8 @@ def add(self, *args, **kwargs):
self.__add(*args, **kwargs)

def __add(self, name, x_value, y_value, *,
symbol_size=10, **kwargs):
symbol_size=10,
**kwargs):
"""
:param name:
Expand Down Expand Up @@ -47,7 +52,7 @@ def __add(self, name, x_value, y_value, *,
raise TypeError("x_axis and y_axis must be list")

def draw(self, path, color=None):
""" 将图片上的像素点转换为数组,如 color 为 (255,255,255)时只保留非白色像素点的坐标信息
""" 将图片上的像素点转换为数组,如 color 为(255,255,255)时只保留非白色像素点的坐标信息
:param path:
转换图片的地址
Expand All @@ -64,5 +69,6 @@ def draw(self, path, color=None):
for y in range(height):
if y < int(height / 2):
imarray[x, y], imarray[x, height-y-1] = imarray[x, height-y-1], imarray[x, y]
# [:3] 为 r,g,b
result = [(x, y) for x in range(width) for y in range(height) if imarray[x, y][:3] != color]
return self.cast(result)
Loading

0 comments on commit 0e5f13d

Please sign in to comment.