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

动画 scaleInY 在 polar 下不符合预期 #4461

Closed
1 task done
hustcc opened this issue Dec 14, 2022 · 2 comments · Fixed by #5866
Closed
1 task done

动画 scaleInY 在 polar 下不符合预期 #4461

hustcc opened this issue Dec 14, 2022 · 2 comments · Fixed by #5866

Comments

@hustcc
Copy link
Member

hustcc commented Dec 14, 2022

AntV Open Source Contribution Plan(可选)

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

Issue 类型

中级任务

任务介绍

动画 scaleInY 在 polar 下不符合预期,scaleInY 没有考虑极坐标的情况,目前还是 y 方向 scale 而不是径向 scale 生长。期望 y 方向生长。

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

const chart = new Chart({
  container: 'container',
  width: 800,
  height: 800,
});

const colors = [
  '#98abc5',
  '#8a89a6',
  '#7b6888',
  '#6b486b',
  '#a05d56',
  '#d0743c',
  '#ff8c00',
];

chart.coordinate({ type: 'polar', innerRadius: 0.4 });

chart
  .interval()
  .data({
    type: 'fetch',
    value:
      'https://gw.alipayobjects.com/os/bmw-prod/d582a447-2057-4a74-97ed-1d73a5459ea4.csv',
    transform: [
      {
        type: 'fold',
        fields: [
          'Under 5 Years',
          '5 to 13 Years',
          '14 to 17 Years',
          '18 to 24 Years',
          '25 to 44 Years',
          '45 to 64 Years',
          '65 Years and Over',
        ],
        key: 'Age',
        value: 'Population',
      },
    ],
  })
  .transform({ type: 'stackY' })
  .encode('x', 'State')
  .encode('y', 'Population')
  .encode('color', 'Age')
  .scale('color', { range: colors })
  .legend('color', { position: 'center', display: 'grid', gridCol: 1 })
  .scale('y', { type: 'sqrt' })
  .axis('y', {
    labelFormatter: '~s',
    tickFilter: (_, i) => i !== 0,
    direction: 'center',
  })
  .axis('x', { position: 'inner' })
  .animate('enter', {
    type: 'scaleInY',
    duration: 2000,
  });

chart.render();

参考说明

scaleInY 动画考虑 polar 坐标系,计算合适的 scale(x, y) 中的 x 和 y。

@hustcc hustcc self-assigned this Dec 14, 2022
@pearmini pearmini added this to G2 Jan 4, 2023
@pearmini pearmini moved this to High Priority in G2 Jan 4, 2023
@pearmini pearmini added the V5 label Jan 4, 2023
@pearmini
Copy link
Member

pearmini commented Jan 4, 2023

看上去应该是 scaleInY 没有考虑极坐标的情况,目前还是 y 方向 scale 而不是径向 scale。

@pearmini pearmini assigned pearmini and unassigned hustcc Feb 13, 2023
@pearmini pearmini moved this from Before Release to Todo in G2 Mar 28, 2023
@pearmini pearmini removed the status in G2 Sep 4, 2023
@pearmini pearmini added the New label Nov 30, 2023
@pearmini pearmini removed their assignment Nov 30, 2023
@pearmini pearmini added Feature and removed Bug labels Nov 30, 2023
@Runtus
Copy link
Contributor

Runtus commented Nov 30, 2023

【Runtus】认领

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

Successfully merging a pull request may close this issue.

3 participants