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] 折线图 encode Date 问题 #4563

Closed
visiky opened this issue Jan 9, 2023 · 3 comments
Closed

[v5] 折线图 encode Date 问题 #4563

visiky opened this issue Jan 9, 2023 · 3 comments
Labels

Comments

@visiky
Copy link
Member

visiky commented Jan 9, 2023

描述

image

下面两段代码,lineX 标记 encode x 获取的通道数据应该是一致的,但是展示结果不一致。和 line 标记的数据无法同步起来

正常展示:

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

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

chart
  .line()
  .data({
    type: 'fetch',
    value:
      'https://gw.alipayobjects.com/os/bmw-prod/551d80c6-a6be-4f3c-a82a-abd739e12977.csv',
  })
  .encode('x', d => new Date(d.date))
  .encode('y', 'close')
  .style('connectNulls', true)
  .style('connectStroke', '#aaa');

// 正常展示
chart.lineX()
  .data([{ date: '2010' }])
  .encode('x', d => new Date(d.date))


chart.render();

不正常展示:

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

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

chart
  .line()
  .data({
    type: 'fetch',
    value:
      'https://gw.alipayobjects.com/os/bmw-prod/551d80c6-a6be-4f3c-a82a-abd739e12977.csv',
  })
  .encode('x', d => new Date(d.date))
  .encode('y', 'close')
  .style('connectNulls', true)
  .style('connectStroke', '#aaa');

// 不正常展示
chart.lineX()
  .data(['2010'])
  .encode('x', d => new Date(d))
// 正常展示
// chart.lineX()
//   .data([{ date: '2010' }])
//   .encode('x', d => new Date(d.date))

chart.render();
@visiky visiky added the V5 label Jan 9, 2023
@pearmini
Copy link
Member

pearmini commented Jan 9, 2023

不期望如下的使用:

chart.lineX()
  .data(['2010'])
  .encode('x', d => new Date(d))

正确的使用方式如下:

chart.lineX()
  .data([new Date('2010')])

@visiky
Copy link
Member Author

visiky commented Jan 9, 2023 via email

@pearmini
Copy link
Member

pearmini commented Jan 9, 2023

没有问题吧?

image

@visiky visiky closed this as completed Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants