You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "lilykuang (via GitHub)" <gi...@apache.org> on 2023/04/21 01:00:13 UTC

[GitHub] [superset] lilykuang opened a new pull request, #23762: fix: repeated color in the same chart

lilykuang opened a new pull request, #23762:
URL: https://github.com/apache/superset/pull/23762

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   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.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   Before:
   ![before](https://user-images.githubusercontent.com/5705598/233516271-2f98eb11-9614-4598-95e3-70e025b2c0dc.gif)
   After:
   ![after](https://user-images.githubusercontent.com/5705598/233516283-bde9fa2e-52fc-4e4b-a2a2-53c3154d53ed.gif)
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] 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
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #23762: fix: repeated color in the same chart

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #23762:
URL: https://github.com/apache/superset/pull/23762#issuecomment-1530170806

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on pull request #23762: fix: repeated color in the same chart

Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on PR #23762:
URL: https://github.com/apache/superset/pull/23762#issuecomment-1530169064

   /testenv up


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] github-actions[bot] commented on pull request #23762: fix: repeated color in the same chart

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #23762:
URL: https://github.com/apache/superset/pull/23762#issuecomment-1530170846

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho commented on a diff in pull request #23762: fix: repeated color in the same chart

Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho commented on code in PR #23762:
URL: https://github.com/apache/superset/pull/23762#discussion_r1181837953


##########
superset-frontend/packages/superset-ui-core/src/color/CategoricalColorScale.ts:
##########
@@ -96,7 +98,22 @@ class CategoricalColorScale extends ExtensibleFunction {
     const newColor = this.scale(cleanedValue);
     if (!color) {
       color = newColor;
+      // make sure we don't overwrite the origin colors
+      if (!isFeatureEnabled(FeatureFlag.USE_ANALAGOUS_COLORS)) {
+        const updatedRange = [...this.originColors];
+        // remove the color option from shared color
+        sharedColorMap.forEach((value, key) => {
+          if (key !== cleanedValue) {
+            const index = updatedRange.indexOf(value);
+            updatedRange.splice(index, 1);

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



##########
superset-frontend/packages/superset-ui-core/src/color/CategoricalColorScale.ts:
##########
@@ -96,7 +98,22 @@ class CategoricalColorScale extends ExtensibleFunction {
     const newColor = this.scale(cleanedValue);
     if (!color) {
       color = newColor;
+      // make sure we don't overwrite the origin colors
+      if (!isFeatureEnabled(FeatureFlag.USE_ANALAGOUS_COLORS)) {
+        const updatedRange = [...this.originColors];
+        // remove the color option from shared color
+        sharedColorMap.forEach((value, key) => {
+          if (key !== cleanedValue) {
+            const index = updatedRange.indexOf(value);
+            updatedRange.splice(index, 1);

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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] lilykuang merged pull request #23762: fix: repeated color in the same chart

Posted by "lilykuang (via GitHub)" <gi...@apache.org>.
lilykuang merged PR #23762:
URL: https://github.com/apache/superset/pull/23762


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: repeated color in the same chart [superset]

Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on code in PR #23762:
URL: https://github.com/apache/superset/pull/23762#discussion_r1443015643


##########
superset-frontend/packages/superset-ui-core/src/color/CategoricalColorScale.ts:
##########
@@ -96,7 +114,12 @@ class CategoricalColorScale extends ExtensibleFunction {
     const newColor = this.scale(cleanedValue);

Review Comment:
   This is moving the scale to the next color in order 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] codecov[bot] commented on pull request #23762: fix: repeated color in the same chart

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #23762:
URL: https://github.com/apache/superset/pull/23762#issuecomment-1546548870

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/23762?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#23762](https://app.codecov.io/gh/apache/superset/pull/23762?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (b85f8f8) into [master](https://app.codecov.io/gh/apache/superset/commit/1670275571ddd677634bf0ba9b171c6a7275091a?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (1670275) will **increase** coverage by `0.00%`.
   > The diff coverage is `100.00%`.
   
   > :exclamation: Current head b85f8f8 differs from pull request most recent head f978b1f. Consider uploading reports for the commit f978b1f to get more accurate results
   
   ```diff
   @@           Coverage Diff           @@
   ##           master   #23762   +/-   ##
   =======================================
     Coverage   68.23%   68.23%           
   =======================================
     Files        1942     1942           
     Lines       75205    75216   +11     
     Branches     8145     8148    +3     
   =======================================
   + Hits        51314    51325   +11     
     Misses      21806    21806           
     Partials     2085     2085           
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | javascript | `54.53% <100.00%> (+0.01%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://app.codecov.io/gh/apache/superset/pull/23762?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...uperset-ui-core/src/color/CategoricalColorScale.ts](https://app.codecov.io/gh/apache/superset/pull/23762?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvcGFja2FnZXMvc3VwZXJzZXQtdWktY29yZS9zcmMvY29sb3IvQ2F0ZWdvcmljYWxDb2xvclNjYWxlLnRz) | `100.00% <100.00%> (ø)` | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: repeated color in the same chart [superset]

Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on code in PR #23762:
URL: https://github.com/apache/superset/pull/23762#discussion_r1443016065


##########
superset-frontend/packages/superset-ui-core/src/color/CategoricalColorScale.ts:
##########
@@ -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);

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



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org