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

The label render callback function should return a color #5474

Closed
1 task done
ancyloce opened this issue Aug 28, 2023 · 0 comments
Closed
1 task done

The label render callback function should return a color #5474

ancyloce opened this issue Aug 28, 2023 · 0 comments

Comments

@ancyloce
Copy link

ancyloce commented Aug 28, 2023

AntV Open Source Contribution Plan(可选)

  • 我同意将这个 Issue 参与 OSCP 计划

Issue 类型

中级任务

任务介绍

给 label 提供第个参数,会返回图形的一些信息,包含图形颜色。使用 label 的颜色可以根据图形属性决定。

import { Chart } from '@antv/g2';

const chart = new Chart({ container: 'container' });

chart
  .interval()
  .data([
    { genre: 'Sports', sold: 0 },
    { genre: 'Strategy', sold: 115 },
    { genre: 'Action', sold: 120 },
    { genre: 'Shooter', sold: 350 },
    { genre: 'Other', sold: 150 },
  ])
  .encode('x', 'genre')
  .encode('y', 'sold')
  .encode('color', 'genre')
  .style('minHeight', 50)
  .label({ text: 'genre', fill: (_, i, array, d) => d.fill }); // label 颜色和图形保持一致

chart.render();

参考

@ancyloce ancyloce changed the title The label render callback function did not return a color. [V5] The label render callback function did not return a color. Aug 28, 2023
@pearmini pearmini changed the title [V5] The label render callback function did not return a color. The label render callback function should return a color Nov 16, 2023
@pearmini pearmini moved this to No Status(G2) in AntV OSCP 开发者贡献需求 Nov 16, 2023
@hustcc hustcc closed this as completed Dec 5, 2024
@github-project-automation github-project-automation bot moved this from 已认领 to Done in AntV OSCP 开发者贡献需求 Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

4 participants