-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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(explore): Fix generic X-axis time grain disappearing #21484
fix(explore): Fix generic X-axis time grain disappearing #21484
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.
After the option
is changed from an Object to an Array, we have to loop through the entire Array. This is an O(n) operation.
if (isPhysicalColumn(xAxisValue)) { | ||
return !!xAxis?.options?.[xAxisValue]?.is_dttm; | ||
if (isPhysicalColumn(xAxisValue) && Array.isArray(xAxis?.options)) { | ||
for (let i = 0; i < xAxis.options.length; i += 1) { | ||
if (xAxis.options[i].column_name === xAxisValue) { | ||
return !!xAxis.options[i].is_dttm; | ||
} | ||
} | ||
} |
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.
nits:
if (isPhysicalColumn(xAxisValue)) { | |
return !!xAxis?.options?.[xAxisValue]?.is_dttm; | |
if (isPhysicalColumn(xAxisValue) && Array.isArray(xAxis?.options)) { | |
for (let i = 0; i < xAxis.options.length; i += 1) { | |
if (xAxis.options[i].column_name === xAxisValue) { | |
return !!xAxis.options[i].is_dttm; | |
} | |
} | |
} | |
if (isPhysicalColumn(xAxisValue)) { | |
return !!(xAxis?.options ?? []).find(col => col.column_name === xAxisValue)?.is_dttm; | |
} |
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.
Merged this PR first because Time Grain blocked testing others' fixes. @codyml thanks for the quick fixing!
(cherry picked from commit 324e997)
SUMMARY
In #21315, I refactored shared controls so feature flag checking for drag and drop was done in React render instead on module load. As part of that, I modified the config object's
options
property to be an array instead of an object for some DnD shared controls, because non-DnD versions expected an array and I wanted to merge DnD and non-DnD config objects. But, I missed a place where avisibility
function expected an object, causing the Time Grain control to not appear whenGENERIC_CHART_AXES
is enabled. This PR fixes that issue.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before:
After:
TESTING INSTRUCTIONS
Time Grain
appears for charts supporting generic X-axis whenGENERIC_CHART_AXES
is enabled.ADDITIONAL INFORMATION
GENERIC_CHART_AXES