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

给 rangeX 和 rangeY 增加 data 语法糖 #5803

Closed
1 task done
pearmini opened this issue Nov 16, 2023 · 3 comments · Fixed by #5914
Closed
1 task done

给 rangeX 和 rangeY 增加 data 语法糖 #5803

pearmini opened this issue Nov 16, 2023 · 3 comments · Fixed by #5914

Comments

@pearmini
Copy link
Member

AntV Open Source Contribution Plan(可选)

  • 我同意将这个 Issue 参与 OSCP 计划

Issue 类型

中级任务

任务介绍

使得 rangeX 支持以下的语法,解决 #4572 提到的第一个问题。

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

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

chart.data({
  type: 'fetch',
  value:
    'https://gw.alipayobjects.com/os/bmw-prod/551d80c6-a6be-4f3c-a82a-abd739e12977.csv',
});

chart.line().encode('x', 'date').encode('y', 'close');

chart.rangeY().data([350, 600]); // 这样写就可以了

chart.render();

之前的写法:

chart.rangeY().data([[350, 600]]).encode('y', d => d)

思路:添加一个默认的 transform,参考下面的参考说明

参考说明

@deletenothing
Copy link
Contributor

【deletenothing 认领】

@deletenothing
Copy link
Contributor

@pearmini 你好,我对这个需求还有一些疑问,1,请问这个语法糖需要考虑data为[[300,400],[500,600]]这样多个数组的情况吗;2,请问对于RangeX想要实现什么样的效果可以再说明一下吗

@pearmini
Copy link
Member Author

@deletenothing

  1. 需要考虑 [[300,400],[500,600]] 的情况。
  2. rangeX 和 rangeY 类似,也需要支持同样的语法糖,只不过绘制的是竖直方向的区域。

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

Successfully merging a pull request may close this issue.

2 participants