-
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.
feat: add thresholds params in gauge mark (#5021)
- Loading branch information
1 parent
88d0e02
commit 66a4a8e
Showing
7 changed files
with
108 additions
and
66 deletions.
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: gauge | ||
order: 1 | ||
--- | ||
|
||
<embed src="@/docs/spec/mark/gauge.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,57 @@ | ||
--- | ||
title: gauge | ||
order: 1 | ||
--- | ||
|
||
仪表盘 | ||
|
||
## 开始使用 | ||
|
||
<img alt="wordCloud" src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*hpjTRr6LM7IAAAAAAAAAAAAADmJ7AQ/original | ||
" width="600" /> | ||
|
||
```js | ||
import { Chart } from '@antv/g2'; | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
theme: 'classic', | ||
autoFit: true, | ||
}); | ||
|
||
chart | ||
.gauge() | ||
.data({ | ||
value: { | ||
target: 120, | ||
total: 400, | ||
name: 'score', | ||
}, | ||
}) | ||
.legend(false); | ||
|
||
chart.render(); | ||
``` | ||
|
||
## 选项 | ||
|
||
| 属性 | 描述 | 类型 | 默认值 | | ||
| ------ | ------------------------ | ----------- | ------ | | ||
| data | 数据 | `GaugeData` | - | | ||
| style | 配置图形样式和标签样式 | - | - | | ||
| labels | 自定义节点数据标签的配置 | `label[]` | `[]` | | ||
|
||
## data | ||
|
||
| 属性 | 描述 | 类型 | 默认值 | | ||
| ---------- | -------- | ---------- | ------ | | ||
| target | 目标值 | `number` | - | | ||
| total | 总计值 | `number` | - | | ||
| percent | 百分比 | `number` | - | | ||
| thresholds | 阈值区间 | `number[]` | - | | ||
|
||
## style | ||
|
||
复合图形标记需要通过不同的前缀来区分图形的配置。 | ||
|
||
- `<label>`: 数据标签的前缀,例如:`labelText` 设置标签的 text 文本。 |
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,28 @@ | ||
import { Chart } from '@antv/g2'; | ||
|
||
const chart = new Chart({ | ||
container: 'container', | ||
theme: 'classic', | ||
autoFit: true, | ||
}); | ||
|
||
chart | ||
.gauge() | ||
.data({ | ||
value: { | ||
target: 159, | ||
total: 400, | ||
name: 'score', | ||
thresholds: [100, 200, 400], | ||
}, | ||
}) | ||
.scale('color', { | ||
range: ['#F4664A', '#FAAD14', 'green'], | ||
}) | ||
.style( | ||
'textContent', | ||
(target, total) => `得分:${target}\n占比:${(target / total) * 100}%`, | ||
) | ||
.legend(false); | ||
|
||
chart.render(); |
This file was deleted.
Oops, something went wrong.
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