antvis/G2

聚合多度量图点击无法获得准确信息。 #4923

pearmini posted onGitHub

  • 版本:5.0.4
  • 问题:点击条的时候
    • 期望是转换之后的数据,目前是转换之前的数据。
    • 除了 data 之外,返回 channel 的信息,可以识别条属于哪一个度量。

image

/**
 * 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();

可以通过数据列实现,故关闭。

posted by pearmini over 1 year ago

Fund this Issue

$0.00
Funded

Pull requests