Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pearmini opened this issue Apr 27, 2023 · 1 comment
Closed

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

pearmini opened this issue Apr 27, 2023 · 1 comment
Assignees
Labels

Comments

@pearmini
Copy link
Member

  • 版本: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();
@pearmini pearmini self-assigned this Apr 27, 2023
@pearmini
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant