Replies: 1 comment 2 replies
-
可以看看运行这个代码,是否是想要的想过,如果不是的话,贴一下你需要的效果吧! /**
* 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')
.state('inactive', { opacity: 0.3 }) // 👈🏻 这里
.axis('x', {
labelSpacing: 4,
style: {
labelTransform: 'rotate(90)',
},
})
.axis('y', { labelFormatter: '~s' });
chart.interaction('legendHighlight', true); // 👈🏻 这里
chart.render(); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
关闭图例不想让对应横坐标也消失,只让对应柱子隐藏,仍旧占位
Beta Was this translation helpful? Give feedback.
All reactions