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

feat: add ECharts Pie chart #10966

Merged
merged 7 commits into from
Sep 22, 2020

Conversation

villebro
Copy link
Member

@villebro villebro commented Sep 19, 2020

SUMMARY

Replace the existing NVD3 Pie chart with an ECharts based chart (see apache-superset/superset-ui#772) and bump superset-ui packages to 0.15.3. Also fixes color problems on boxplot and wordcloud.

BEFORE

image

AFTER

image
pie_anim

TEST PLAN

ADDITIONAL INFORMATION

@junlincc
Copy link
Member

they look awesome!!thank you Ville!

@villebro villebro force-pushed the villebro/bump-superset-ui-0.15.3 branch from f2a4b9b to f245670 Compare September 19, 2020 08:16
@villebro villebro changed the title feat: introduce echarts pie chart feat: add ECharts Pie chart Sep 19, 2020
@pull-request-size pull-request-size bot added size/L and removed size/M labels Sep 19, 2020
Comment on lines -1389 to -1443
class TestDistributionPieViz(SupersetTestCase):
base_df = pd.DataFrame(
data={
"intcol": [1, 2, 3, 4, None],
"floatcol": [1.0, 0.2, 0.3, 0.4, None],
"strcol_a": ["a", "a", "a", "a", None],
"strcol": ["a", "b", "c", None, "d"],
}
)

@staticmethod
def get_cols(data: List[Dict[str, Any]]) -> Set[str]:
return set([row["x"] for row in data])

def test_bool_groupby(self):
datasource = self.get_datasource_mock()
df = pd.DataFrame(data={"intcol": [1, 2, None], "boolcol": [True, None, False]})

pie_viz = viz.DistributionPieViz(
datasource, {"metrics": ["intcol"], "groupby": ["boolcol"]},
)
data = pie_viz.get_data(df)
assert self.get_cols(data) == {"True", "False", "<NULL>"}

def test_string_groupby(self):
datasource = self.get_datasource_mock()
pie_viz = viz.DistributionPieViz(
datasource, {"metrics": ["floatcol"], "groupby": ["strcol"]},
)
data = pie_viz.get_data(self.base_df)
assert self.get_cols(data) == {"<NULL>", "a", "b", "c", "d"}

def test_int_groupby(self):
datasource = self.get_datasource_mock()
pie_viz = viz.DistributionPieViz(
datasource, {"metrics": ["floatcol"], "groupby": ["intcol"]},
)
data = pie_viz.get_data(self.base_df)
assert self.get_cols(data) == {"<NULL>", "1", "2", "3", "4"}

def test_float_groupby(self):
datasource = self.get_datasource_mock()
pie_viz = viz.DistributionPieViz(
datasource, {"metrics": ["intcol"], "groupby": ["floatcol"]},
)
data = pie_viz.get_data(self.base_df)
assert self.get_cols(data) == {"<NULL>", "1", "0.2", "0.3", "0.4"}

def test_multi_groupby(self):
datasource = self.get_datasource_mock()
pie_viz = viz.DistributionPieViz(
datasource, {"metrics": ["floatcol"], "groupby": ["intcol", "strcol"]},
)
data = pie_viz.get_data(self.base_df)
assert self.get_cols(data) == {"1, a", "2, b", "3, c", "4, <NULL>", "<NULL>, d"}
Copy link
Member Author

Choose a reason for hiding this comment

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

@codecov-commenter
Copy link

Codecov Report

Merging #10966 into master will decrease coverage by 0.10%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10966      +/-   ##
==========================================
- Coverage   65.80%   65.69%   -0.11%     
==========================================
  Files         815      815              
  Lines       38327    38304      -23     
  Branches     3600     3600              
==========================================
- Hits        25221    25165      -56     
- Misses      13002    13032      +30     
- Partials      104      107       +3     
Flag Coverage Δ
#cypress 56.28% <ø> (-0.42%) ⬇️
#javascript 61.75% <ø> (ø)
#python 61.41% <100.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...-frontend/src/visualizations/presets/MainPreset.js 100.00% <ø> (ø)
superset/viz.py 57.39% <100.00%> (-0.52%) ⬇️
...et-frontend/src/SqlLab/reducers/getInitialState.js 33.33% <0.00%> (-16.67%) ⬇️
...rontend/src/SqlLab/components/TabbedSqlEditors.jsx 76.97% <0.00%> (-5.27%) ⬇️
...rontend/src/SqlLab/components/SqlEditorLeftBar.jsx 44.00% <0.00%> (-4.00%) ⬇️
...end/src/SqlLab/components/TemplateParamsEditor.jsx 88.57% <0.00%> (-2.86%) ⬇️
superset-frontend/src/SqlLab/actions/sqlLab.js 60.25% <0.00%> (-2.36%) ⬇️
superset-frontend/src/SqlLab/reducers/sqlLab.js 37.91% <0.00%> (-1.67%) ⬇️
...rontend/src/SqlLab/components/AceEditorWrapper.tsx 59.49% <0.00%> (-1.27%) ⬇️
...erset-frontend/src/SqlLab/components/SqlEditor.jsx 52.12% <0.00%> (-1.22%) ⬇️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 557a303...854a889. Read the comment docs.

@villebro villebro force-pushed the villebro/bump-superset-ui-0.15.3 branch 4 times, most recently from 9c28b84 to fa3ec04 Compare September 21, 2020 08:03
@villebro villebro force-pushed the villebro/bump-superset-ui-0.15.3 branch from fa3ec04 to ba75cdd Compare September 21, 2020 08:04
Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

Fantastic! Happy to see more of viz.py go away, and this first drop-in replacement for NVD3! And tests in the more sensible place! So many good things happening here.

@ktmud / @kristw Please double check that this PR (and ones like it) won't break any use cases you're aware of. I would assume people will be excited to see this one landing though.

@villebro villebro merged commit a9eab33 into apache:master Sep 22, 2020
@villebro villebro deleted the villebro/bump-superset-ui-0.15.3 branch September 22, 2020 16:27
@ktmud
Copy link
Member

ktmud commented Sep 22, 2020

Thank you! The new pie chart looks so much beautifuler!

auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
* feat: introduce echarts pie chart

* lint

* remove viz.py shim

* remove tests

* fix cypress test

* fix test
@benceorlai
Copy link

Roadmap: apache-superset/superset-roadmap#48

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

Successfully merging this pull request may close these issues.

8 participants