antvis/G2




The issue has been closed
【v5】shape 通道指定后,legend 位置设置失效 #5015
Deathsteps posted onGitHub
问题描述
<img width="1149" alt="image" src="https://github.com/antvis/G2/assets/1549118/7bd0f4f3-f661-468d-a484-293e33b21b59"> <img width="1086" alt="image" src="https://github.com/antvis/G2/assets/1549118/ebc3af6a-e01f-4a62-b0b6-70d084069b0d">
期望结果
shape encode 不影响图例位置设置
如何重现
官方示例修改
/**
* A recreation of this demo: https://observablehq.com/@d3/stacked-bar-chart
*/
import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
theme: 'classic',
autoFit: true,
});
chart
.interval()
.data({
type: 'fetch',
value:
'https://gw.alipayobjects.com/os/bmw-prod/f129b517-158d-41a9-83a3-3294d639b39e.csv',
format: 'csv',
})
.transform({ type: 'stackY' })
.transform({ type: 'sortX', by: 'y', reverse: true })
.encode('x', 'state')
.encode('y', 'population')
.encode('color', 'age')
.axis('x', {
labelSpacing: 4,
style: {
labelTransform: 'rotate(90)',
},
})
.encode('shape', 'hollow')
.legend('color', {
position: 'bottom',
})
.axis('y', { labelFormatter: '~s' });
chart.render();
额外信息
G2 5.0.4