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

【v5】tooltip labelFormatter 应该支持 d3-format #5016

Closed
Deathsteps opened this issue May 12, 2023 · 2 comments
Closed

【v5】tooltip labelFormatter 应该支持 d3-format #5016

Deathsteps opened this issue May 12, 2023 · 2 comments

Comments

@Deathsteps
Copy link
Contributor

问题描述

axis 支持了 d3-format,tooltip 居然不支持,有点不合理。

image

期望结果

tooltip 的 labelFormatter 和 axis 的一样,可以支持 d3-format

如何重现

官方示例修改

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

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

chart
  .interval()
  .data([
    { name: 'MODIFY', value: 138, washaway: 0.21014492753623193 },
    { name: 'PRERELEASE', value: 109, washaway: 0.5596330275229358 },
    { name: 'RELEASING', value: 48, washaway: 0 },
  ])
  .encode('x', 'name')
  .encode('y', 'value')
  .encode('color', 'name')
  .encode('size', 80)
  .axis('y', { labelFormatter: '.0%' })
  .tooltip({ channel: 'y', labelFormatter: '.0%' });

chart.render();

额外信息

G2 5.0.4

@pearmini
Copy link
Member

pearmini commented May 12, 2023

这个 API 是 valueFormatter:

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

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

chart
  .interval()
  .tooltip({ channel: 'y', valueFormatter: '.0%' });

chart.render();

@Deathsteps
Copy link
Contributor Author

Sorry,看错文档了 😂

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

No branches or pull requests

2 participants