Skip to content

Commit

Permalink
Add is_animation initialize argument for every charts (pyecharts#693)
Browse files Browse the repository at this point in the history
* Add: pyecharts#691 为每个图形新增 is_animation 配置项,用于控制是否显示动画

* Fix: 修复测试

* Docs: 文档更新
  • Loading branch information
chenjiandongx authored Aug 25, 2018
1 parent 5c26a1d commit 75e37c0
Show file tree
Hide file tree
Showing 17 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/zh-cn/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#### Added
* [pr#685](https://github.com/pyecharts/pyecharts/pull/685) 图表方法(`use_theme`/`config`/`add`)支持链式调用
* [issue#687](https://github.com/pyecharts/pyecharts/issues/687) 新增 `add_coordinate_json` 方法用于支持导入 Geo/Geolines 坐标数据
* [issue#691](https://github.com/pyecharts/pyecharts/issues/691) 为每种图形新增 `is_animation` 初始化参数,用于控制是否显示动画。


* ### version 0.5.8 - 2018.8.13(current)
Expand Down
3 changes: 2 additions & 1 deletion docs/zh-cn/charts_configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
指定使用渲染方式,有 'svg' 和 'canvas' 可选,默认为 'canvas'。3D 图仅能使用 'canvas'。
* extra_html_text_label -> list
额外的 HTML 文本标签,`(<p> 标签)`。类型为 list,list[0] 为文本内容,list[1] 为字体风格样式(选填)。如 ["this is a p label", "color:red"]**仅限于在单个图形或者 page 类时使用。**

* is_animation -> bool
是否开启动画,默认为 True。V0.5.9+

## 通用配置项

Expand Down
4 changes: 4 additions & 0 deletions pyecharts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(
renderer=constants.CANVAS_RENDERER,
page_title=constants.PAGE_TITLE,
extra_html_text_label=None,
is_animation=True,
):
"""
Expand All @@ -42,6 +43,8 @@ def __init__(
:param extra_html_text_label:
额外的 HTML 文本标签,(<p> 标签)。类型为 list,list[0] 为文本内容,
list[1] 为字体风格样式(选填)。如 ["this is a p label", "color:red"]
:param is_animation:
是否开启动画,默认为 True。V0.5.9+
"""
self._option = {}
self._js_dependencies = set()
Expand All @@ -54,6 +57,7 @@ def __init__(
self.theme = None
self.use_theme(CURRENT_CONFIG.theme)
self.extra_html_text_label = extra_html_text_label
self.is_animation = is_animation

@property
def chart_id(self):
Expand Down
5 changes: 5 additions & 0 deletions pyecharts/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(
page_title=constants.PAGE_TITLE,
renderer=constants.CANVAS_RENDERER,
extra_html_text_label=None,
is_animation=True,
):
"""
Expand Down Expand Up @@ -62,13 +63,16 @@ def __init__(
:param extra_html_text_label:
额外的 HTML 文本标签,(<p> 标签)。类型为 list,list[0] 为文本内容,
list[1] 为字体风格样式(选填)。如 ["this is a p label", "color:red"]
:param is_animation:
是否开启动画,默认为 True。V0.5.9+
"""
super(Chart, self).__init__(
width=width,
height=height,
renderer=renderer,
page_title=page_title,
extra_html_text_label=extra_html_text_label,
is_animation=is_animation
)
self._colorlst = [
"#c23531",
Expand Down Expand Up @@ -130,6 +134,7 @@ def __init__(
series=[],
legend=[{"data": []}],
backgroundColor=background_color,
animation=self.is_animation
)

def add(
Expand Down
6 changes: 4 additions & 2 deletions pyecharts/custom/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

class Grid(Base):
"""
<<< 并行显示多张图 >>>
用户可以自定义结合 Line/Bar/Kline/Scatter/EffectScatter/Pie/HeatMap
/Boxplot 图表,将不同类型图表画在多张图上。第一个图需为 有 x/y 轴的图,
即不能为 Pie,其他位置顺序任意。
"""

def __init__(self, page_title=PAGE_TITLE, width=800, height=400):
super(Grid, self).__init__(width=width, height=height)
def __init__(self, page_title=PAGE_TITLE, width=800, height=400, **kwargs):
super(Grid, self).__init__(width=width, height=height, **kwargs)
self._page_title = page_title

def add(
Expand Down
2 changes: 2 additions & 0 deletions pyecharts/custom/overlap.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

class Overlap(Base):
"""
<<< 结合不同类型图表叠加画在同张图上 >>>
用户可以自定义结合 Line/Bar/Kline, Scatter/EffectScatter 图表,
将不同类型图表画在一张图上。利用第一个图表为基础,往后的数据都将
会画在第一个图表上。
Expand Down
2 changes: 2 additions & 0 deletions pyecharts/custom/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

class Page(object):
"""
<<< 同一网页按顺序展示多图 >>>
A composite object to present multiple charts vertically in a single page
"""

Expand Down
2 changes: 1 addition & 1 deletion pyecharts/custom/timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class Timeline(Base):
"""
时间线轮播多张图
<<< 时间线轮播多张图 >>>
"""

def __init__(
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/bar3d_options.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"animation": true,
"color": [
"#c23531",
"#2f4554",
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/bar_options.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"animation": true,
"color": [
"#c23531",
"#2f4554",
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/geo_options.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"animation": true,
"color": [
"#c23531",
"#2f4554",
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/geolines.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"animation": true,
"backgroundColor": "#404a59",
"color": [
"#a6c84c",
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/kline_options.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"animation": true,
"color": [
"#c23531",
"#2f4554",
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/line3d_options.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"animation": true,
"color": [
"#c23531",
"#2f4554",
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/polar_options.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"type": "category",
"z": 50
},
"animation": true,
"color": [
"#c23531",
"#2f4554",
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/scatter3d_options.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"animation": true,
"color": [
"#c23531",
"#2f4554",
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/scatter_options.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"animation": true,
"color": [
"#c23531",
"#2f4554",
Expand Down

0 comments on commit 75e37c0

Please sign in to comment.