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

feat(plugins): Adding colors to BigNumber with Time Comparison chart #27052

Merged

Conversation

Antonio-RiveroMartnez
Copy link
Member

@Antonio-RiveroMartnez Antonio-RiveroMartnez commented Feb 8, 2024

SUMMARY

Currently our BigNumber with Time Comparison chart has no visual indicators to help user easily tell when the differences are positive or negatives. This PR adds a customize control to enable colors in the chart.

Also this PR is updating the thumbnail to reflect an up to date version of the chart with these colors.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screenshot 2024-02-08 at 15 21 08

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

- Add new checbox control so users can toggle colors in the chart
- Make the component capable of using the right colors based on the data
- Fix types in props ofthe component
- Update the thumbnail of the chart
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Attention: 124 lines in your changes are missing coverage. Please review.

Comparison is base (daaf657) 67.19% compared to head (6afe5a6) 67.16%.
Report is 21 commits behind head on master.

Files Patch % Lines
...s/plugin-chart-period-over-period-kpi/src/utils.ts 3.09% 94 Missing ⚠️
...plugin-chart-period-over-period-kpi/src/PopKPI.tsx 0.00% 27 Missing ⚠️
...rt-period-over-period-kpi/src/plugin/buildQuery.ts 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #27052      +/-   ##
==========================================
- Coverage   67.19%   67.16%   -0.03%     
==========================================
  Files        1899     1900       +1     
  Lines       74369    74423      +54     
  Branches     8274     8293      +19     
==========================================
+ Hits        49971    49988      +17     
- Misses      22343    22380      +37     
  Partials     2055     2055              
Flag Coverage Δ
javascript 56.87% <2.36%> (-0.04%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

comparisonColorEnabled ? backgroundColor : defaultBackgroundColor
};
color: ${comparisonColorEnabled ? textColor : defaultTextColor};
padding: 2px 5px;
Copy link
Member

Choose a reason for hiding this comment

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

could we use full grid units? Or does it look weird?

@@ -30,16 +34,51 @@ const ComparisonValue = styled.div<PopKPIComparisonValueStyleProps>`
`}
`;

const SymbolWrapper = styled.div<PopKPIComparisonSymbolStyleProps>`
${({ theme, percentDifferenceNumber, comparisonColorEnabled }) => {
const defaultBackgroundColor = theme.colors.grayscale.light4;
Copy link
Member

Choose a reason for hiding this comment

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

Interesting approach with putting js inside of styled component like that! But I wonder if deducing colours from more "high-level" data belongs to a styled component. Maybe we should move that logic to PopKPI and just pass backgroundColor and textColor to SymbolWrapper?
But if you think this solution is better then I won't argue, I don't have a strong opinion here

Copy link
Member Author

Choose a reason for hiding this comment

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

hehe yeah, I had it like that before and moved to this, it doesn't feel quite "well" but now that you noticed too, let's move it there instead. Thanks

@rusackas
Copy link
Member

rusackas commented Feb 8, 2024

I'm trying to upgrade Storybook, but ironing out a few last details. When that's done, we should add this plugin to Storybook and make sure it has controls for these options

@Antonio-RiveroMartnez
Copy link
Member Author

Antonio-RiveroMartnez commented Feb 8, 2024

I'm trying to upgrade Storybook, but ironing out a few last details. When that's done, we should add this plugin to Storybook and make sure it has controls for these options

Yes! This will be included and we'll have more docs about it too. Right now it's behind Feature Flag as experimental, but an update is coming soon on that regard. Thanks

? prevNumber
: index === 1
? valueDifference
: percentDifferenceFormattedString}
Copy link
Member

Choose a reason for hiding this comment

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

Hmm I'm not sure about coupling the values with indexes like this. I think it would be cleaner if we had some key-value mapping between symbols and values, or an array like [['#', prevNumber], ['△', valueDifference], ['%', percentDifferenceFormattedString]]

bigNumber: string;
prevNumber: string;
valueDifference: string;
percentDifferenceFormattedString: string;
compType: String;
Copy link
Member

Choose a reason for hiding this comment

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

can we also fix those capital S strings? 😛

- Move background and textcolor computation inside the main component so the Styled doesnt have to deal with logic
- Stop accessing values with indexes and have a single array that collects both the symbol and the value
- fix more typing
@Antonio-RiveroMartnez
Copy link
Member Author

/testenv up FEATURE_CHART_PLUGINS_EXPERIMENTAL=true

Copy link
Contributor

github-actions bot commented Feb 8, 2024

@Antonio-RiveroMartnez Ephemeral environment creation is currently limited to committers.

@yousoph
Copy link
Member

yousoph commented Feb 8, 2024

/testenv up FEATURE_CHART_PLUGINS_EXPERIMENTAL=true

@justinpark justinpark added the review:checkpoint Last PR reviewed during the daily review standup label Feb 8, 2024
@justinpark justinpark self-requested a review February 8, 2024 18:00
@yousoph
Copy link
Member

yousoph commented Feb 8, 2024

/testenv up FEATURE_CHART_PLUGINS_EXPERIMENTAL=true

@mistercrunch
Copy link
Member

Hey, quick note that I'm trying to fix ephemeral envs here -> #27057, hoping to merge quickly as soon as CI passes, and to confirm the fix on this PR right after...

@mistercrunch
Copy link
Member

/testenv up FEATURE_CHART_PLUGINS_EXPERIMENTAL=true

2 similar comments
@mistercrunch
Copy link
Member

/testenv up FEATURE_CHART_PLUGINS_EXPERIMENTAL=true

@mistercrunch
Copy link
Member

/testenv up FEATURE_CHART_PLUGINS_EXPERIMENTAL=true

Copy link
Contributor

github-actions bot commented Feb 9, 2024

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

Copy link
Contributor

github-actions bot commented Feb 9, 2024

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

@mistercrunch
Copy link
Member

/testenv up FEATURE_CHART_PLUGINS_EXPERIMENTAL=true

Copy link
Contributor

github-actions bot commented Feb 9, 2024

@mistercrunch Ephemeral environment spinning up at http://34.221.206.0:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

- Update Thumbnail to be square so it doest look squished
@Antonio-RiveroMartnez
Copy link
Member Author

/testenv up FEATURE_CHART_PLUGINS_EXPERIMENTAL=true

Copy link
Contributor

@Antonio-RiveroMartnez Ephemeral environment spinning up at http://35.87.2.140:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@kgabryje
Copy link
Member

Nit for eventual follow up PR - add advanced analytics tag? cc @yousoph

image

@kgabryje
Copy link
Member

I think the selected number formatting doesn't apply to %

image

@kgabryje
Copy link
Member

The styling is not responsive - when I added the chart to a dashboard in a small container, I can't see the values on the right (the container is also not scrollable horizontally so they're just hidden)

