-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 饼图支持配置坐标系 startAngle 和 endAngle (#2164)
* feat(pie): 饼图支持设置坐标系起始角度和结束角度 * docs(demo): 增加四分之一圆的demo & 调整饼图 demo * test: 添加饼图startAngle & endAngle的单测 * docs: 添加饼图 startAngle & endAngle 的 api 文档 * docs(demo): 移除多余的 demo & 添加 demo 截图
- Loading branch information
Showing
10 changed files
with
114 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Pie } from '../../../../src'; | ||
import { POSITIVE_NEGATIVE_DATA } from '../../../data/common'; | ||
import { createDiv } from '../../../utils/dom'; | ||
|
||
describe('pie', () => { | ||
it('set startAngle & endAngle', () => { | ||
const pie = new Pie(createDiv(), { | ||
width: 400, | ||
height: 300, | ||
data: POSITIVE_NEGATIVE_DATA, | ||
angleField: 'value', | ||
colorField: 'type', | ||
radius: 0.8, | ||
startAngle: 0, | ||
endAngle: Math.PI, | ||
}); | ||
|
||
pie.render(); | ||
|
||
const coodinate = pie.chart.getCoordinate(); | ||
expect(coodinate.startAngle).toBe(0); | ||
expect(coodinate.endAngle).toBe(Math.PI); | ||
|
||
pie.destroy(); | ||
}); | ||
}); |
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
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Pie } from '@antv/g2plot'; | ||
|
||
const data = [ | ||
{ type: '分类一', value: 27 }, | ||
{ type: '分类二', value: 25 }, | ||
{ type: '分类三', value: 18 }, | ||
{ type: '分类四', value: 15 }, | ||
{ type: '分类五', value: 10 }, | ||
{ type: '其他', value: 5 }, | ||
]; | ||
|
||
const piePlot = new Pie('container', { | ||
appendPadding: 10, | ||
data, | ||
angleField: 'value', | ||
colorField: 'type', | ||
radius: 1, | ||
// 设置圆弧起始角度 | ||
startAngle: Math.PI, | ||
endAngle: Math.PI * 1.5, | ||
label: { | ||
type: 'inner', | ||
offset: '-8%', | ||
content: '{name}', | ||
style: { fontSize: 18 }, | ||
}, | ||
interactions: [{ type: 'element-active' }], | ||
pieStyle: { | ||
lineWidth: 0, | ||
}, | ||
}); | ||
|
||
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
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
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