antvis / G2

📊 The concise and progressive visualization grammar.
https://g2.antv.antgroup.com
MIT License
12.11k stars 1.59k forks source link

怎么设置 elementHighlight 的背景色呢? #6073

Open YY88Xu opened 8 months ago

YY88Xu commented 8 months ago

问题描述

image

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

Amaz-Ning commented 3 weeks ago

可以通过state设置: interaction: { elementHighlight: { background: true }, }, state: { // 这里设置 active: { backgroundFill: 'red' } }