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(legend): optimize #5202

Merged
merged 1 commit into from
Jun 17, 2023
Merged

feat(legend): optimize #5202

merged 1 commit into from
Jun 17, 2023

Conversation

pearmini
Copy link
Member

@pearmini pearmini commented Jun 16, 2023

优化图例

  • 图例 autoPadding。
  • 连续图例的展示优化:添加 handle。
  • 多个图例的展示问题。
  • 离散图例默认展示 title。
  • 离散图例展示优化。

开始使用

export function commitsPointGrouped(): G2Spec {
  return {
    type: 'point',
    height: 300,
    inset: 10,
    padding: 'auto',
    frame: true,
    data: {
      type: 'fetch',
      value: 'data/commits.csv',
    },
    encode: {
      x: (d) => d.time.getUTCHours(),
      y: (d) => d.time.getUTCDay(),
      size: 'count',
      shape: 'point',
      color: 'count',
    },
    transform: [{ type: 'group', size: 'sum' }, { type: 'sortY' }],
    scale: {
      y: { type: 'point' },
      x: { tickCount: 24 },
      color: { palette: 'rdBu' },
    },
    axis: {
      x: { title: 'time (hours)' },
      y: { title: 'time (day)', grid: true },
    },
  };
}

优化前:

上面存在的问题如下:

  • 图例布局空间浪费。
  • size 图例的颜色有误导性,引导用户去找蓝色的圆,应该选择一个更加中性的颜色。
  • 图例默认没有 handle。
  • 图例的 title 和 label 的样式和坐标轴的不符合。
  • size 图例只展示第一个和最后一个 tick。
  • 连续图例太长了。

优化后:

@pearmini pearmini requested review from hustcc and Aarebecca June 16, 2023 04:53
Copy link
Contributor

@pepper-nice pepper-nice left a comment

Choose a reason for hiding this comment

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

LG

@pearmini pearmini merged commit fbebfc5 into v5 Jun 17, 2023
@pearmini pearmini deleted the feat/optimize-legend branch June 17, 2023 01:15
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.

3 participants