Skip to content

[fix] Ensure sunburst column ordering adheres to hierarchy#9011

Merged
john-bodley merged 1 commit into
apache:masterfrom
john-bodley:john-bodley--fix-sunburst-chart
Jan 24, 2020
Merged

[fix] Ensure sunburst column ordering adheres to hierarchy#9011
john-bodley merged 1 commit into
apache:masterfrom
john-bodley:john-bodley--fix-sunburst-chart

Conversation

@john-bodley
Copy link
Copy Markdown
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

@john-bodley john-bodley force-pushed the john-bodley--fix-sunburst-chart branch from 353d036 to a2c96ac Compare January 24, 2020 17:40
Comment thread superset/viz.py
def get_data(self, df: pd.DataFrame) -> VizData:
fd = self.form_data
cols = fd.get("groupby")
cols = fd.get("groupby") or []
Copy link
Copy Markdown
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", [])

Comment thread superset/viz.py
# 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 First shipped in 0.36.0 labels Feb 28, 2024
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
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 First shipped in 0.36.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants