-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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(echarts-funnel): Implement % calculation type #26290
Conversation
Codecov ReportAttention:
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this 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.
There was a problem hiding this 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
const isFiltered = | ||
filterState.selectedValues && !filterState.selectedValues.includes(name); | ||
const firstStepPercent = value / (data[0][metricLabel] as number); | ||
const prevStepPercent = | ||
index === 0 ? 1 : value / (data[index - 1][metricLabel] as number); |
There was a problem hiding this comment.
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..
index === 0 ? 1 : value / (data[index - 1][metricLabel] as number); | |
index ? value / (data[index - 1][metricLabel] as number) : 1; |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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 👍
bind = op.get_bind() | ||
session = db.Session(bind=bind) | ||
|
||
for slc in session.query(Slice).filter(Slice.viz_type == "funnel"): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
bind = op.get_bind() | ||
session = db.Session(bind=bind) | ||
|
||
for slc in session.query(Slice).filter(Slice.viz_type == "funnel"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
cb5d447
to
8586275
Compare
There was a problem hiding this 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() |
There was a problem hiding this comment.
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)
session.commit() |
if percent_calculation: | ||
del params["percent_calculation_type"] | ||
slc.params = json.dumps(params) | ||
session.commit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
session.commit() |
TIL 🙂 done |
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:
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
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
Current: 0.21 s
10+: 0.21 s
100+: 0.12 s
1000+: 0.13 s