Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

feat(plugin-chart-echarts): Emit cross filters for pie and boxplot #1010

Merged
merged 12 commits into from
Mar 19, 2021

Conversation

maloun96
Copy link
Contributor

@maloun96 maloun96 commented Mar 16, 2021

Add checkbox control to disable/enable the emitting filter for the pie chart

Screen.Recording.2021-03-16.at.13.00.02.mov
Screen.Recording.2021-03-18.at.12.33.47.mov

@maloun96 maloun96 requested a review from a team as a code owner March 16, 2021 10:58
@request-info
Copy link

request-info bot commented Mar 16, 2021

We would appreciate it if you could provide us with more info about this issue/pr!

@vercel
Copy link

vercel bot commented Mar 16, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/superset/superset-ui/2o9sZBv6DJ3y2PerQhJtgaF52HYZ
✅ Preview: https://superset-ui-git-fork-maloun96-enable-emitting-filter-superset.vercel.app

@codecov
Copy link

codecov bot commented Mar 16, 2021

Codecov Report

Merging #1010 (f1630df) into master (03e697b) will decrease coverage by 0.05%.
The diff coverage is 22.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1010      +/-   ##
==========================================
- Coverage   27.95%   27.90%   -0.06%     
==========================================
  Files         414      417       +3     
  Lines        8535     8602      +67     
  Branches     1218     1237      +19     
==========================================
+ Hits         2386     2400      +14     
- Misses       5992     6043      +51     
- Partials      157      159       +2     
Impacted Files Coverage Δ
...lugin-chart-echarts/src/BoxPlot/EchartsBoxPlot.tsx 0.00% <0.00%> (ø)
plugins/plugin-chart-echarts/src/BoxPlot/index.ts 0.00% <ø> (ø)
plugins/plugin-chart-echarts/src/BoxPlot/types.ts 0.00% <0.00%> (ø)
...lugins/plugin-chart-echarts/src/Pie/EchartsPie.tsx 0.00% <0.00%> (ø)
...gins/plugin-chart-echarts/src/Pie/controlPanel.tsx 66.66% <0.00%> (-33.34%) ⬇️
plugins/plugin-chart-echarts/src/Pie/index.ts 0.00% <ø> (ø)
plugins/plugin-chart-echarts/src/Pie/types.ts 100.00% <ø> (ø)
...ins/plugin-chart-echarts/src/components/Echart.tsx 0.00% <0.00%> (ø)
plugins/plugin-chart-echarts/src/types.ts 100.00% <ø> (ø)
...s/plugin-chart-echarts/src/BoxPlot/controlPanel.ts 50.00% <50.00%> (ø)
... and 7 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 03e697b...f1630df. Read the comment docs.

@suddjian
Copy link
Member

I'd like to better understand the motivation for this change. There is currently a project to enable cross-filtering of charts on Dashboards, but this PR doesn't look like it is compatible with that feature. Will cross-filtering support your use case?

Copy link
Contributor

@villebro villebro left a comment

Choose a reason for hiding this comment

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

A few comments

(values: string[]) => {
const groupbyValues = values.map(value => labelMap[value]);

setDataMask({
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to check if emitFilter is enabled before calling the hook.

config: {
type: 'CheckboxControl',
label: t('Enable emitting filters'),
default: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we pick the default value from DEFAULT_FORM_DATA?

(values: string[]) => {
const groupbyValues = values.map(value => labelMap[value]);

setDataMask({
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we also need to check if emitFilter is enabled.

Comment on lines 59 to 67
currentState: {
value: groupbyValues ?? null,
},
},
ownFilters: {
currentState: {
selectedValues: values,
},
},
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
currentState: {
value: groupbyValues ?? null,
},
},
ownFilters: {
currentState: {
selectedValues: values,
},
},
currentState: {
value: groupbyValues.length ? groupbyValues : null,
},
},
ownFilters: {
currentState: {
selectedValues: values.length ? values : null,
},
},

Comment on lines 59 to 67
currentState: {
value: groupbyValues ?? null,
},
},
ownFilters: {
currentState: {
selectedValues: values,
},
},
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
currentState: {
value: groupbyValues ?? null,
},
},
ownFilters: {
currentState: {
selectedValues: values,
},
},
currentState: {
value: groupbyValues.length ? groupbyValues : null,
},
},
ownFilters: {
currentState: {
selectedValues: values.length ? values : null,
},
},

@villebro villebro changed the title feat(plugin-chart-echarts): Enable / Disable emitting filter for pie chart feat(plugin-chart-echarts): Emit cross filters for pie and boxplot Mar 19, 2021
@villebro
Copy link
Contributor

I'd like to better understand the motivation for this change. There is currently a project to enable cross-filtering of charts on Dashboards, but this PR doesn't look like it is compatible with that feature. Will cross-filtering support your use case?

This PR has been done in cooperation with me and Simcha, and implements the cross filter hook (I did the groundwork here which this PR builds on: #1009). So it's fully compatible with the cross filtering feature that's been worked on lately.

@villebro villebro merged commit e7242cc into apache-superset:master Mar 19, 2021
NejcZdovc pushed a commit to blotoutio/superset-ui that referenced this pull request Apr 20, 2021
…pache-superset#1010)

* feat(plugin-chart-echarts): emit filter events when clicking on slice

* feat(plugin-chart-echarts): enable emitting filter

* clean up filter state

* check eventHandlers by emitFilter flag

* feat(plugin-chart-echarts): multiple choices for filter

* WIP

* feat(plugin-chart-echarts): select multiple values

* add conditional control item for emitting filter

* add cross filter for box plot chart

* refactor: combine values and indexes single object

* fix: eslint

* Add default emitFilter for BoxPlot. Check emit filter before handle crossFilter

Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants