antvis/G2

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

visiky posted onGitHub

描述

<img width="500" alt="image" src="https://user-images.githubusercontent.com/15646325/211262831-c1578919-bf79-42a8-884d-a80fdcfc60a1.png">

下面两段代码,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();

不期望如下的使用:

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

正确的使用方式如下:

chart.lineX()
  .data([new Date('2010')])
posted by pearmini over 2 years ago

一样还是会存在问题的

发自我的 iPad

------------------ 原始邮件 ------------------ 寄件人: MiniPear @.*> 发送时间: 2023年1月9日 17:12 收件人: antvis/G2 *@.> 抄送: visiky @.*>, Author *@.> 主旨: 回覆:[antvis/G2] [v5] 折线图 encode Date 问题 (Issue #4563)

不期望如下的使用: chart.lineX() .data(['2010']) .encode('x', d => new Date(d))

正确的使用方式如下: chart.lineX() .data([new Date('2010')])

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

posted by visiky over 2 years ago

没有问题吧?

image

posted by pearmini over 2 years ago

Fund this Issue

$0.00
Funded

Pull requests