Skip to content

Commit

Permalink
docs: 增加 meta options 的配置说明文档 & radar demo 移除数据处理逻辑 (#2182)
Browse files Browse the repository at this point in the history
* docs(events): 修改事件相关的文档

* docs(meta): 添加 meta 的配置项文档

* docs(api): 调整 api 文档页导航顺序

* docs(meta): 调整 meta options 文档的内容

* docs(faq): 添加双轴图共享 y 轴的 faq 文档

* docs(style): 调整下文档的样式

* docs(demo): 更新 radar demo,移除数据处理

* docs(badge): 添加 open issue & issue resolution 的 badge
  • Loading branch information
visiky authored Jan 7, 2021
1 parent 921deb6 commit d7c09ca
Show file tree
Hide file tree
Showing 30 changed files with 298 additions and 173 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ A charting library based on the Grammar of Graphics.
![Latest commit](https://badgen.net/github/last-commit/antvis/G2Plot)
[![build Status](https://github.com/antvis/G2Plot/workflows/build/badge.svg?branch=master)](https://github.com/antvis/G2Plot/actions?query=workflow%3Abuild)
[![coverage](https://img.shields.io/coveralls/antvis/G2Plot/master.svg)](https://coveralls.io/github/antvis/G2Plot)
[![Percentage of issues still open](http://isitmaintained.com/badge/open/antvis/g2plot.svg)](http://isitmaintained.com/project/antvis/g2plot "Percentage of issues still open")
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/antvis/g2plot.svg)](http://isitmaintained.com/project/antvis/g2plot "Average time to resolve an issue")

</div>

Expand Down
2 changes: 2 additions & 0 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
![Latest commit](https://badgen.net/github/last-commit/antvis/G2Plot)
[![build Status](https://github.com/antvis/G2Plot/workflows/build/badge.svg?branch=master)](https://github.com/antvis/G2Plot/actions?query=workflow%3Abuild)
[![coverage](https://img.shields.io/coveralls/antvis/G2Plot/master.svg)](https://coveralls.io/github/antvis/G2Plot)
[![Percentage of issues still open](http://isitmaintained.com/badge/open/antvis/g2plot.svg)](http://isitmaintained.com/project/antvis/g2plot "Percentage of issues still open")
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/antvis/g2plot.svg)](http://isitmaintained.com/project/antvis/g2plot "Average time to resolve an issue")

</div>

Expand Down
2 changes: 1 addition & 1 deletion docs/api/events.en.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Events
order: 4
order: 6
---

`markdown:docs/common/events.en.md`
2 changes: 1 addition & 1 deletion docs/api/events.zh.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 图表事件
order: 4
order: 6
---

`markdown:docs/common/events.zh.md`
2 changes: 1 addition & 1 deletion docs/api/graphic-style.en.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Graphic Style
order: 6
order: 9
---

G2Plot uses [G](https://github.com/antvis/g) as the drawing engine. Some graphic styles, such as the `lineStyle` of Line, the `columnStyle` of Column, and the style configuration of some components, such as `label.style`, `axis.line.style`, are all transmitted transparently through the drawing properties of G.
Expand Down
2 changes: 1 addition & 1 deletion docs/api/graphic-style.zh.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 绘图属性
order: 6
order: 9
---

G2Plot 使用 [G](https://github.com/antvis/g) 作为绘图引擎,一些图形的样式配置,如折线图的`lineStyle`,柱状图的`columnStyle`等,还有部分组件的样式配置,如`label.style``axis.line.style`等,都是直接透传 G 的绘图属性。
Expand Down
2 changes: 1 addition & 1 deletion docs/api/interactions.en.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Interactions
order: 4
order: 7
---

`markdown:docs/common/interactions.en.md`
2 changes: 1 addition & 1 deletion docs/api/interactions.zh.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 图表交互
order: 4
order: 7
---

`markdown:docs/common/interactions.zh.md`
2 changes: 1 addition & 1 deletion docs/api/multi-view.en.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Multi-View
order: 7
order: 11
---

`markdown:docs/api/multi-view.zh.md`
2 changes: 1 addition & 1 deletion docs/api/multi-view.zh.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 多图层图表
order: 7
order: 11
---

目前处于 `beta` 阶段,详细文档即将到来...
6 changes: 6 additions & 0 deletions docs/api/options/meta.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Meta
order: 1
---

`markdown:docs/api/options/meta.zh.md`
179 changes: 179 additions & 0 deletions docs/api/options/meta.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
---
title: Meta
order: 1
---

通过 `meta` 可以全局化配置图表数据元信息,以字段为单位进行配置。在 `meta` 上的配置将同时影响所有组件的文本信息。

## 配置方式

传入以字段名为 key,_MetaOption_ 为 value 的配置,同时设置多个字段的元信息。

```sign
{
meta: {
[field: string]: MetaOption
}
}
```

Example:

```ts
{
meta: {
sale: {
min: 0,
max: 100,
},
}
}
```

## 细分配置项

_MetaOption_ 配置如下:

### MetaOption.type

<description> _string_ **optional**</description>

声明度量类型:

| 度量类型 | 描述 |
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 分类度量 | - cat: 分类度量 <br /> - timeCat: 时间分类度量 |
| 连续度量 | - linear: 线性度量 <br /> - time:连续的时间度量 <br /> - log: log 度量 <br /> - pow: pow 度量 <br /> - quantize:分段度量,用户可以指定不均匀的分段 <br /> - quantile: 等分度量,根据数据的分布自动计算分段 <br /> |
| 常量度量 | - identity: 常量度量
### MetaOption.alias

<description> _string_ **optional**</description>

数据字段的显示别名,scale 内部不感知,外部注入。

### MetaOption.values

<description> _any[]_ **optional**</description>

输入域、定义域。

### MetaOption.formatter

<description> _(v: any, k?: number) => any_ **optional**</description>

tick 格式化函数,会影响数据在坐标轴 axis、图例 legend、tooltip 上的显示。

### MetaOption.range

<description> _[number, number]_ **optional** _default:_ `[0, 1]`</description>

输出域、值域,表示在绘图范围内可用于绘制的范围。

### MetaOption.sync

<description> _boolean | string_ **optional**</description>

```ts
{
meta: {
{
x: { sync: true },
y: { sync: true },
x1: { sync: 'x1' },
x2: { sync: 'x1' },
}
}
}
```

同步 scale。sync: `boolean` 即为 sync: \[key\],如上例中 `x: { sync: true }` 等同于 `x: { sync: 'x' }``y: { sync: true }` 等同于 `y: { sync: 'y' }`,所以,通过以上配置,会分别对 x 和 y 两个字段,x1 和 x2 两个字段进行同步度量操作。

### MetaOption.min

<description> _any_ **optional**</description>

定义域的最小值,d3 为 domain,ggplot2 为 limits,分类型下无效。

### MetaOption.max

<description> _any_ **optional**</description>

定义域的最大值,分类型下无效。

### MetaOption.minLimit

<description> _any_ **optional**</description>

严格模式下的定义域最小值,设置后会强制 ticks 从最小值开始。

### MetaOption.maxLimit

<description> _any_ **optional**</description>

严格模式下的定义域最大值,设置后会强制 ticks 以最大值结束。

### MetaOption.base

<description> _number_ **optional**</description>

log 有效,底数。

### MetaOption.exponent

<description> _number_ **optional**</description>

pow 有效,指数。

### MetaOption.nice

<description> _boolean_ **optional**</description>

自动调整 min、max 。

### MetaOption.ticks

<description> _any[]_ **optional**</description>

用于指定 tick,优先级最高。

### MetaOption.tickInterval

<description> _number_ **optional**</description>

tick 间隔,只对分类型和时间型适用,优先级高于 tickCount。

### MetaOption.minTickInterval

<description> _number_ **optional**</description>

tick 最小间隔,只对 linear 适用。

### MetaOption.tickCount

<description> _number_ **optional** _default:_ `5`</description>

tick 个数。

### MetaOption.maxTickCount

<description> _number_ **optional** _default:_ `10`</description>

ticks 最大值。

### MetaOption.tickMethod

<description> _string | TickMethod_ **optional**</description>

计算 ticks 的算法。

### MetaOption.showLast

<description> _boolean_ **optional**</description>

只对 type: 'time' 的 scale 生效,强制显示最后的日期 tick。

### MetaOption.mask

<description> _string_ **optional**</description>

时间度量 time, timeCat 时有效。底层使用 [fecha](https://github.com/taylorhakes/fecha#formatting-tokens) 进行日期的格式,所以对于 mask 的字符串可以直接参考其写法。
2 changes: 1 addition & 1 deletion docs/api/theme.en.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Theme
order: 5
order: 8
---

`markdown:docs/common/theme.en.md`
2 changes: 1 addition & 1 deletion docs/api/theme.zh.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 图表主题
order: 5
order: 8
---

`markdown:docs/common/theme.zh.md`
59 changes: 1 addition & 58 deletions docs/common/events.en.md
Original file line number Diff line number Diff line change
@@ -1,58 +1 @@
在 Chart 和 View 上通过 on 绑定事件、off 移除绑定事件。

```ts
// 绑定事件
chart.on('eventName', callback);
// 移除事件
chart.off('eventName', callback);
```

#### eventName

组成方式:element + ':' + events。

element 指要绑定的元素类型,例如 `element``legend-item``axis-label``mask``plot``legend-item-name``reset-button` 等。

events 对应 DOM 常见事件,例如 `click``mousedown``mouseup``dblclick``mouseenter``mouseout``mouseover``mousemove``mouseleave``contextmenu` 等,同时支持几个移动端事件:`touchstart``touchmove``touchend`

```ts
// plot添加点击事件,整个图表区域
chart.on('plot:click', (...args) => {
console.log(...args);
});

// element 添加点击事件, element 代指 label|point 等
chart.on('element:click', (...args) => {
console.log(...args);
});

// 图例添加点击事件
chart.on('legend-item:click', (...args) => {
console.log(...args);
});

// 图例名称添加点击事件
chart.on('legend-item-name:click', (...args) => {
console.log(...args);
});

// label 添加点击事件
chart.on('label:click', (...args) => {
console.log(...args);
});

// mask 添加点击事件
chart.on('mask:click', (...args) => {
console.log(...args);
});

// axis-label 添加点击事件
chart.on('axis-label:click', (...args) => {
console.log(...args);
});

// 给 annotation 添加点击事件
chart.on('annotation:click', (...args) => {
console.log(...args);
});
```
`markdown:docs/common/events.zh.md`
Loading

0 comments on commit d7c09ca

Please sign in to comment.