-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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(insights): add % of total option to line, bar and area trend insights (fixes #13728, #11276) #16699
Conversation
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 good so far to me...
@thmsobrmlr is way more familiar than me with insights these days 🥇 tagging him for visibility
frontend/src/queries/nodes/InsightViz/insightDisplayConfigLogic.ts
Outdated
Show resolved
Hide resolved
Don't have time for a full review at the moment, but here are some fly-by comments:
|
@thmsobrmlr point 1 and 3 can be easily achievable. I will make the required changes and let you know. For point 2, you can suggest me the label name :) |
Hi @thmsobrmlr , I have done points 1 and 3 as suggested by you and added the percentStack option view for the area and line graph as well. |
I've not made time to run it yet but from a pass over the code this is looking really good @Arun-chaitanya 🙌 |
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.
Had a more in-depth look and unfortunately I have quite a bunch of follow up comments code wise and I think I also found two bugs:
-
When you go to e.g. a funnels insight, then go back to the the trends insight, the option for the percent stack isn't displayed initially and you need to reload the page to see the option
-
For an insight with a breakdown it doesn't seem to aggregate the values correctly
Hope my comments are clear & you aren't discouraged by them. Let me know if you need clarification or assistance with anything.
@@ -106,6 +106,22 @@ export const getShowValueOnSeries = (query: InsightQueryNode): boolean | undefin | |||
} | |||
} | |||
|
|||
export const getShowPercentStackView = (query: InsightQueryNode): boolean | undefined => { | |||
if (PERCENT_STACK_VIEW_DISPLAY_TYPE.includes(getDisplay(query) as ChartDisplayType)) { |
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'd like to split this function up into two parts:
- one part that should stay in this function related to getting the
show_percent_stack_view
from the respective insight filter (this is what other functions in this file do as well) - the other part where we override the value with
undefined
for chart display types that don't support the percent stack view. this should go in a kea selector withdisplay
andshowPercentStackView
as input and the same output
I think there is also a bug since this only considers the case where the query has a display set, but not the default display.
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.
Also only trends insights support the percent stack view (see below how you implemented formatYAxisLabel)
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.
Resolved: Also only trends insights support the percent stack view (see below how you implemented formatYAxisLabel)
Resolved: I think there is also a bug since this only considers the case where the query has a display set, but not the default display.
About the above two points, I understood the first point, the second point was not that clear to me.
frontend/src/scenes/insights/EditorFilters/percentStackViewLogic.ts
Outdated
Show resolved
Hide resolved
7471be0
to
d60f811
Compare
@thmsobrmlr I have resolved most of the comments. And 1st of the 2 bugs is solved. I am not able to reproduce the 2nd bug as I don't have much data in my test env. Is there any way I can reproduce it? Also, can you comment on the above 1 doubt? |
@thmsobrmlr I was also able to solve the second bug also. Pheew! Now I just have one doubt about your comment, but If I am right I am managing that thing by passing checked={!!showPercentStackView} to Checkbox, so I need not manage undefined case specially. But you can give the correct opinion. |
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.
Thank you again for the PR @Arun-chaitanya, everything is looking good now & it's great to finally get this feature in. I'll merge the PR on Monday.
Problem
Allow 100% stacked area/bar chart (#13728)
Changes
Without Percent Stack View
![Screenshot 2023-07-20 at 11 04 12 PM](https://private-user-images.githubusercontent.com/44457256/254963035-d3b66cda-cb90-4932-b580-7c8ac8545226.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2ODUyMDksIm5iZiI6MTczOTY4NDkwOSwicGF0aCI6Ii80NDQ1NzI1Ni8yNTQ5NjMwMzUtZDNiNjZjZGEtY2I5MC00OTMyLWI1ODAtN2M4YWM4NTQ1MjI2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDA1NDgyOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTljZmFkNDU0ZmZhMjE5ZWJiZjNiMDEzMGM3MWFlMmVmOWJjMmRiNGY1ZWU3MDNmNWI1NDFkNDNiOGJmMWI1NWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.JKrrBf2a7bAxPzOeBE8y9EbHObApw8kMhJOjL4Sxn0c)
![Screenshot 2023-07-20 at 11 04 20 PM](https://private-user-images.githubusercontent.com/44457256/254963080-cb36e111-6066-40aa-8427-604e17fe4765.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2ODUyMDksIm5iZiI6MTczOTY4NDkwOSwicGF0aCI6Ii80NDQ1NzI1Ni8yNTQ5NjMwODAtY2IzNmUxMTEtNjA2Ni00MGFhLTg0MjctNjA0ZTE3ZmU0NzY1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDA1NDgyOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNiZWQ3MDk4YTU5MmIwNDg1NGMzODUzOWE0NjFlNzg2MTliYzQ3NzlmYWY3YWQ2NzIzY2E5MTBmZDA3MGFiYjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.J2bXnyfBSfUwdYRNL5-rxdlHI6kMufhu3QFmqs46uNE)
With Percent Stack View
Bugs Noticed - Update (FIXED)
I can right away see one bug that if I switch on "Show value on series" at first it is showing percentages as values, but when I hover it is showing their original value.
Screen.Recording.2023-07-20.at.11.06.09.PM.mov
I am working on it. @pauldambra
👉 Stay up-to-date with PostHog coding conventions for a smoother review.
How did you test this code?