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

fix: display label as tooltip title on stickiness graph #24728

Merged
merged 5 commits into from
Sep 2, 2024

Conversation

ghoti143
Copy link
Contributor

@ghoti143 ghoti143 commented Aug 31, 2024

Problem

As described in #22209, the <LineGraph /> component wasn't properly rendering tooltip titles in the context of the stickiness graph. This was due to the fact that the filter interval was undefined so the IntervalType defaulted to day.

? `${getFormattedDate(date, seriesData?.[0]?.filter?.interval)} (${

export function getFormattedDate(input?: string | number, interval: IntervalType = 'day'): string {

Changes

As described in #22440 (comment), the interval value is not present in the api response. Even if it was present, however, it could be argued that 3 weeks (EDT), 4 weeks (UTC), and 2 days (PDT) are not good titles (the presence of the timezone makes no sense in this context). Thus it was decided to avoid the date formatting all together when the date value is numeric by returning the label value from the altTitle function. This is the same value used on the graph's X axis.

Below are some comparisons showing the difference b/w PostHog:master and ghoti143:bug-tooltip-title

Stickiness graph grouped by week

PostHog:master

image

ghoti143:bug-tooltip-title

image

Stickiness graph grouped by day

PostHog:master

image

ghoti143:bug-tooltip-title

image

Stickiness graph grouped by hour

PostHog:master

image

ghoti143:bug-tooltip-title

image

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

Manually tested the Trends graph to ensure that it still renders the titles using the getFormattedDate() function and doesn't display the labels.

image
image

Copy link
Collaborator

@Twixes Twixes left a comment

Choose a reason for hiding this comment

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

Excellent improvement, thank you!

@Twixes Twixes enabled auto-merge (squash) September 2, 2024 09:08
@Twixes Twixes merged commit c9cfc64 into PostHog:master Sep 2, 2024
92 checks passed
@ghoti143 ghoti143 deleted the bug-tooltip-title branch September 11, 2024 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants