Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Chart.md #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions bizCharts/zh/api/bizcharts.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ G2 的命名空间,在有需要的情况下用户可以直接拿到该对象
BizCharts.track(false);
```

## PathUtil
来自 G2,用于操作图形路径的工具类。具体提供的方法如下
## DomUtil
用于操作 dom 相关的工具类。具体该工具类包含的方法如下

| 方法 | 参数说明 | 返回结果 |
| ----------------------------------------------- | ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
Expand All @@ -82,6 +82,33 @@ BizCharts.track(false);
| `addEventListener(target, eventType, callback)` | `target`:HTMLElement,DOM对象;`eventType`:String,事件名;`callback`:Function,回调函数 | 添加事件监听器 |
| `requestAnimationFrame(fn)` | `fn`:Function,回调函数 | 用于定时循环操作。 |

## MatrixUtil
来自 G2,用于操作矩阵、向量的工具类。该工具类提供了操作三阶矩阵、二维向量和三维向量的方法,这些方法直接使用了 glMatrix 库,并且在其基础上添加了一些额外的遍历方法,具体如下代码:
1. G2.MatrixUtil.mat3: 三阶矩阵,详见 http://glmatrix.net/docs/module-mat3.html;
2. G2.MatrixUtil.vec2: 二维向量,详见 http://glmatrix.net/docs/module-vec2.html;
3. G2.MatrixUtil.vec3: 三维向量,详见 http://glmatrix.net/docs/module-vec3.html;
4. G2.MatrixUtil.transform(m, ts): 对三阶矩阵参数 m 按照 ts 进行变换,变换包含 t: translate,s: scale,r: rotate,m: multiply,具体使用如下:
```js
import {Util} from 'bizcharts';
Util.MatrixUtil.transform([ 1, 0, 0, 0, 1, 0, 0, 0, 1 ], [
[ 'r', Math.PI / 2 ],
[ 't', 10, 10 ],
[ 'r', -1 * Math.PI / 2 ]
]);
```

## PathUtil
来自 G2,用于操作图形路径的工具类。具体提供的方法如下:

| 方法 | 参数说明 | 返回结果 |
| ----------------------------------------------- | ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| `parsePathString(pathString)` | `pathString`:String,字符串格式的路径,如 'M 10,39 L 20,50' | 将字符串格式的路径转换为数组格式,[ [ 'M', 10, 39 ], [ 'L', 20, 50 ] ] |
| `parsePathArray(pathArray)` | `pathArray`:Array,数组格式的路径,如 [ [ 'M', 10, 39 ], [ 'L', 20, 50 ] ] | 将数组格式的路径转化为字符串,'M 10,39 L 20,50' |
| `pathTocurve(path)` | `dom`:Array,数组格式的路径 | 路径转曲 |
| `pathToAbsolute(path)` | `str`:Array,数组格式的路径 | 将所有的路径命令转换为绝对定位。 |
| `catmullRomToBezier(pointsArray)` | `str`:Array,点的数组,如 [ 10, 12, 22, 1, ... ] | 将传入的点(至少四组点)转曲。 |
| `intersection(path1, path2)` | `path1`:Array,数组格式的路径;`path2`:Array,数组格式的路径; | 两条路径差值计算。 |

## Util
默认提供的常见的工具类,大部分基于 lodash 封装。
如下:
Expand Down