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 rescaling y-axis edge cases #1437

Merged
merged 1 commit into from
Jun 22, 2021
Merged

Fix rescaling y-axis edge cases #1437

merged 1 commit into from
Jun 22, 2021

Conversation

Iinh
Copy link
Contributor

@Iinh Iinh commented Jun 22, 2021

This PR fixes 3 things that we noticed after testing dev:

  1. 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.

  2. 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)

  3. @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.

@Iinh Iinh requested a review from emtwo June 22, 2021 17:08
Copy link
Contributor

@emtwo emtwo left a 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! :)

Copy link
Contributor Author

@Iinh Iinh left a 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.

Comment on lines +147 to +152
const linearMetrics = [
'histogram-linear',
'quantity',
'counter',
'labeled_counter',
];
Copy link
Contributor Author

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.

Working example of a counter metric:
2021-06-22 12 28 21

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;
Copy link
Contributor Author

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.

match

Comment on lines +199 to +205
if (data[0].transformedPercentiles) {
visiblePercentiles.forEach((p) => {
yData = yData.concat([
...data.map((arr) => arr.transformedPercentiles[p]),
]);
});
}
Copy link
Contributor Author

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.

2021-06-22 12 03 58

Copy link
Contributor

@emtwo emtwo left a 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!

@Iinh Iinh merged commit 2a6770e into main Jun 22, 2021
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