-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 柱条形图支持组间和组内padding的像素级设置 (#2539)
* feat: 柱条形图支持组间和组内padding的像素级设置 * fix: 修复 lint 问题
- Loading branch information
Showing
19 changed files
with
363 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
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
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,78 @@ | ||
import { Bar } from '@antv/g2plot'; | ||
|
||
const data = [ | ||
{ | ||
label: 'Mon.', | ||
type: 'series1', | ||
value: 2800, | ||
}, | ||
{ | ||
label: 'Mon.', | ||
type: 'series2', | ||
value: 2260, | ||
}, | ||
{ | ||
label: 'Tues.', | ||
type: 'series1', | ||
value: 1800, | ||
}, | ||
{ | ||
label: 'Tues.', | ||
type: 'series2', | ||
value: 1300, | ||
}, | ||
{ | ||
label: 'Wed.', | ||
type: 'series1', | ||
value: 950, | ||
}, | ||
{ | ||
label: 'Wed.', | ||
type: 'series2', | ||
value: 900, | ||
}, | ||
{ | ||
label: 'Thur.', | ||
type: 'series1', | ||
value: 500, | ||
}, | ||
{ | ||
label: 'Thur.', | ||
type: 'series2', | ||
value: 390, | ||
}, | ||
{ | ||
label: 'Fri.', | ||
type: 'series1', | ||
value: 170, | ||
}, | ||
{ | ||
label: 'Fri.', | ||
type: 'series2', | ||
value: 100, | ||
}, | ||
]; | ||
|
||
const stackedBarPlot = new Bar('container', { | ||
data, | ||
isGroup: true, | ||
xField: 'value', | ||
yField: 'label', | ||
seriesField: 'type', | ||
dodgePadding: 4, | ||
label: { | ||
// 可手动配置 label 数据标签位置 | ||
position: 'middle', // 'left', 'middle', 'right' | ||
// 可配置附加的布局方法 | ||
layout: [ | ||
// 柱形图数据标签位置自动调整 | ||
{ type: 'interval-adjust-position' }, | ||
// 数据标签防遮挡 | ||
{ type: 'interval-hide-overlap' }, | ||
// 数据标签文颜色自动调整 | ||
{ type: 'adjust-color' }, | ||
], | ||
}, | ||
}); | ||
|
||
stackedBarPlot.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,79 @@ | ||
import { Bar } from '@antv/g2plot'; | ||
|
||
const data = [ | ||
{ | ||
label: 'Mon.', | ||
type: 'series1', | ||
value: 2800, | ||
}, | ||
{ | ||
label: 'Mon.', | ||
type: 'series2', | ||
value: 2260, | ||
}, | ||
{ | ||
label: 'Tues.', | ||
type: 'series1', | ||
value: 1800, | ||
}, | ||
{ | ||
label: 'Tues.', | ||
type: 'series2', | ||
value: 1300, | ||
}, | ||
{ | ||
label: 'Wed.', | ||
type: 'series1', | ||
value: 950, | ||
}, | ||
{ | ||
label: 'Wed.', | ||
type: 'series2', | ||
value: 900, | ||
}, | ||
{ | ||
label: 'Thur.', | ||
type: 'series1', | ||
value: 500, | ||
}, | ||
{ | ||
label: 'Thur.', | ||
type: 'series2', | ||
value: 390, | ||
}, | ||
{ | ||
label: 'Fri.', | ||
type: 'series1', | ||
value: 170, | ||
}, | ||
{ | ||
label: 'Fri.', | ||
type: 'series2', | ||
value: 100, | ||
}, | ||
]; | ||
|
||
const stackedBarPlot = new Bar('container', { | ||
data, | ||
isGroup: true, | ||
xField: 'value', | ||
yField: 'label', | ||
seriesField: 'type', | ||
dodgePadding: 4, | ||
intervalPadding: 20, | ||
label: { | ||
// 可手动配置 label 数据标签位置 | ||
position: 'middle', // 'left', 'middle', 'right' | ||
// 可配置附加的布局方法 | ||
layout: [ | ||
// 柱形图数据标签位置自动调整 | ||
{ type: 'interval-adjust-position' }, | ||
// 数据标签防遮挡 | ||
{ type: 'interval-hide-overlap' }, | ||
// 数据标签文颜色自动调整 | ||
{ type: 'adjust-color' }, | ||
], | ||
}, | ||
}); | ||
|
||
stackedBarPlot.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Column } from '@antv/g2plot'; | ||
|
||
fetch('https://gw.alipayobjects.com/os/antfincdn/iPY8JFnxdb/dodge-padding.json') | ||
.then((data) => data.json()) | ||
.then((data) => { | ||
const plot = new Column('container', { | ||
data, | ||
isGroup: true, | ||
xField: '月份', | ||
yField: '月均降雨量', | ||
seriesField: 'name', | ||
// 分组柱状图 组内柱子间的间距 (像素级别) | ||
dodgePadding: 2, | ||
label: { | ||
// 可手动配置 label 数据标签位置 | ||
position: 'middle', // 'top', 'middle', 'bottom' | ||
// 可配置附加的布局方法 | ||
layout: [ | ||
// 柱形图数据标签位置自动调整 | ||
{ type: 'interval-adjust-position' }, | ||
// 数据标签防遮挡 | ||
{ type: 'interval-hide-overlap' }, | ||
// 数据标签文颜色自动调整 | ||
{ type: 'adjust-color' }, | ||
], | ||
}, | ||
}); | ||
|
||
plot.render(); | ||
}); |
Oops, something went wrong.