antvis/G2

The issue has been closed
聚合多度量图点击无法获得准确信息。 #4923
pearmini posted onGitHub
- 版本:5.0.4
- 问题:点击条的时候
- 期望是转换之后的数据,目前是转换之前的数据。
- 除了 data 之外,返回 channel 的信息,可以识别条属于哪一个度量。
/**
* A recreation of this demo: https://vega.github.io/vega-lite/examples/bar_grouped_repeated.html
*/
import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
theme: 'classic',
autoFit: true,
paddingBottom: 150,
});
chart.data({
type: 'fetch',
value: 'https://assets.antv.antgroup.com/g2/movies.json',
});
chart
.interval()
.transform({ type: 'groupX', y: 'sum' })
.axis('y', { labelFormatter: '~s' })
.axis('x', { labelTransform: 'rotate(90)' })
.encode('x', 'Major Genre')
.encode('y', 'Worldwide Gross')
.encode('series', () => 'Worldwide Gross')
.encode('color', () => 'Worldwide Gross')
.tooltip({ channel: 'y', valueFormatter: '~s' });
chart
.interval()
.transform({ type: 'groupX', y: 'sum' })
.encode('x', 'Major Genre')
.encode('y', 'US Gross')
.encode('color', () => 'US Gross')
.encode('series', () => 'US Gross')
.tooltip({ channel: 'y', valueFormatter: '~s' });
// 1. 期望是转换之后的数据,目前是转换之前的数据。
// 2. 除了 data 之外,返回 channel 的信息,可以识别条属于哪一个度量。
chart.on('element:click', e => expect(e.data.data).toBeTransformedData());
chart.render();