Skip to content

Commit 256a132

Browse files
committed
follow pyecharts dev branch and update docs
1 parent 43ab79e commit 256a132

6 files changed

+268
-1
lines changed

_navbar.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- [pyecharts](https://github.com/pyecharts/pyecharts)
44
- [snapshot-selenium](https://github.com/pyecharts/snapshot-selenium)
55
- [snapshot-phantomjs](https://github.com/pyecharts/snapshot-phantomjs)
6+
- [snapshot-pyppeteer](https://github.com/pyecharts/snapshot-pyppeteer)
67
- [捐赠](zh-cn/donate)
78
- Language
89
- [中文](/zh-cn/)

zh-cn/3d_charts.md

+102
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ class Bar3D(
127127

128128
### Demo
129129

130+
> Bar3D-基本示例
131+
130132
```python
131133
from pyecharts.faker import Faker
132134
from pyecharts import options as opts
@@ -152,6 +154,106 @@ def bar3d_base() -> Bar3D:
152154
```
153155
![](https://user-images.githubusercontent.com/19553554/55604530-d3213c80-57a2-11e9-8a13-45289fe88d17.png)
154156

157+
> Bar3D-堆叠柱状图示例
158+
159+
```python
160+
def bar3d_stack() -> Bar3D:
161+
def generate_data():
162+
data = []
163+
for j in range(10):
164+
for k in range(10):
165+
value = random.randint(0, 9)
166+
data.append([j, k, value * 2 + 4])
167+
return data
168+
169+
c = (
170+
Bar3D()
171+
.add(
172+
"",
173+
generate_data(),
174+
shading="lambert",
175+
xaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
176+
yaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
177+
zaxis3d_opts=opts.Axis3DOpts(type_="value"),
178+
)
179+
.add(
180+
"",
181+
generate_data(),
182+
shading="lambert",
183+
xaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
184+
yaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
185+
zaxis3d_opts=opts.Axis3DOpts(type_="value"),
186+
)
187+
.add(
188+
"",
189+
generate_data(),
190+
shading="lambert",
191+
xaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
192+
yaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
193+
zaxis3d_opts=opts.Axis3DOpts(type_="value"),
194+
)
195+
.add(
196+
"",
197+
generate_data(),
198+
shading="lambert",
199+
xaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
200+
yaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
201+
zaxis3d_opts=opts.Axis3DOpts(type_="value"),
202+
)
203+
.add(
204+
"",
205+
generate_data(),
206+
shading="lambert",
207+
xaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
208+
yaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
209+
zaxis3d_opts=opts.Axis3DOpts(type_="value"),
210+
)
211+
.add(
212+
"",
213+
generate_data(),
214+
shading="lambert",
215+
xaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
216+
yaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
217+
zaxis3d_opts=opts.Axis3DOpts(type_="value"),
218+
)
219+
.add(
220+
"",
221+
generate_data(),
222+
shading="lambert",
223+
xaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
224+
yaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
225+
zaxis3d_opts=opts.Axis3DOpts(type_="value"),
226+
)
227+
.add(
228+
"",
229+
generate_data(),
230+
shading="lambert",
231+
xaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
232+
yaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
233+
zaxis3d_opts=opts.Axis3DOpts(type_="value"),
234+
)
235+
.add(
236+
"",
237+
generate_data(),
238+
shading="lambert",
239+
xaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
240+
yaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
241+
zaxis3d_opts=opts.Axis3DOpts(type_="value"),
242+
)
243+
.add(
244+
"",
245+
generate_data(),
246+
shading="lambert",
247+
xaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
248+
yaxis3d_opts=opts.Axis3DOpts(data=list(range(10)), type_="value"),
249+
zaxis3d_opts=opts.Axis3DOpts(type_="value"),
250+
)
251+
.set_global_opts(title_opts=opts.TitleOpts("Bar3D-堆叠柱状图示例"))
252+
.set_series_opts(**{"stack": "stack"})
253+
)
254+
return c
255+
```
256+
![](https://user-images.githubusercontent.com/17564655/68597558-23e6d980-04d8-11ea-8342-6a36dad4ab49.png)
155257

156258
## Line3D:3D折线图
157259

zh-cn/composite_charts.md

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ class GridOpts(
5757

5858
# grid 组件的高度。默认自适应。
5959
height: Union[Numeric, str, None] = None,
60+
61+
# grid 区域是否包含坐标轴的刻度标签。
62+
is_contain_label: bool = False,
6063
)
6164
```
6265

zh-cn/global_options.md

+6
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,12 @@ class VisualMapOpts(
516516
# colorHue: 颜色的色调,参见 HSL。
517517
out_of_range: Optional[Sequence] = None,
518518

519+
# 图形的宽度,即长条的宽度。
520+
item_width: int = 0,
521+
522+
# 图形的高度,即长条的高度。
523+
item_height: int = 0,
524+
519525
# 文字样式配置项,参考 `series_options.TextStyleOpts`
520526
textstyle_opts: Union[TextStyleOpts, dict, None] = None,
521527
)

zh-cn/rectangular_charts.md

+116
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,44 @@ def bar_custom_bar_color() -> Bar:
961961
```
962962
![](https://user-images.githubusercontent.com/19553554/63005440-1dcc6700-beaf-11e9-9281-8b20a047c113.png)
963963

964+
> Bar-堆叠显示百分比
965+
966+
```python
967+
def stack_bar_percent() -> Bar:
968+
list2 = [
969+
{"value": 12, "percent": 12 / (12 + 3)},
970+
{"value": 23, "percent": 23 / (23 + 21)},
971+
{"value": 33, "percent": 33 / (33 + 5)},
972+
{"value": 3, "percent": 3 / (3 + 52)},
973+
{"value": 33, "percent": 33 / (33 + 43)},
974+
]
975+
976+
list3 = [
977+
{"value": 3, "percent": 3 / (12 + 3)},
978+
{"value": 21, "percent": 21 / (23 + 21)},
979+
{"value": 5, "percent": 5 / (33 + 5)},
980+
{"value": 52, "percent": 52 / (3 + 52)},
981+
{"value": 43, "percent": 43 / (33 + 43)},
982+
]
983+
984+
c = (
985+
Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
986+
.add_xaxis([1, 2, 3, 4, 5])
987+
.add_yaxis("product1", list2, stack="stack1", category_gap="50%")
988+
.add_yaxis("product2", list3, stack="stack1", category_gap="50%")
989+
.set_series_opts(
990+
label_opts=opts.LabelOpts(
991+
position="right",
992+
formatter=JsCode(
993+
"function(x){return Number(x.data.percent * 100).toFixed() + '%';}"
994+
),
995+
)
996+
)
997+
)
998+
return c
999+
```
1000+
![](https://user-images.githubusercontent.com/17564655/68597426-e5e9b580-04d7-11ea-882f-d5cce5ccd484.png)
1001+
9641002

9651003
## Boxplot:箱形图
9661004

@@ -1832,6 +1870,84 @@ def line_itemstyle() -> Line:
18321870
```
18331871
![](https://user-images.githubusercontent.com/19553554/56972743-1b632d00-6b9e-11e9-8110-c52070cc2783.png)
18341872

1873+
> Line图-高级自定义
1874+
1875+
```python
1876+
def line_color_with_js_func() -> Line:
1877+
x_data = ["14", "15", "16", "17", "18", "19", "20", "21", "22", "23"]
1878+
y_data = [393, 438, 485, 631, 689, 824, 987, 1000, 1100, 1200]
1879+
1880+
background_color_js = (
1881+
"new echarts.graphic.LinearGradient(0, 0, 0, 1, "
1882+
"[{offset: 0, color: '#c86589'}, {offset: 1, color: '#06a7ff'}], false)"
1883+
)
1884+
area_color_js = (
1885+
"new echarts.graphic.LinearGradient(0, 0, 0, 1, "
1886+
"[{offset: 0, color: '#eb64fb'}, {offset: 1, color: '#3fbbff0d'}], false)"
1887+
)
1888+
1889+
c = (
1890+
Line(init_opts=opts.InitOpts(bg_color=JsCode(background_color_js)))
1891+
.add_xaxis(xaxis_data=x_data)
1892+
.add_yaxis(
1893+
series_name="注册总量",
1894+
y_axis=y_data,
1895+
is_smooth=True,
1896+
is_symbol_show=True,
1897+
symbol="circle",
1898+
symbol_size=6,
1899+
linestyle_opts=opts.LineStyleOpts(color="#fff"),
1900+
label_opts=opts.LabelOpts(is_show=True, position="top", color="white"),
1901+
itemstyle_opts=opts.ItemStyleOpts(
1902+
color="red", border_color="#fff", border_width=3
1903+
),
1904+
tooltip_opts=opts.TooltipOpts(is_show=False),
1905+
areastyle_opts=opts.AreaStyleOpts(color=JsCode(area_color_js), opacity=1),
1906+
)
1907+
.set_global_opts(
1908+
title_opts=opts.TitleOpts(
1909+
title="OCTOBER 2015",
1910+
pos_bottom="5%",
1911+
pos_left="center",
1912+
title_textstyle_opts=opts.TextStyleOpts(color="#fff", font_size=16),
1913+
),
1914+
xaxis_opts=opts.AxisOpts(
1915+
type_="category",
1916+
boundary_gap=False,
1917+
axislabel_opts=opts.LabelOpts(margin=30, color="#ffffff63"),
1918+
axisline_opts=opts.AxisLineOpts(is_show=False),
1919+
axistick_opts=opts.AxisTickOpts(
1920+
is_show=True,
1921+
length=25,
1922+
linestyle_opts=opts.LineStyleOpts(color="#ffffff1f"),
1923+
),
1924+
splitline_opts=opts.SplitLineOpts(
1925+
is_show=True, linestyle_opts=opts.LineStyleOpts(color="#ffffff1f")
1926+
),
1927+
),
1928+
yaxis_opts=opts.AxisOpts(
1929+
type_="value",
1930+
position="right",
1931+
axislabel_opts=opts.LabelOpts(margin=20, color="#ffffff63"),
1932+
axisline_opts=opts.AxisLineOpts(
1933+
linestyle_opts=opts.LineStyleOpts(width=2, color="#fff")
1934+
),
1935+
axistick_opts=opts.AxisTickOpts(
1936+
is_show=True,
1937+
length=15,
1938+
linestyle_opts=opts.LineStyleOpts(color="#ffffff1f"),
1939+
),
1940+
splitline_opts=opts.SplitLineOpts(
1941+
is_show=True, linestyle_opts=opts.LineStyleOpts(color="#ffffff1f")
1942+
),
1943+
),
1944+
legend_opts=opts.LegendOpts(is_show=False),
1945+
)
1946+
)
1947+
return c
1948+
```
1949+
![](https://user-images.githubusercontent.com/17564655/68598066-09f9c680-04d9-11ea-9390-9d161c9228e8.png)
1950+
18351951

18361952
## PictorialBar:象形柱状图
18371953

zh-cn/render_images.md

+40-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
使用 pyecharts 渲染成图片一直是开发者比较关心的功能,pyecharts 提供了 `selenium` `phantomjs` 两种方式
1+
使用 pyecharts 渲染成图片一直是开发者比较关心的功能,pyecharts 提供了 `selenium`, `phantomjs` `pyppeteer` 三种方式
22

33
## make_snapshot
44

@@ -106,3 +106,42 @@ def bar_chart() -> Bar:
106106

107107
make_snapshot(snapshot, bar_chart().render(), "bar0.png")
108108
```
109+
110+
## snapshot-pyppeteer
111+
112+
### 安装
113+
114+
```shell
115+
$ pip install snapshot-pyppeteer
116+
117+
# 安装完后建议执行 chromium 安装命令
118+
pyppeteer-install
119+
```
120+
121+
[snapshot-pyppeteer](https://github.com/pyecharts/snapshot-pyppeteer) 是 pyecharts + pyppeteer 渲染图片的扩展,需要先安装 pyppeteer 和 Chromium 安装方法请参照仓库地址 [snapshot-pyppeteer](https://github.com/pyecharts/snapshot-pyppeteer)
122+
123+
### 使用
124+
125+
```python
126+
from snapshot_pyppeteer import snapshot
127+
128+
from pyecharts.charts import Bar
129+
from pyecharts.faker import Faker
130+
from pyecharts import options as opts
131+
from pyecharts.render import make_snapshot
132+
133+
134+
def bar_base() -> Bar:
135+
c = (
136+
Bar()
137+
.add_xaxis(Faker.choose())
138+
.add_yaxis("商家A", Faker.values())
139+
.add_yaxis("商家B", Faker.values())
140+
.set_global_opts(title_opts=opts.TitleOpts(title="Bar-基本示例", subtitle="我是副标题"))
141+
)
142+
make_snapshot(snapshot, c.render(), "bar.png")
143+
144+
145+
if __name__ == '__main__':
146+
bar_base()
147+
```

0 commit comments

Comments
 (0)