如何修改柱状图hover时的背景样式 #5011
Answered
by
pearmini
liuzhaoxu1996
asked this question in
Q&A
如何修改柱状图hover时的背景样式
#5011
-
Beta Was this translation helpful? Give feedback.
Answered by
pearmini
May 15, 2023
Replies: 1 comment 1 reply
-
v5 里面可以通过 mark.state API 去修改高亮时候背景的颜色: import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
theme: 'classic',
});
chart
.interval()
.data({
type: 'fetch',
value:
'https://gw.alipayobjects.com/os/bmw-prod/fb9db6b7-23a5-4c23-bbef-c54a55fee580.csv',
transform: [{ type: 'slice', start: 0, end: 5 }],
})
.encode('x', 'letter')
.encode('y', 'frequency')
.scale('y', { nice: true })
.axis('y', { labelFormatter: '.0%' })
.state({
active: { // 设置高亮时候背景的颜色
backgroundFill: 'red',
backgroundRadius: 10,
},
});
chart.interaction('elementHighlight', {
background: true, // 显示背景
});
chart.render(); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
hustcc
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
v5 里面可以通过 mark.state API 去修改高亮时候背景的颜色: