-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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): Log scale option in Trends #22995
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.
@pauldambra please take a look (or reroute to somebody?)
About tests, the only proper way I see to test this is a visual test. It turns out visual tests don't draw the graphs (see this for example), so I actually don't see any good way to test this 🤷
I also wonder if I should keep the y axis tick values, or remove them, like this.
@@ -16,6 +16,7 @@ export const isLegacyTrendsFilter = (filters: Record<string, any> | undefined): | |||
'show_labels_on_series', | |||
'compare', | |||
'compare_to', | |||
'y_axis_scale_type', |
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 wonder if this part is needed? What is the legacy trends, are they still present?
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.
CC @thmsobrmlr
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.
(Thomas will be back on Monday, so will wait with merging this till then)
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.
It's not necessary to add here. This is a frontend side migration for notebook nodes (these already store "queries", whereas insights store "filters"). Legacy in this case refers to some properties that had been snake_cased and are now camelCased.
callback: (value) => { | ||
return formatPercentStackAxisValue(trendsFilter, value, isPercentStackView) | ||
}, | ||
}, | ||
grid: gridOptions, | ||
type: yAxisScaleType === 'log10' ? 'logarithmic' : 'linear', |
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.
Log scale graphs don't show zero values, see the screenshot. This can be fixed (as per this thread), I wonder if it's needed?
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.
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.
The only workaround I found that might work is
- Replace zeroes with 1e-12
- Set minimum of the graph to the minimum value among the trend values (so that the graph doesn't show 1e-12, like here)
- Figure out how to show "0" instead of "1e-12" when hovering, this person couldn't do it.
Do you think it's worth trying? Because that sounds like a lot and the result is not guaranteed.
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.
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.
Damn, thanks!
frontend/src/scenes/insights/EditorFilters/YAxisScaleSettings.tsx
Outdated
Show resolved
Hide resolved
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 to me, just got a suggestion about the zeros!
As for the schema handling, I'll tag @thmsobrmlr here, since he knows much better about the cleaning/conversion functions we've got
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.
Dug into Chart.js a bit, the chart feels pretty smooth now 😄
frontend/src/types.ts
Outdated
@@ -2159,6 +2159,7 @@ export interface TrendsFilterType extends FilterType { | |||
show_values_on_series?: boolean | |||
show_labels_on_series?: boolean | |||
show_percent_stack_view?: boolean | |||
y_axis_scale_type?: string // "log10" or "linear" |
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.
Maybe
y_axis_scale_type?: string // "log10" or "linear" | |
y_axis_scale_type?: 'log10' | 'linear' |
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.
Oh, makes sense, updated, thanks!
@@ -16,6 +16,7 @@ export const isLegacyTrendsFilter = (filters: Record<string, any> | undefined): | |||
'show_labels_on_series', | |||
'compare', | |||
'compare_to', | |||
'y_axis_scale_type', |
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.
CC @thmsobrmlr
...tickOptions, | ||
precision, | ||
display: !hideYAxis, | ||
...(yAxisScaleType !== 'log10' && { precision }), // Precision is not supported for the log scale |
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 can't leave precision as is here because types don't match then, because precision is not a field for log scale.
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.
Oh of course, I didn't notice TypeScript alerting me about this in VS Code, so missed that
# Conflicts: # frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.test.ts # frontend/src/queries/nodes/InsightQuery/utils/queryNodeToFilter.ts # frontend/src/queries/nodes/InsightViz/utils.ts # frontend/src/queries/schema.ts # frontend/src/scenes/insights/insightVizDataLogic.ts # frontend/src/scenes/insights/utils/compareInsightQuery.ts
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 work!
@@ -16,6 +16,7 @@ export const isLegacyTrendsFilter = (filters: Record<string, any> | undefined): | |||
'show_labels_on_series', | |||
'compare', | |||
'compare_to', | |||
'y_axis_scale_type', |
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.
It's not necessary to add here. This is a frontend side migration for notebook nodes (these already store "queries", whereas insights store "filters"). Legacy in this case refers to some properties that had been snake_cased and are now camelCased.
Problem
#22564
Changes
Add support for log scale for trends.
Does this work well for both Cloud and self-hosted?
Yes
How did you test this code?
Manually + a storybook test