antvis/G2

存在多个 transform 的情况下,Tooltip 默认不会展示堆叠前的数据 #5952

YiSiWang posted onGitHub

问题描述

#4681 提到 Tooltip 默认展示堆叠前的数据,但是如果存在 .transform({ type: 'groupColor', y: 'count' }) ,会导致 Tooltip 展示堆叠后的数据:

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

const chart = new Chart({
  container: 'container',
  height: 640,
});

chart.coordinate({ type: 'theta', innerRadius: 0.6 });

chart
  .interval()
  .transform({ type: 'groupColor', y: 'count' })
  .transform({ type: 'stackY' })
  .data(
    [
      { name: 'A' },
      { name: 'A' },
      { name: 'A' },
      { name: 'B' },
      { name: 'C' },
    ]
  )
  .encode('color', 'name')
  .style('stroke', 'white')
  .style('inset', 1)
  .style('radius', 10)
  .scale('color', {
    palette: 'spectral',
    offset: (t) => t * 0.8 + 0.1,
  })
  .animate('enter', { type: 'waveIn' })
  .legend(false);

chart.render();
  1. 如何展示堆叠前的数据?
  2. 是否应该默认展示堆叠前?

重现链接

No response

重现步骤

No response

预期行为

No response

平台

  • 操作系统: [macOS, Windows, Linux, React Native ...]
  • 网页浏览器: [Google Chrome, Safari, Firefox]

屏幕截图或视频(可选)

No response

补充说明(可选)

No response


这例子中期望展现的堆叠前的数据是啥?

posted by pearmini over 1 year ago

@pearmini 3,1,1 啊 不是三个A,1个B,1个C嘛

posted by YiSiWang over 1 year ago
chart
  .interval()
  .interaction('tooltip', { shared: true }) // 这样?
posted by pearmini over 1 year ago

Fund this Issue

$0.00
Funded

Pull requests