image

@kgabryje
Copy link
Member

  1. Can we add a description tooltip?
  2. Does week/month/year mean last week/last month/last year? If so, maybe we could add "last" prefix to the names?
image

@kgabryje
Copy link
Member

  1. Since "Filters (custom)" control works only if Range For Comparison is "Custom", can we make the visibility of that control dynamic, so that it's actually only visible when it's useful? I believe we use such pattern in some other charts.
  2. Can we remove the collapsible and maybe change the name of the control to sth like "Custom comparison range"?
image

@Antonio-RiveroMartnez
Copy link
Member Author

  1. Can we add a description tooltip?
  2. Does week/month/year mean last week/last month/last year? If so, maybe we could add "last" prefix to the names?
image

There's is work in the making that will enhance this select control with more info to help users. But will be worked in a separated PR.

@Antonio-RiveroMartnez
Copy link
Member Author

Antonio-RiveroMartnez commented Feb 12, 2024

  1. Since "Filters (custom)" control works only if Range For Comparison is "Custom", can we make the visibility of that control dynamic, so that it's actually only visible when it's useful? I believe we use such pattern in some other charts.
  2. Can we remove the collapsible and maybe change the name of the control to sth like "Custom comparison range"?
image

Yes, this PR has not been updated with latest master but a PR got merged addressing this already #27054

@kgabryje
Copy link
Member

kgabryje commented Feb 12, 2024

That's a TOTAL nitpick but... the name "huge" sounds a bit overdramatic since the text isn't really that big 😆 + we could change the name "subheader" to "symbol" maybe?

image

@kgabryje
Copy link
Member

Yes, this PR has not been updated with latest master but a PR got merged addressing this already #27054

Nice!

Copy link
Member

@kgabryje kgabryje left a comment

Choose a reason for hiding this comment

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

LGTM, the bugs I listed can be worked on in the follow up PRs

- Extract comparison period calculation to an util file and make use of it when building the query. This is to support following work that will make use of that function and to prepare us when adding proper testing.
@john-bodley john-bodley removed the review:checkpoint Last PR reviewed during the daily review standup label Feb 12, 2024
@Antonio-RiveroMartnez Antonio-RiveroMartnez merged commit e8e208d into apache:master Feb 12, 2024
34 of 35 checks passed
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

sadpandajoe pushed a commit to preset-io/superset that referenced this pull request Feb 12, 2024
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 4.0.0 labels Apr 17, 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 plugins size/XL 🚢 4.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants