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(size): support ordinal size channel #5320

Merged
merged 1 commit into from
Jul 17, 2023
Merged

feat(size): support ordinal size channel #5320

merged 1 commit into from
Jul 17, 2023

Conversation

pearmini
Copy link
Member

@pearmini pearmini commented Jul 17, 2023

离散 Size 通道

之前的 point 的 size 对应比例尺是 sqrt,没有考虑离散的情况。当 point 的 size 绑定的是离散数据的情况,将使用 point 比例尺。

相关 issue

主要内容

  • point 的 size 只有在连续的时候,才会使用 sqrt 比例尺。
  • 修改了推断 category legend 的逻辑:不走枚举的逻辑(不好维护),用更简单的方式:当且仅当该字段绑定的所有比例尺满足以下两个条件的时候会推断出比例尺:
    • 不全是 constant 比例尺
    • 只有 constant 和 discrete 的比例尺

TODO

  • 修复 GUI hollow shape 的 stroke 随着 marker size 变换的问题。

image

  • 修复 GUI item 不是放在中心的问题。

image

案例

export function cars2PointConstantColorSize(): G2Spec {
  return {
    type: 'point',
    padding: 'auto',
    data: {
      type: 'fetch',
      value: 'data/cars2.csv',
    },
    encode: {
      y: 'Miles_per_Gallon',
      x: 'Horsepower',
      size: 'Origin',
    },
    scale: {
      x: { nice: true },
      y: { nice: true },
    },
  };
}
export function cars2PointOrdinalSize(): G2Spec {
  return {
    type: 'point',
    padding: 'auto',
    data: {
      type: 'fetch',
      value: 'data/cars2.csv',
    },
    encode: {
      y: 'Miles_per_Gallon',
      x: 'Horsepower',
      color: 'Origin',
      size: 'Origin',
      shape: 'point',
    },
    scale: { x: { nice: true }, y: { nice: true } },
  };
}

@pearmini pearmini requested a review from hustcc July 17, 2023 08:31
@pearmini pearmini merged commit 760eb75 into v5 Jul 17, 2023
2 checks passed
@pearmini pearmini deleted the feat/size branch July 17, 2023 11:55
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.

不设置 color 通道,只设置 size 通道会报错 size 通道需要支持离散数据
3 participants