antvis / G2

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

图例同时 highlight 和 filter 会出错 #5939

Open YY88Xu opened 10 months ago

YY88Xu commented 10 months ago

问题描述

import { Chart } from '@antv/g2';

const chart = new Chart({ container: 'container', autoFit: true, });

chart .interval() .data([ { month: 'Jan.', profit: 387264, start: 0, end: 387264 }, { month: 'Feb.', profit: 772096, start: 387264, end: 1159360 }, { month: 'Mar.', profit: 638075, start: 1159360, end: 1797435 }, { month: 'Apr.', profit: -211386, start: 1797435, end: 1586049 }, { month: 'May', profit: -138135, start: 1586049, end: 1447914 }, { month: 'Jun', profit: -267238, start: 1447914, end: 1180676 }, { month: 'Jul.', profit: 431406, start: 1180676, end: 1612082 }, { month: 'Aug.', profit: 363018, start: 1612082, end: 1975100 }, { month: 'Sep.', profit: -224638, start: 1975100, end: 1750462 }, { month: 'Oct.', profit: -299867, start: 1750462, end: 1450595 }, { month: 'Nov.', profit: 607365, start: 1450595, end: 2057960 }, { month: 'Dec.', profit: 1106986, start: 2057960, end: 3164946 }, { month: 'Total', start: 0, end: 3164946 }, ]) .encode('x', 'month') .encode('y', ['end', 'start']) .encode('color', (d) => d.month === 'Total' ? 'Total' : d.profit > 0 ? 'Increase' : 'Decrease', ) .axis('y', { labelFormatter: '~s' }) .state('inactive', { opacity: 0.1 }) .legend('color', { state: { inactive: { labelOpacity: 0.1, markerOpacity: 0.1 } }, });

chart.interaction('legendHighlight', true); chart.interaction('legendFilter', true);

chart.render();

重现链接

No response

重现步骤

legend 同时具有 hightlight 和 filter 的时候有问题。 当filter 一个以后再恢复,hightlight 不能正常使用

image

预期行为

No response

平台

屏幕截图或视频(可选)

No response

补充说明(可选)

No response

thankwsx commented 2 months ago

默认legendFilter是启用的,如果同时启用legendHighlight,点击legend之后,移出鼠标,legend的inactive状态会消失。