-
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.
fix(bidirection-bar): 修复对称条形图 label 位置设置和默认配置 (#2921)
* fix(bidirection-bar): 修复对称条形图 label 位置设置和默认配置 * refactor: 代码可读性优化 * fix: 修复 ts 错误
- Loading branch information
Showing
5 changed files
with
129 additions
and
11 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,37 @@ | ||
import { BidirectionalBar } from '@antv/g2plot'; | ||
|
||
export const data = [ | ||
{ country: '乌拉圭', '2016年耕地总面积': 13.4, '2016年转基因种植面积': 12.3 }, | ||
{ country: '巴拉圭', '2016年耕地总面积': 14.4, '2016年转基因种植面积': 6.3 }, | ||
{ country: '南非', '2016年耕地总面积': 18.4, '2016年转基因种植面积': 8.3 }, | ||
{ country: '巴基斯坦', '2016年耕地总面积': 34.4, '2016年转基因种植面积': 13.8 }, | ||
{ country: '阿根廷', '2016年耕地总面积': 44.4, '2016年转基因种植面积': 19.5 }, | ||
{ country: '巴西', '2016年耕地总面积': 24.4, '2016年转基因种植面积': 18.8 }, | ||
{ country: '加拿大', '2016年耕地总面积': 54.4, '2016年转基因种植面积': 24.7 }, | ||
{ country: '中国', '2016年耕地总面积': 104.4, '2016年转基因种植面积': 5.3 }, | ||
{ country: '美国', '2016年耕地总面积': 165.2, '2016年转基因种植面积': 72.9 }, | ||
]; | ||
|
||
const BidirectionalBarPlot = new BidirectionalBar('container', { | ||
data, | ||
xField: 'country', | ||
xAxis: { | ||
position: 'bottom', | ||
}, | ||
appendPadding: [0, 30], | ||
interactions: [{ type: 'active-region' }], | ||
yField: ['2016年耕地总面积', '2016年转基因种植面积'], | ||
tooltip: { | ||
shared: true, | ||
showMarkers: false, | ||
}, | ||
// 开启 label 展示 | ||
label: { | ||
// 默认居中, 'middle' | ||
position: 'right', | ||
// 默认为: 2 | ||
// offset: 4, | ||
}, | ||
}); | ||
|
||
BidirectionalBarPlot.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
34 changes: 34 additions & 0 deletions
34
examples/more-plots/bidirectional-bar/demo/vertical-label.ts
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,34 @@ | ||
import { BidirectionalBar } from '@antv/g2plot'; | ||
|
||
export const data = [ | ||
{ country: '乌拉圭', '2016年耕地总面积': 13.4, '2016年转基因种植面积': 12.3 }, | ||
{ country: '巴拉圭', '2016年耕地总面积': 14.4, '2016年转基因种植面积': 6.3 }, | ||
{ country: '南非', '2016年耕地总面积': 18.4, '2016年转基因种植面积': 8.3 }, | ||
{ country: '巴基斯坦', '2016年耕地总面积': 34.4, '2016年转基因种植面积': 13.8 }, | ||
{ country: '阿根廷', '2016年耕地总面积': 44.4, '2016年转基因种植面积': 19.5 }, | ||
{ country: '巴西', '2016年耕地总面积': 24.4, '2016年转基因种植面积': 18.8 }, | ||
{ country: '加拿大', '2016年耕地总面积': 54.4, '2016年转基因种植面积': 24.7 }, | ||
{ country: '中国', '2016年耕地总面积': 104.4, '2016年转基因种植面积': 5.3 }, | ||
{ country: '美国', '2016年耕地总面积': 165.2, '2016年转基因种植面积': 72.9 }, | ||
]; | ||
|
||
const BidirectionalBarPlot = new BidirectionalBar('container', { | ||
data, | ||
layout: 'vertical', | ||
xField: 'country', | ||
yField: ['2016年耕地总面积', '2016年转基因种植面积'], | ||
tooltip: { | ||
shared: true, | ||
showMarkers: false, | ||
}, | ||
appendPadding: [20, 0], | ||
// 开启 label 展示 | ||
label: { | ||
// 默认居中, 'middle' | ||
position: 'top', | ||
// 默认为: 2 | ||
// offset: 4, | ||
}, | ||
}); | ||
|
||
BidirectionalBarPlot.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