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

fix: fix subLayoutFacetCircle cal center y problem #5833

Merged
merged 1 commit into from
Nov 22, 2023
Merged

fix: fix subLayoutFacetCircle cal center y problem #5833

merged 1 commit into from
Nov 22, 2023

Conversation

BENcorry
Copy link
Contributor

@BENcorry BENcorry commented Nov 22, 2023

Checklist
  • npm test passes
  • benchmarks are included
  • commit message follows commit guidelines
  • documents are updated
Description of change
解决问题

使用facetCircle绘制时,月份的数据和具体图表对应不上的问题 #5624

解决办法

处理在会只过程中对于子坐标系的原点计算的逻辑

Demo
import { Chart } from '../../../src';

export function viewFacetCircle(context) {
  const { container, canvas } = context;

  const M = [
    'Jan.',
    'Feb.',
    'Mar.',
    'Apr.',
    'May',
    'Jun.',
    'Jul.',
    'Aug.',
    'Sept.',
    'Oct.',
    'Nov.',
    'Dec.',
  ];
  const N = ['A', 'B', 'C', 'D'];
  const data = M.flatMap((month, i) =>
    N.map((name, j) => ({
      month,
      name,
      value: i + j,
    })),
  );

  const chart = new Chart({
    container: container,
    canvas,
  });

  const facetCircle = chart
    .facetCircle()
    .data(data)
    .encode('position', 'month');

  facetCircle
    .interval()
    .encode('x', 'name')
    .encode('y', 'value')
    .encode('color', 'name');

  const finished = chart.render();

  return { chart, finished };
}
修复前

image

修复后

image

@BENcorry
Copy link
Contributor Author

我这边删除月份让月份的数量为单数的时候,不存在刻度的问题

demo
export function viewFacetCircle(context) {
  const { container, canvas } = context;

  const M = [
    'Jan.',
    'Feb.',
    'Mar.',
    'Apr.',
    'May',
    'Jun.',
    'Jul.',
    'Aug.',
    'Sept.',
    'Oct.',
    'Nov.',
  ];
  const N = ['A', 'B', 'C', 'D'];
  const data = M.flatMap((month, i) =>
    N.map((name, j) => ({
      month,
      name,
      value: i + j,
    })),
  );

  const chart = new Chart({
    container: container,
    canvas,
  });

  const facetCircle = chart
    .facetCircle()
    .data(data)
    .encode('position', 'month');

  facetCircle
    .interval()
    .encode('x', 'name')
    .encode('y', 'value')
    .encode('color', 'name');

  const finished = chart.render();

  return { chart, finished };
}

image

Copy link
Member

@pearmini pearmini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI 报错了,本地删除对应的截图,运行 npm t 重新生成一下。

src/composition/facetCircle.ts Show resolved Hide resolved
Copy link
Member

@pearmini pearmini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM🚀🚀

@pearmini pearmini merged commit 74ce08a into antvis:v5 Nov 22, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants