-
Notifications
You must be signed in to change notification settings - Fork 23
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 rescaling y-axis edge cases #1437
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.
Code looks good to me! Would you mind putting some screenshots of the changes you made for reference. Helpful especially since I'm not super familiar with the codebase. Thank you! :)
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.
@emtwo Of course! I included some screenshots below along with my thought process behind this change.
const linearMetrics = [ | ||
'histogram-linear', | ||
'quantity', | ||
'counter', | ||
'labeled_counter', | ||
]; |
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.
These metrics have linear graph type, but initially I only had histogram-linear
and quantity
on this list, so other linear graphs such as counter
and labeled_counter
did not scale (see counter and labeled_counter)
After adding them to the list, we can rescale y-axis for counter
and labeled_counter
now.
yScaleType === 'scalePoint' | ||
) { | ||
// do not change yDomain when all percentiles are selected | ||
// (we want the graph to match the violin plot initially) | ||
if ($store.visiblePercentiles.length === 5) return yDomain; |
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 were not able to rescale the y axis because we used to have the same set of data for yDomain regardless of toggled percentiles. In my last change, I calculated the yDomain range to only include the highest and smallest values available of the shown percentile lines, so that this array will dynamically change if a percentile is toggled. However this means that the range is more tightly scoped than before, and you can see the difference in initial behavior here: dev vs stage.
@rafrombrc wanted the initial range of the graph to match the violin plot graph, so I added this condition here to preserve the yDomain range if all percentile lines are visible (i.e no percentiles toggled yet)
Below you can see that the yDomain range matches the violin plot initially.
if (data[0].transformedPercentiles) { | ||
visiblePercentiles.forEach((p) => { | ||
yData = yData.concat([ | ||
...data.map((arr) => arr.transformedPercentiles[p]), | ||
]); | ||
}); | ||
} |
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.
Currently on dev this metric doesn't have any data. After changing data source to $store.transformedPercentiles
(which I believe is the main source of data for Glean metrics, we use $store.percentiles
for desktop probes), it does now.
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.
This looks great! Thanks so much for the screen captures, @Iinh!
This PR fixes 3 things that we noticed after testing dev:
Use transformed percentile data for Android metrics. For example, the graph for this metric doesn't display any data because we were using data from the regular percentile source (like we did for telemetry probes), instead of sourcing from
transformedPercentiles
, which is for Android metrics.Add more metrics to linear graph group, such as counter and labeled_counter. This will let us rescale y-axis for these metrics too, since currently they do not on dev (see examples for counter and labeled_counter)
@rafrombrc pointed out that we should keep the y domain range to match the violin plot at first, and only rescale it when a percentile is toggled. I added a condition to fix this.