豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

feat(echarts-funnel): Implement % calculation type#26290

Merged
kgabryje merged 3 commits intoapache:masterfrom
kgabryje:feat/funnel-percent-calc
Dec 22, 2023
Merged

feat(echarts-funnel): Implement % calculation type#26290
kgabryje merged 3 commits intoapache:masterfrom
kgabryje:feat/funnel-percent-calc

Conversation

@kgabryje
Copy link
Copy Markdown
Member

SUMMARY

Add "% Calculation" field to Funnel chart's control panel. Currently, the % of each level of funnel chart is calculated as % of total. This PR allows user to also display % of each level as % of the first step or % of previous step.

Example of calculations:

Value Percent of total Calculate from first step Calculate from previous step
100 57% 100% 100%
50 28% 50% 50%
25 14% 25% 50%

The default value for new charts is "Calculate from first step". For existing charts, a migration was added to keep "Percent of total" as selected option.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

image image image

TESTING INSTRUCTIONS

  1. Create a funnel chart
  2. Verify that the calculated percents of each step match expected values for each option

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
      Current: 0.21 s
      10+: 0.21 s
      100+: 0.12 s
      1000+: 0.13 s
  • Introduces new feature or API
  • Removes existing feature or API

@kgabryje kgabryje requested a review from a team as a code owner December 16, 2023 15:05
@kgabryje kgabryje requested a review from villebro December 16, 2023 15:06
@codecov
Copy link
Copy Markdown

codecov bot commented Dec 16, 2023

Codecov Report

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

Comparison is base (5e85f5c) 69.18% compared to head (adec022) 69.18%.

Files Patch % Lines
.../plugin-chart-echarts/src/Funnel/transformProps.ts 57.14% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #26290   +/-   ##
=======================================
  Coverage   69.18%   69.18%           
=======================================
  Files        1945     1945           
  Lines       75971    75981   +10     
  Branches     8467     8474    +7     
=======================================
+ Hits        52559    52566    +7     
  Misses      21225    21225           
- Partials     2187     2190    +3     
Flag Coverage Δ
hive 53.67% <ø> (ø)
javascript 56.52% <57.14%> (+<0.01%) ⬆️
mysql 78.06% <ø> (-0.03%) ⬇️
postgres 78.18% <ø> (ø)
presto 53.63% <ø> (ø)
python 82.86% <ø> (+<0.01%) ⬆️
sqlite 76.83% <ø> (ø)
unit 55.79% <ø> (ø)

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.

Copy link
Copy Markdown
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.

Looks great! Thanks for including the migration timings, too.

Copy link
Copy Markdown
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

Great improvement! Small theoretical scalability improvement for the migration, other than that LGTM

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: maybe this slightly shortens it, although it's maybe less explicit..

Suggested change
index === 0 ? 1 : value / (data[index - 1][metricLabel] as number);
index ? value / (data[index - 1][metricLabel] as number) : 1;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

TBH in case such as this, I think it's better to be explicit that we perform an operation only for the first element of an array, rather than when "index is not falsy"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, very good point. This was mostly a knee-jerk reaction that I often get when I get when I see something that can be shortened with truthy/falsy checking. Carry on 👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we use paginated_update here? I'm not expecting people to have 100k funnel charts, but as a principle, I think it's a good idea to always paginate updates when possible.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here

@kgabryje kgabryje force-pushed the feat/funnel-percent-calc branch from cb5d447 to 8586275 Compare December 21, 2023 16:55
Copy link
Copy Markdown
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

We should remove the explicit commit, as that's already happening in the paginator

if not percent_calculation:
params["percent_calculation_type"] = "total"
slc.params = json.dumps(params)
session.commit()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we should be committing on the changes (paginated_update should do that for us)

Suggested change
session.commit()

if percent_calculation:
del params["percent_calculation_type"]
slc.params = json.dumps(params)
session.commit()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same here

Suggested change
session.commit()

@kgabryje
Copy link
Copy Markdown
Member Author

We should remove the explicit commit, as that's already happening in the paginator

TIL 🙂 done

@kgabryje kgabryje merged commit 5400d30 into apache:master Dec 22, 2023
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 4.0.0 First shipped in 4.0.0 labels Apr 17, 2024
vinothkumar66 pushed a commit to vinothkumar66/superset that referenced this pull request Nov 11, 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 🚢 4.0.0 First shipped in 4.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants