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

SortX 支持对连续通道排序 #4356

Closed
pearmini opened this issue Nov 24, 2022 · 5 comments
Closed

SortX 支持对连续通道排序 #4356

pearmini opened this issue Nov 24, 2022 · 5 comments
Assignees
Milestone

Comments

@pearmini
Copy link
Member

pearmini commented Nov 24, 2022

SortX

目前的 Sort 只针对离散数据,通过对 scale.domain 去排序达到对数据排序的效果。同时应该增加对连续数据排序的能力。

image

import { Chart } from '@antv/g2';
import { sort } from 'd3-array';

const data = [/** */];

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

chart
  .line()
  .data(data)
  .encode('x', (d) => d)
  .transform({ type: 'binX', y: 'count' })
  .transform({ type: SortX })

chart.render();

// 简单的实现方式如下
function SortX() {
  return (I, mark) => {
    const { encode } = mark;
    const { x } = encode;
    const X = x.value;
    const sortedX = sort(I, (i) => X[i]);
    return [sortedX, mark];
  };
}
@pearmini pearmini self-assigned this Nov 24, 2022
@pearmini pearmini added the V5 label Nov 24, 2022
@hustcc hustcc added this to the 5.0.0-beta.2 milestone Dec 1, 2022
@pearmini pearmini closed this as completed Dec 8, 2022
@pearmini
Copy link
Member Author

pearmini commented Dec 8, 2022

这个 RP #4395 已经解决这个问题

@myface-wang
Copy link

对于连续通道,我想问下,使用new date的的时候,如何将英文日期改为中文

@pearmini
Copy link
Member Author

pearmini commented Dec 8, 2023

对于连续通道,我想问下,使用new date的的时候,如何将英文日期改为中文

@myface-wang 没有太理解,有例子吗?

@myface-wang
Copy link

myface-wang commented Dec 8, 2023

对于连续通道,我想问下,使用新日期的时候,如何将英文日期改为中文

@myface-wang不太明白,有例子吗?

image
当时间跨度没有达到年份的级别时,会显示月份,如何将月份汉化 @pearmini

@pearmini
Copy link
Member Author

@myface-wang

chart.axis('x', { labelFormatter: d => {} })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

No branches or pull requests

3 participants