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] Ensure sunburst column ordering adheres to hierarchy #9011

Merged

Conversation

john-bodley
Copy link
Member

@john-bodley john-bodley commented Jan 24, 2020

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

This PR fixes an issue where the values for the sunburst chart (which takes in a list of lists order by the hierarchical columns) were being named incorrectly. The reason being is the resulting pandas.DataFrame column ordering is not the same as the ordering defined in the hierarchy.

The fix is to simply re-order the pandas.DataFrame columns to adhere to the column ordering specified in the hierarchy.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TEST PLAN

Tested locally for a chart where there were more than one hierarchies defined and confirmed that the ordering of the layers in the chart were correct.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

REVIEWERS

to: @etr2460 @mistercrunch @williaster

@@ -1601,13 +1601,18 @@ class SunburstViz(BaseViz):

def get_data(self, df: pd.DataFrame) -> VizData:
fd = self.form_data
cols = fd.get("groupby")
cols = fd.get("groupby") or []
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cols = fd.get("groupby") or []
cols = fd.get("groupby", [])

# Re-order the columns as the query result set column ordering may differ from
# that listed in the hierarchy.
df = df[cols]
return df.to_numpy().tolist()
Copy link
Contributor

Choose a reason for hiding this comment

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

.values.tolist()?

Copy link
Member Author

Choose a reason for hiding this comment

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

@serenajiang per the documentation they mention,

Warning We recommend using DataFrame.to_numpy() instead.

@john-bodley john-bodley merged commit dcfa047 into apache:master Jan 24, 2020
@john-bodley john-bodley deleted the john-bodley--fix-sunburst-chart branch January 24, 2020 19:24
Copy link
Contributor

@williaster williaster left a comment

Choose a reason for hiding this comment

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

thanks @john-bodley !

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.36.0 labels Feb 28, 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/S 🚢 0.36.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants