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: Respecting max/min opacities, and adding tests. #20555

Merged
merged 9 commits into from
Jun 30, 2022

Conversation

rusackas
Copy link
Member

@rusackas rusackas commented Jun 30, 2022

SUMMARY

There was an error where calculated opacities could be over 1, or below 0. This code will only allow the opacity to go to the configured maximum or minimum.

Hat tip to @michael-s-molina for the detective work here :)

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

image

TESTING INSTRUCTIONS

Unit tests included!

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

@codecov
Copy link

codecov bot commented Jun 30, 2022

Codecov Report

Merging #20555 (0dd7d4a) into master (daded10) will decrease coverage by 0.16%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #20555      +/-   ##
==========================================
- Coverage   66.75%   66.58%   -0.17%     
==========================================
  Files        1739     1752      +13     
  Lines       65138    67087    +1949     
  Branches     6898     7448     +550     
==========================================
+ Hits        43480    44667    +1187     
- Misses      19908    20576     +668     
- Partials     1750     1844      +94     
Flag Coverage Δ
hive 53.72% <ø> (ø)
javascript 52.19% <100.00%> (+0.39%) ⬆️
mysql 82.33% <ø> (ø)
postgres 82.40% <ø> (ø)
presto 53.57% <ø> (ø)
python 82.84% <ø> (ø)
sqlite 82.18% <ø> (ø)
unit 50.56% <ø> (ø)

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

Impacted Files Coverage Δ
...-ui-chart-controls/src/utils/getColorFormatters.ts 100.00% <100.00%> (ø)
...gins/legacy-plugin-chart-chord/src/controlPanel.ts 40.00% <0.00%> (-60.00%) ⬇️
...gins/legacy-plugin-chart-rose/src/controlPanel.tsx 66.66% <0.00%> (-33.34%) ⬇️
...ins/legacy-plugin-chart-sankey/src/controlPanel.ts 66.66% <0.00%> (-33.34%) ⬇️
...s/legacy-plugin-chart-calendar/src/controlPanel.ts 66.66% <0.00%> (-33.34%) ⬇️
...plugin-chart-word-cloud/src/plugin/controlPanel.ts 66.66% <0.00%> (-33.34%) ⬇️
...egacy-plugin-chart-country-map/src/controlPanel.ts 66.66% <0.00%> (-33.34%) ⬇️
...egacy-preset-chart-nvd3/src/Bubble/controlPanel.ts 66.66% <0.00%> (-33.34%) ⬇️
...gacy-preset-chart-nvd3/src/Compare/controlPanel.ts 66.66% <0.00%> (-33.34%) ⬇️
...lugin-chart-handlebars/src/plugin/controlPanel.tsx 80.00% <0.00%> (-20.00%) ⬇️
... and 90 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update daded10...0dd7d4a. Read the comment docs.

@rusackas rusackas changed the title Respecting max/min opacities, and adding tests. fix: Respecting max/min opacities, and adding tests. Jun 30, 2022
@@ -50,6 +50,8 @@ describe('getOpacity', () => {
expect(getOpacity(100, 100, 50)).toEqual(0.05);
expect(getOpacity(100, 100, 100, 0, 0.8)).toEqual(0.8);
expect(getOpacity(100, 100, 50, 0, 1)).toEqual(0);
expect(getOpacity(999, 100, 50, 0, 1)).toEqual(1);
expect(getOpacity(-999, 100, 50, 0, 1)).toEqual(0.05);
Copy link
Member

Choose a reason for hiding this comment

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

Math.abs inside the function will make sure result is never negative. We can replace this test with one that passes a high minOpacity like 0.9 and parameters that make result be less than this value to test result < minOpacity

Suggested change
expect(getOpacity(-999, 100, 50, 0, 1)).toEqual(0.05);

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

LGTM

@rusackas rusackas added the v2.0 label Jun 30, 2022
@pull-request-size pull-request-size bot added size/S and removed size/M labels Jun 30, 2022
@rusackas rusackas closed this Jun 30, 2022
@rusackas rusackas reopened this Jun 30, 2022
@rusackas rusackas merged commit ac8e502 into master Jun 30, 2022
@rusackas rusackas deleted the setting-opacity-boundaries branch June 30, 2022 22:10
sadpandajoe pushed a commit to preset-io/superset that referenced this pull request Jun 30, 2022
* Respecting max/min opacities, and adding tests.

* revising tests

* Adding missing test case for maximum coverage :)

* removing unnecessary logic and test

* adding another unit test for (hopefully) full coverage.

* no more ternary operator

* New approach with Math.min  - take THAT codecov.

* one more stab at making codecov happy... ignoring the file next.

* lint fixes

(cherry picked from commit ac8e502)
@sadpandajoe
Copy link
Member

🏷️ preset:2022.25

michael-s-molina pushed a commit that referenced this pull request Jul 6, 2022
* Respecting max/min opacities, and adding tests.

* revising tests

* Adding missing test case for maximum coverage :)

* removing unnecessary logic and test

* adding another unit test for (hopefully) full coverage.

* no more ternary operator

* New approach with Math.min  - take THAT codecov.

* one more stab at making codecov happy... ignoring the file next.

* lint fixes

(cherry picked from commit ac8e502)
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 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 preset:2022.25 preset-io size/S v2.0 🍒 2.0.0 🍒 2.0.1 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants