-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
119 additions
and
5 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,25 @@ | ||
--- | ||
title: API | ||
--- | ||
|
||
#### Usage | ||
|
||
There are two ways to configure labels | ||
|
||
Method 1, pass in 'Boolean' to set whether to display a label. | ||
|
||
```ts | ||
label: false; // close label | ||
``` | ||
|
||
Method 2, pass in _LegendCfg_ to configure the label as a whole. | ||
|
||
```ts | ||
label: { | ||
content: '标签' | ||
} | ||
``` | ||
|
||
#### Properties | ||
|
||
`markdown:docs/common/label.en.md` |
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,26 @@ | ||
--- | ||
title: API | ||
--- | ||
|
||
#### 使用方式 | ||
|
||
配置数据标签有两种方式: | ||
|
||
第一种,传入 `boolean` 设置是否显示数据标签。 | ||
|
||
```ts | ||
label: false; // 关闭数据标签 | ||
``` | ||
|
||
第二种,传入 _LabelCfg_ 对数据标签进行整体配置。 | ||
|
||
```ts | ||
label: { | ||
layout: 'horizontal', | ||
position: 'right' | ||
} | ||
``` | ||
|
||
#### 配置属性 | ||
|
||
`markdown:docs/common/label.zh.md` |
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,51 @@ | ||
import { Pie, G2 } from '@antv/g2plot'; | ||
|
||
const G = G2.getEngine('canvas'); | ||
|
||
const data = [ | ||
{ sex: '男', sold: 0.45 }, | ||
{ sex: '女', sold: 0.55 }, | ||
]; | ||
|
||
const piePlot = new Pie('container', { | ||
appendPadding: 10, | ||
data, | ||
angleField: 'sold', | ||
colorField: 'sex', | ||
radius: 0.66, | ||
color: ['#1890ff', '#f04864'], | ||
label: { | ||
content: (obj) => { | ||
const group = new G.Group({}); | ||
group.addShape({ | ||
type: 'image', | ||
attrs: { | ||
x: 0, | ||
y: 0, | ||
width: 40, | ||
height: 50, | ||
img: | ||
obj.sex === '男' | ||
? 'https://gw.alipayobjects.com/zos/rmsportal/oeCxrAewtedMBYOETCln.png' | ||
: 'https://gw.alipayobjects.com/zos/rmsportal/mweUsJpBWucJRixSfWVP.png', | ||
}, | ||
}); | ||
|
||
group.addShape({ | ||
type: 'text', | ||
attrs: { | ||
x: 20, | ||
y: 54, | ||
text: obj.sex, | ||
textAlign: 'center', | ||
textBaseline: 'top', | ||
fill: obj.sex === '男' ? '#1890ff' : '#f04864', | ||
}, | ||
}); | ||
return group; | ||
}, | ||
}, | ||
interactions: [{ type: 'element-active' }], | ||
}); | ||
|
||
piePlot.render(); |
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,17 @@ | ||
{ | ||
"title": { | ||
"zh": "中文分类", | ||
"en": "Category" | ||
}, | ||
"demos": [ | ||
{ | ||
"filename": "custom-label.ts", | ||
"title": { | ||
"zh": "自定义数据标签", | ||
"en": "Custom Label" | ||
}, | ||
"new": true, | ||
"screenshot": "https://gw.alipayobjects.com/zos/antfincdn/P7ARYNBdol/3988b5ab-b286-4b2c-befa-eac77afd5bac.png" | ||
} | ||
] | ||
} |
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