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

fix: repeated color in the same chart #23762

Merged
merged 10 commits into from
May 19, 2023

Conversation

lilykuang
Copy link
Member

@lilykuang lilykuang commented Apr 21, 2023

SUMMARY

Currently, the charts are experiencing an issue where colors are being repeated even though the color palette has more colors than the chart requires. This is problematic because it can make it difficult for users to distinguish between different data points and can lead to confusion. the code will now check colors in shared label and remove the color for the list.

  • add a feature flag
  • implement a function to remove shared label color from range

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:
before
After:
after

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

sharedColorMap.forEach((value, key) => {
if (key !== cleanedValue) {
const index = updatedRange.indexOf(value);
updatedRange.splice(index, 1);
Copy link
Member

@eschutho eschutho May 1, 2023

Choose a reason for hiding this comment

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

It looks like this may be removing items from a list. Can you use the filter function here instead?

@eschutho
Copy link
Member

eschutho commented May 1, 2023

/testenv up

@github-actions
Copy link
Contributor

github-actions bot commented May 1, 2023

@eschutho Container image not yet published for this PR. Please try again when build is complete.

@github-actions
Copy link
Contributor

github-actions bot commented May 1, 2023

@eschutho Ephemeral environment creation failed. Please check the Actions logs for details.

@pull-request-size pull-request-size bot added size/L and removed size/M labels May 13, 2023
@codecov
Copy link

codecov bot commented May 13, 2023

Codecov Report

Merging #23762 (daaddac) into master (1670275) will increase coverage by 0.00%.
The diff coverage is 65.38%.

❗ Current head daaddac differs from pull request most recent head d5d68b7. Consider uploading reports for the commit d5d68b7 to get more accurate results

@@           Coverage Diff           @@
##           master   #23762   +/-   ##
=======================================
  Coverage   68.23%   68.23%           
=======================================
  Files        1942     1942           
  Lines       75205    75226   +21     
  Branches     8145     8148    +3     
=======================================
+ Hits        51314    51329   +15     
- Misses      21806    21812    +6     
  Partials     2085     2085           
Flag Coverage Δ
hive 53.16% <15.38%> (-0.02%) ⬇️
javascript 54.53% <84.61%> (+0.01%) ⬆️
mysql 78.91% <15.38%> (-0.03%) ⬇️
postgres 78.99% <15.38%> (-0.03%) ⬇️
presto 53.09% <46.15%> (-0.01%) ⬇️
python 82.77% <46.15%> (-0.02%) ⬇️
sqlite 77.51% <15.38%> (-0.03%) ⬇️
unit 53.03% <15.38%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ackages/superset-ui-core/src/utils/featureFlags.ts 100.00% <ø> (ø)
...n-chart-handlebars/src/plugin/controls/columns.tsx 15.78% <0.00%> (+0.78%) ⬆️
superset/config.py 92.02% <ø> (ø)
superset/models/helpers.py 69.11% <45.45%> (-0.31%) ⬇️
superset/models/core.py 89.97% <50.00%> (-0.19%) ⬇️
...uperset-ui-core/src/color/CategoricalColorScale.ts 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@lilykuang lilykuang requested a review from eschutho May 17, 2023 17:24
Copy link
Member

@eschutho eschutho left a comment

Choose a reason for hiding this comment

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

LGTM!

@lilykuang lilykuang merged commit 66594ad into apache:master May 19, 2023
@lilykuang lilykuang deleted the lily/repeated-color branch May 19, 2023 21:48
@@ -96,7 +114,12 @@ class CategoricalColorScale extends ExtensibleFunction {
const newColor = this.scale(cleanedValue);
Copy link
Member

Choose a reason for hiding this comment

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

This is moving the scale to the next color in order

@@ -96,7 +114,12 @@ class CategoricalColorScale extends ExtensibleFunction {
const newColor = this.scale(cleanedValue);
if (!color) {
color = newColor;
if (isFeatureEnabled(FeatureFlag.AVOID_COLORS_COLLISION)) {
this.removeSharedLabelColorFromRange(sharedColorMap, cleanedValue);
color = this.scale(cleanedValue);
Copy link
Member

Choose a reason for hiding this comment

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

Calling this again will move to the next color in the scale again unnecessarily

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.0.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants