antvis/G2

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

Deathsteps posted onGitHub

问题描述

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

<img width="1175" alt="image" src="https://github.com/antvis/G2/assets/1549118/3da976aa-f038-42e4-be23-94e9c766a49f">

期望结果

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


这个 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();
posted by pearmini almost 2 years ago

Sorry,看错文档了 😂

posted by Deathsteps almost 2 years ago

Fund this Issue

$0.00
Funded

Pull requests