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: add channels to style and label callback #6250

Merged
merged 2 commits into from
May 30, 2024
Merged

Conversation

pearmini
Copy link
Member

@pearmini pearmini commented May 29, 2024

fix: #6248

对于聚合图表,需要提供聚合之后的数据给 label 和 style 的回调,这样才能根据聚合后的数据进行可视化。

image
export function diamondIntervalGroupX(): G2Spec {
  return {
    type: 'interval',
    data: {
      type: 'fetch',
      value: 'data/diamond.csv',
    },
    encode: {
      x: 'clarity',
      y: 'price',
    },
    labels: [
      {
        text: (_, index, __, {channel}) => channel.y[index],
      },
    ],
    transform: [{ type: 'groupX', y: 'max' }],
    style: {
      fill: (_, index, __, {channel}) =>
        channel.y[index] < 11700 ? 'red' : 'blue',
    },
  };
}

@coveralls
Copy link

coveralls commented May 29, 2024

Pull Request Test Coverage Report for Build 9283375010

Details

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.002%) to 86.409%

Totals Coverage Status
Change from base Build 9243141786: 0.002%
Covered Lines: 10374
Relevant Lines: 11629

💛 - Coveralls

@pearmini pearmini merged commit 3c003d0 into v5 May 30, 2024
2 checks passed
@pearmini pearmini deleted the callback-with-channels branch May 30, 2024 08:07
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.

进行groupX聚合运算的图表,添加对应属性的数据标签label显示不正确
3 participants