Open YY88Xu opened 8 months ago
import { Chart } from '@antv/g2';
const data = [ { year: '1951 年', sales: 38 }, { year: '1952 年', sales: 52 }, { year: '1956 年', sales: 61 }, { year: '1957 年', sales: 145 }, { year: '1958 年', sales: 48 }, { year: '1959 年', sales: 38 }, { year: '1960 年', sales: 38 }, { year: '1962 年', sales: 38 }, ];
const chart = new Chart({ container: 'container', autoFit: true, });
chart.interval().data(data).encode('x', 'year') .encode('y', 'sales') .interaction('elementHighlight', { background: true, backgroundFill: 'red', // 这里 })
chart.render();
No response
可以通过state设置: interaction: { elementHighlight: { background: true }, }, state: { // 这里设置 active: { backgroundFill: 'red' } }
问题描述
import { Chart } from '@antv/g2';
const data = [ { year: '1951 年', sales: 38 }, { year: '1952 年', sales: 52 }, { year: '1956 年', sales: 61 }, { year: '1957 年', sales: 145 }, { year: '1958 年', sales: 48 }, { year: '1959 年', sales: 38 }, { year: '1960 年', sales: 38 }, { year: '1962 年', sales: 38 }, ];
const chart = new Chart({ container: 'container', autoFit: true, });
chart.interval().data(data).encode('x', 'year') .encode('y', 'sales') .interaction('elementHighlight', { background: true, backgroundFill: 'red', // 这里 })
chart.render();
重现链接
No response
重现步骤
No response
预期行为
No response
平台
屏幕截图或视频(可选)
No response
补充说明(可选)
No response