antvis/G2

【V5】堆叠折线图.style('stroke')无法获取某条线的数据 #5807

KuduroJS posted onGitHub

问题描述

堆叠折线图.style('stroke')无法获取某条线的数据

面积图也有这个问题

demo如下:

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

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

chart.data({
  type: 'fetch',
  value: 'https://assets.antv.antgroup.com/g2/unemployment-by-industry.json',
});

chart
  .line()
  .transform([
    { type: 'stackY' }, // Try to remove this line.
  ])
  .encode('x', (d) => new Date(d.date))
  .encode('y', 'unemployed')
  .encode('color', 'industry')
  .encode('shape', 'smooth')
  .style('stroke', (datum, b, c, d) => {
    console.log('stroke...', datum, b, c, d) // ! 这里无法获取当前row数据
    return 'red'
  })
  ;

chart.render();

重现链接

No response

重现步骤

console输出

预期行为

预期可以获取当前row数据,根据数据设置不同颜色

平台

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

屏幕截图或视频(可选)

No response

补充说明(可选)

No response


row 数据是指啥?

posted by pearmini over 1 year ago

row 数据是指啥?

没说清楚hhh,抱歉

比如图上有30条线,我想把某条线改成红色。。需要这条线的数据。

或者叫通道?

posted by KuduroJS over 1 year ago
 .style('stroke', (datum, b, c, d) => {
    // datum 就是整条线的数据?
    return 'red'
  })
posted by pearmini over 1 year ago
 .style('stroke', (datum, b, c, d) => {
    // datum 就是整条线的数据?
    return 'red'
  })

!。。是的。。我傻了/捂脸。 谢谢你。

posted by KuduroJS over 1 year ago

Fund this Issue

$0.00
Funded

Pull requests