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】堆叠折线图.style('stroke')无法获取某条线的数据 #5807

Closed
KuduroJS opened this issue Nov 16, 2023 · 4 comments
Closed

Comments

@KuduroJS
Copy link

KuduroJS commented Nov 16, 2023

问题描述

堆叠折线图.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

@KuduroJS KuduroJS changed the title 堆叠折线图.style('stroke')无法获取当前row数据 【V5】堆叠折线图.style('stroke')无法获取当前row数据 Nov 16, 2023
@pearmini
Copy link
Member

row 数据是指啥?

@KuduroJS
Copy link
Author

KuduroJS commented Nov 17, 2023

row 数据是指啥?

没说清楚hhh,抱歉

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

或者叫通道?

@KuduroJS KuduroJS changed the title 【V5】堆叠折线图.style('stroke')无法获取当前row数据 【V5】堆叠折线图.style('stroke')无法获取某条线的数据 Nov 17, 2023
@pearmini
Copy link
Member

 .style('stroke', (datum, b, c, d) => {
    // datum 就是整条线的数据?
    return 'red'
  })

@KuduroJS
Copy link
Author

 .style('stroke', (datum, b, c, d) => {
    // datum 就是整条线的数据?
    return 'red'
  })

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

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