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

配置slider的formatter后,sparkline不再显示 #6137

Open
peaceps opened this issue Mar 18, 2024 · 1 comment
Open

配置slider的formatter后,sparkline不再显示 #6137

peaceps opened this issue Mar 18, 2024 · 1 comment

Comments

@peaceps
Copy link

peaceps commented Mar 18, 2024

问题描述

配置slider的formatter后,sparkline不再显示

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

const data = [
  { year: '1991', value: 3 },
  { year: '1992', value: 4 },
  { year: '1993', value: 3.5 },
  { year: '1994', value: 5 },
  { year: '1995', value: 4.9 },
  { year: '1996', value: 6 },
  { year: '1997', value: 7 },
  { year: '1998', value: 9 },
  { year: '1999', value: 13 },
];

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

chart
  .data(data)
  .encode('x', 'year')
  .encode('y', 'value');

chart
  .line()
  .slider('x', {
    formatter: t => Math.floor(1991 + t * 8).toString() + '年'
  });

chart.render();

重现链接

No response

重现步骤

No response

预期行为

slider label的formatter应该不会影响sparkline的绘制
看代码在slider.ts里有如下判断

if (slider?.x && Object.keys(slider.x).length === 0) {
  ...添加sparkline数据

不是很确定这里检查key.length===0的用意,可能是为了避免和某些配置参数的冲突?
但是感觉比起直接忽略sparkline,暴露不绘制sparkline的选项更友好

平台

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

屏幕截图或视频(可选)

No response

补充说明(可选)

No response

重现链接

No response

重现步骤

No response

预期行为

No response

平台

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

屏幕截图或视频(可选)

image

image

补充说明(可选)

No response

@qtj4js
Copy link

qtj4js commented May 17, 2024

想问一下,这个任务有考虑解决么?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants