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

feat(layout): auto inset #5204

Merged
merged 1 commit into from
Jun 20, 2023
Merged

feat(layout): auto inset #5204

merged 1 commit into from
Jun 20, 2023

Conversation

pearmini
Copy link
Member

Auto Inset

在极坐标系下 legend 和 axis 可能会重合,这里通过自动计算 inset 来解决。

开始使用

下图中红色区域就是 inset 部分。

Before After
export function scoreByItemAreaRadarCustom(): G2Spec {
  return {
    type: 'view',
    data: scoreByItem,
    coordinate: { type: 'polar' },
    axis: {
      x: { grid: true },
      y: {
        zIndex: 1,
        title: false,
        tickCount: 3,
        direction: 'center',
        style: {
          gridStroke: 'red',
          gridStrokeOpacity: 1,
          labelStroke: 'green',
          lineStroke: 'yellow',
          tickStroke: 'red',
        },
      },
    },
    scale: {
      x: { padding: 0.5, align: 0 },
      y: { tickCount: 5 },
    },
    legend: { color: { layout: { justifyContent: 'flex-start' } } },
    children: [
      {
        type: 'area',
        encode: { x: 'item', y: 'score', color: 'type' },
        style: { fillOpacity: 0.5 },
      },
      {
        type: 'line',
        encode: { x: 'item', y: 'score', color: 'type' },
        style: { lineWidth: 2 },
      },
    ],
    style: {
      viewFill: '#4e79a7',
      plotFill: '#f28e2c',
      mainFill: '#e15759',
      contentFill: '#76b7b2',
    },
  };
}

@pearmini pearmini requested review from hustcc and Aarebecca and removed request for hustcc June 19, 2023 03:33
@pearmini pearmini linked an issue Jun 19, 2023 that may be closed by this pull request
@pearmini pearmini requested a review from hustcc June 19, 2023 03:34
@pearmini pearmini merged commit 25dd207 into v5 Jun 20, 2023
3 checks passed
@pearmini pearmini deleted the feat/auto-inset branch June 20, 2023 03:29
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.

极坐标系 auto Inset?
2 participants