superset icon indicating copy to clipboard operation
superset copied to clipboard

feat: Adds the ECharts Histogram chart

Open michael-s-molina opened this issue 1 year ago • 1 comments

SUMMARY

This PR creates the ECharts Histogram chart which is used to display the distribution of a dataset by representing the frequency or count of values within different ranges or bins. It helps visualize patterns, clusters, and outliers in the data and provides insights into its shape, central tendency, and spread.

This plugin uses numpy.histogram to compute the distribution on the server side. It supports a single numeric column and multiple dimensions. Aggregations are not supported.

The legacy Histogram is one of the plugins that are currently preventing us from upgrading to React 17. With this PR, we should be able to create a migration script for legacy charts and remove another blocker for the React upgrade.

Fixes https://github.com/apache/superset/issues/24064

TODO:

  • Add more controls
  • Optimize code
  • Add tests
  • Fix CI issues

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screenshot 2024-05-23 at 16 03 12 Screenshot 2024-05-23 at 16 24 47 Screenshot 2024-05-23 at 16 28 51

TESTING INSTRUCTIONS

Check all features.

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

michael-s-molina avatar May 23 '24 19:05 michael-s-molina

Codecov Report

Attention: Patch coverage is 43.75000% with 54 lines in your changes missing coverage. Please review.

Project coverage is 61.09%. Comparing base (76d897e) to head (a90451a). Report is 1094 commits behind head on master.

Files with missing lines Patch % Lines
...ugin-chart-echarts/src/Histogram/transformProps.ts 0.00% 36 Missing :warning:
...s/plugin-chart-echarts/src/Histogram/Histogram.tsx 0.00% 8 Missing :warning:
.../explore/components/ExploreViewContainer/index.jsx 60.00% 2 Missing and 2 partials :warning:
...s/plugin-chart-echarts/src/Histogram/buildQuery.ts 0.00% 2 Missing :warning:
superset/utils/pandas_postprocessing/histogram.py 90.90% 2 Missing :warning:
...lugin-chart-echarts/src/Histogram/controlPanel.tsx 50.00% 1 Missing :warning:
...lugins/plugin-chart-echarts/src/Histogram/index.ts 50.00% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #28652      +/-   ##
==========================================
+ Coverage   60.48%   61.09%   +0.60%     
==========================================
  Files        1931     1951      +20     
  Lines       76236    77568    +1332     
  Branches     8568     8744     +176     
==========================================
+ Hits        46114    47388    +1274     
- Misses      28017    28049      +32     
- Partials     2105     2131      +26     
Flag Coverage Δ
hive 48.94% <21.73%> (-0.23%) :arrow_down:
presto 53.53% <21.73%> (-0.27%) :arrow_down:
python 64.62% <91.30%> (+1.13%) :arrow_up:
unit 59.01% <91.30%> (+1.38%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 23 '24 19:05 codecov[bot]

rusackas avatar May 29 '24 15:05 rusackas

200w

mistercrunch avatar May 29 '24 20:05 mistercrunch

Thanks for the review @kgabryje! I think I addressed all your comments, including adding helpful tooltips. Thanks for pointing that out! It was a copy/paste from the legacy chart.

michael-s-molina avatar May 31 '24 17:05 michael-s-molina

@michael-s-molina It looks like normalised histogram doesn't reach 1 for tallest bar - 1st screenshot is the new plugin, 2nd is the old one

image image

kgabryje avatar Jun 02 '24 09:06 kgabryje

1 more comment - why do we have a select component for num column instead of drag&drop? We could limit the accepted column by type in dnd

kgabryje avatar Jun 03 '24 14:06 kgabryje

@michael-s-molina It looks like normalised histogram doesn't reach 1 for tallest bar - 1st screenshot is the new plugin, 2nd is the old one

@kgabryje I changed the normalize calculation and updated the tooltip. It should be correct now. Keep in mind that it will not match the legacy version because that was wrong too 😅 .

michael-s-molina avatar Jun 03 '24 16:06 michael-s-molina

1 more comment - why do we have a select component for num column instead of drag&drop? We could limit the accepted column by type in dnd

@kgabryje I changed the control to use drag-and-drop as you suggested.

michael-s-molina avatar Jun 03 '24 18:06 michael-s-molina

Ephemeral environment shutdown and build artifacts deleted.

github-actions[bot] avatar Jun 04 '24 12:06 github-actions[bot]