antvis / antvis/G2Plot

🥰 [FEATURE] Allow data label style to be a function (same as for data points)

Open
#3,295 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2.7k
Forks
591
PR merge metrics
No merged PRs in 30d

Description

### 🥰 Features description [Please make everyone to understand it]
Allow data label style to be a function (same as for data points).

### 🏞 What problem does this feature solve
So it would be possible to use different colors for different categories.

### 🧐 What does the proposed API look like
```
label.style: (item) => {
if (item.category === 'Gas fuel') {
return {fill: 'red'};
}
return {fill: 'green'};
},
```

### 🚑 Any additional [like screenshots]
![image](https://user-images.githubusercontent.com/5941457/180613159-bc5a0985-4385-41f1-95ca-ba34297038ef.png)

Contributor guide

Open the contributing guide

Research direction

Start by locating the data-label style handling and the existing data-point style callback support. Trace how the proposed label.style function receives an item and how returned styles are applied. Done means label.style accepts a function and allows category-specific colors such as the example; add or update coverage if the relevant tests are found.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data-visualization
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.