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(explore): Fix generic X-axis time grain disappearing #21484

Merged
merged 1 commit into from
Sep 16, 2022

Conversation

codyml
Copy link
Member

@codyml codyml commented Sep 15, 2022

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 a visibility function expected an object, causing the Time Grain control to not appear when GENERIC_CHART_AXES is enabled. This PR fixes that issue.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:
localhost_9000_explore__form_data_key=Q2g3Sfv5XqzKpKsIiRHB1RIJN5YgORaHyI4gBNyg_eg3TyMDp8AEpDV72c2xJngw slice_id=116 preselect_filters=%7B%221389%22%3A+%7B%22platform%22%3A+%5B%22PS%22%2C+%22PS2%22%2C+%22PS3%22%2C+%22PS4%22%5D%2C+%22genr (1)

After:
localhost_9000_explore__form_data_key=Q2g3Sfv5XqzKpKsIiRHB1RIJN5YgORaHyI4gBNyg_eg3TyMDp8AEpDV72c2xJngw slice_id=116 preselect_filters=%7B%221389%22%3A+%7B%22platform%22%3A+%5B%22PS%22%2C+%22PS2%22%2C+%22PS3%22%2C+%22PS4%22%5D%2C+%22genre%22

TESTING INSTRUCTIONS

  • Ensure that Time Grain appears for charts supporting generic X-axis when GENERIC_CHART_AXES is enabled.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: GENERIC_CHART_AXES
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Copy link
Member

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

Comment on lines -200 to 206
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;
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

nits:

Suggested change
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;
}

@zhaoyongjie zhaoyongjie self-requested a review September 16, 2022 00:48
Copy link
Member

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

@zhaoyongjie zhaoyongjie merged commit 324e997 into apache:master Sep 16, 2022
jinghua-qa pushed a commit to preset-io/superset that referenced this pull request Sep 19, 2022
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XS 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants