Skip to content

Commit b8e6a4b

Browse files
lxfu1liufu.lf
and
liufu.lf
authored
docs: 通用文档补充 (#1561)
Co-authored-by: liufu.lf <[email protected]>
1 parent 79606f7 commit b8e6a4b

26 files changed

+1810
-186
lines changed

docs/common/color.en.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#### color
2+
3+
**可选**, _string | string[] | Function_
4+
5+
功能描述: 指定点的颜色。如没有配置 colorField,指定一个单值即可。对 colorFiled 进行了配置的情况下,即可以指定一系列色值,也可以通过回调函数的方法根据对应数值进行设置。
6+
7+
默认配置:采用 theme 中的色板。
8+
9+
```ts
10+
// 设置单一颜色
11+
{
12+
color: '#a8ddb5'
13+
}
14+
// 设置多色
15+
{
16+
colorField: 'type',
17+
color: ['#d62728', '#2ca02c', '#000000'],
18+
}
19+
// Function
20+
{
21+
colorField: 'type',
22+
color: (type) => {
23+
if(type === 'male'){
24+
return 'red';
25+
}
26+
// TODO
27+
return 'yellow';
28+
}
29+
}
30+
```

docs/common/color.zh.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#### color
2+
3+
**可选**, _string | string[] | Function_
4+
5+
功能描述: 指定点的颜色。如没有配置 colorField,指定一个单值即可。对 colorFiled 进行了配置的情况下,即可以指定一系列色值,也可以通过回调函数的方法根据对应数值进行设置。
6+
7+
默认配置:采用 theme 中的色板。
8+
9+
```ts
10+
// 设置单一颜色
11+
{
12+
color: '#a8ddb5'
13+
}
14+
// 设置多色
15+
{
16+
colorField: 'type',
17+
color: ['#d62728', '#2ca02c', '#000000'],
18+
}
19+
// Function
20+
{
21+
colorField: 'type',
22+
color: (type) => {
23+
if(type === 'male'){
24+
return 'red';
25+
}
26+
// TODO
27+
return 'yellow';
28+
}
29+
}
30+
```

docs/common/events.en.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
在 Chart 和 View 上通过 on 绑定事件、off 移除绑定事件。
2+
3+
```ts
4+
// 绑定事件
5+
chart.on('eventName', callback);
6+
// 移除事件
7+
chart.off('eventName', callback);
8+
```
9+
10+
#### eventName
11+
12+
组成方式:element + ':' + events 。
13+
14+
element 指要绑定的元素类型,例如 `element``legend-item``axis-label``mask``plot``legend-item-name``reset-button` 等。
15+
16+
events 对应 DOM 常见事件,例如 `click``mousedown``mouseup``dblclick``mouseenter``mouseout``mouseover``mousemove``mouseleave``contextmenu` 等,同时支持几个移动端事件:`touchstart``touchmove``touchend`
17+
18+
```ts
19+
// plot添加点击事件,整个图表区域
20+
chart.on('plot:click', (...args) => {
21+
console.log(...args);
22+
});
23+
24+
// element 添加点击事件, element 代指 label|point 等
25+
chart.on('element:click', (...args) => {
26+
console.log(...args);
27+
});
28+
29+
// 图例添加点击事件
30+
chart.on('legend-item:click', (...args) => {
31+
console.log(...args);
32+
});
33+
34+
// 图例名称添加点击事件
35+
chart.on('legend-item-name:click', (...args) => {
36+
console.log(...args);
37+
});
38+
39+
// label 添加点击事件
40+
chart.on('label:click', (...args) => {
41+
console.log(...args);
42+
});
43+
44+
// mask 添加点击事件
45+
chart.on('mask:click', (...args) => {
46+
console.log(...args);
47+
});
48+
49+
// axis-label 添加点击事件
50+
chart.on('axis-label:click', (...args) => {
51+
console.log(...args);
52+
});
53+
```

docs/common/events.zh.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
在 Chart 和 View 上通过 on 绑定事件、off 移除绑定事件。
2+
3+
```ts
4+
// 绑定事件
5+
chart.on('eventName', callback);
6+
// 移除事件
7+
chart.off('eventName', callback);
8+
```
9+
10+
#### eventName
11+
12+
组成方式:element + ':' + events 。
13+
14+
element 指要绑定的元素类型,例如 `element``legend-item``axis-label``mask``plot``legend-item-name``reset-button` 等。
15+
16+
events 对应 DOM 常见事件,例如 `click``mousedown``mouseup``dblclick``mouseenter``mouseout``mouseover``mousemove``mouseleave``contextmenu` 等,同时支持几个移动端事件:`touchstart``touchmove``touchend`
17+
18+
```ts
19+
// plot添加点击事件,整个图表区域
20+
chart.on('plot:click', (...args) => {
21+
console.log(...args);
22+
});
23+
24+
// element 添加点击事件, element 代指 label|point 等
25+
chart.on('element:click', (...args) => {
26+
console.log(...args);
27+
});
28+
29+
// 图例添加点击事件
30+
chart.on('legend-item:click', (...args) => {
31+
console.log(...args);
32+
});
33+
34+
// 图例名称添加点击事件
35+
chart.on('legend-item-name:click', (...args) => {
36+
console.log(...args);
37+
});
38+
39+
// label 添加点击事件
40+
chart.on('label:click', (...args) => {
41+
console.log(...args);
42+
});
43+
44+
// mask 添加点击事件
45+
chart.on('mask:click', (...args) => {
46+
console.log(...args);
47+
});
48+
49+
// axis-label 添加点击事件
50+
chart.on('axis-label:click', (...args) => {
51+
console.log(...args);
52+
});
53+
```

0 commit comments

Comments
 (0)