-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add documents for kde and density
- Loading branch information
Showing
7 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: kde | ||
order: 1 | ||
--- | ||
|
||
<embed src="@/docs/spec/data/kde.zh.md"></embed> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
title: kde | ||
order: 1 | ||
--- | ||
|
||
对指定的数据,进行核密度算法(Kernel Density Estimation)处理,底层使用开源库 [pdfast](https://www.npmjs.com/package/pdfast)。 | ||
|
||
## 开始使用 | ||
|
||
```ts | ||
chart.data({ | ||
type: 'inline', | ||
value: data, | ||
transform: [ | ||
{ | ||
type: 'kde', | ||
field: 'y', | ||
groupBy: ['x', 'species'], | ||
as: ['y', 'size'], | ||
}, | ||
], | ||
}); | ||
``` | ||
|
||
上述例子处理之后,数据会增加 y、size 字段,均为数字数组。 | ||
|
||
## 选项 | ||
|
||
| 属性 | 描述 | 类型 | 默认值 | | ||
| -------- | -------------------------------------------------- | ---------------------------- | ------------- | | ||
| field | 进行核密度算法的数据字段 | `string` | | | ||
| groupBy | 对数据进行分组的分组字段,可以指定多个 | `string[]` | | | ||
| as | 进行 KDE 处理之后,存储的字段 | `[number, number]` | `['y', 'size']` | | ||
| min | 指定处理范围的最小值 | `number` | 数据最小值 | | ||
| max | 指定处理范围的最大值 | `number` | 数据最小值 | | ||
| size | 算法最终生成数据的条数 | `number` | `10` | | ||
| width | 确定一个元素左右影响多少点,类似于 bandWidth。 | `number` | `2` | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: density | ||
order: 1 | ||
--- | ||
|
||
<embed src="@/docs/spec/mark/density.zh.md"></embed> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
title: density | ||
order: 1 | ||
--- | ||
|
||
接受核密度数据,一般用于用于绘制小提琴图。 | ||
|
||
## 开始使用 | ||
|
||
<img alt="density" src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*S6O8QqpcRPMAAAAAAAAAAAAADmJ7AQ/original" width="600" /> | ||
|
||
```js | ||
import { Chart } from '@antv/g2'; | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
theme: 'classic', | ||
autoFit: true, | ||
}); | ||
|
||
chart.data({ | ||
type: 'fetch', | ||
value: 'https://assets.antv.antgroup.com/g2/species.json', | ||
transform: [ | ||
{ | ||
type: 'kde', | ||
field: 'y', | ||
groupBy: ['x'], | ||
size: 20, | ||
}, | ||
], | ||
}); | ||
|
||
chart | ||
.density() | ||
.encode('x', 'x') | ||
.encode('y', 'y') | ||
.encode('color', 'x') | ||
.encode('size', 'size') | ||
.tooltip(false); | ||
|
||
chart.render(); | ||
|
||
``` | ||
|
||
## 选项 | ||
|
||
|
||
| 属性 | 描述 | 类型 | 默认值 | | ||
| -------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- | ------------------------------ | | ||
| fill | 图形的填充色 | `string` \| `Function<string>` | - | | ||
| fillOpacity | 图形的填充透明度 | `number` \| `Function<number>` | - | | ||
| stroke | 图形的描边 | `string` \| `Function<string>` | - | | ||
| strokeOpacity | 描边透明度 | `number` \| `Function<number>` | - | | ||
| lineWidth | 图形描边的宽度 | `number` \| `Function<number>` | - | | ||
| lineDash | 描边的虚线配置,第一个值为虚线每个分段的长度,第二个值为分段间隔的距离。lineDash 设为[0, 0]的效果为没有描边。 | `[number,number]` \| `Function<[number, number]>` | - | | ||
| opacity | 图形的整体透明度 | `number` \| `Function<number>` | - | | ||
| shadowColor | 图形阴影颜色 | `string` \| `Function<string>` | - | | ||
| shadowBlur | 图形阴影的高斯模糊系数 | `number` \| `Function<number>` | - | | ||
| shadowOffsetX | 设置阴影距图形的水平距离 | `number` \| `Function<number>` | - | | ||
| shadowOffsetY | 设置阴影距图形的垂直距离 | `number` \| `Function<number>` | - | | ||
| cursor | 鼠标样式。同 css 的鼠标样式,默认 'default'。 | `string` \| `Function<string>` | 'default' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters