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

refactor(api): composite mark #5178

Merged
merged 2 commits into from
Jun 9, 2023
Merged

refactor(api): composite mark #5178

merged 2 commits into from
Jun 9, 2023

Conversation

pearmini
Copy link
Member

@pearmini pearmini commented Jun 9, 2023

Composite Mark

开始使用

// 之前
function Pie(options) {
  const { encode = {}, ...rest } = options;
  const { value, ...restEncode } = encode;
  return () => {
    return deepMix(rest, {
      type: 'interval',
      transform: [{ type: 'stackY' }],
      coordinate: { type: 'theta' },
      encode: {
        ...restEncode,
        y: value,
      },
    });
  };
}
// 现在
function Pie(options, context) {
  const { encode = {}, ...rest } = options;
  const { value, ...restEncode } = encode;
  return deepMix(rest, {
    type: 'interval',
    transform: [{ type: 'stackY' }],
    coordinate: { type: 'theta' },
    encode: {
      ...restEncode,
      y: value,
    },
  });
}
chart.options({
  type: Pie,
  data: [
    { genre: 'Sports', sold: 275 },
    { genre: 'Strategy', sold: 115 },
    { genre: 'Action', sold: 120 },
    { genre: 'Shooter', sold: 350 },
    { genre: 'Other', sold: 150 },
  ],
  encode: { value: 'sold', color: 'genre' },
});

变化

直接返回 Mark Options,同时增加第二个参数 context 获得 width,height 等参数。

@pearmini pearmini requested a review from hustcc June 9, 2023 03:12
@pearmini pearmini force-pushed the refactor/composite-mark-api branch from e731c67 to 251dfef Compare June 9, 2023 03:44
@pearmini pearmini linked an issue Jun 9, 2023 that may be closed by this pull request
@pearmini pearmini self-assigned this Jun 9, 2023
@pearmini pearmini requested a review from pepper-nice June 9, 2023 05:00
@pearmini pearmini merged commit 2fd9b34 into v5 Jun 9, 2023
@pearmini pearmini deleted the refactor/composite-mark-api branch June 9, 2023 06:36
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.

chart.options 渲染自定义 Mark
3 participants