antvis/G2

[v5] Tooltip 在多 mark 下的并存问题 #4562

visiky posted onGitHub

描述

<img width="400" alt="image" src="https://user-images.githubusercontent.com/15646325/211260257-a83a581b-87a9-402b-9b5f-5671ef14c11a.png">

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

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

chart.interaction({ type: 'tooltip' })

chart
  .line()
  .data({
    type: 'fetch',
    value: 'https://assets.antv.antgroup.com/g2/forecast-range.json',
  })
  .encode('x', d => new Date(d[0]))
  .encode('y', d => d[4])
  .encode('tooltip', d => {
    return [{
      name: '数值',
      value: d[4]
    }]
  });

chart.point()
  .data([
    ['01-08', 0.417885699969663],
    ['01-23', 0.706678090635692],
    ['03-12', 6.0515889109663],
  ])
  .encode('x', (d) => new Date(d[0]))
  .encode('y', (d) => d[1])
  .encode('shape', 'point')
  .encode('color', '#FF6B3B')
  .encode('title', null)
  .encode('tooltip', d => {
    return d ? { name: '异常值', value: d[1] } : null
  })

chart.render();

posted by pearmini over 2 years ago

point 只有两个异常点,在没有异常点的地方,tooltip 依然展示了数据

posted by visiky over 2 years ago

Fund this Issue

$0.00
Funded

Pull requests