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

[dashboard] After update filter, trigger new queries when charts are visible #7233

Merged

Conversation

graceguo-supercat
Copy link

@graceguo-supercat graceguo-supercat commented Apr 5, 2019

SUMMARY

Currently Superset dashboard only support global filters, which means filter will apply to all charts in the dashboard (except the immune ones).

After user apply filter, dashboard will trigger new queries for all charts in DOM, even for those under other tabs. Many users feel confused whether charts under other tabs are affected by filter, or which charts are affected by filter. At the same time, if there are many charts in DOM, trigger queries for charts under other invisible tabs will make charts in current tab looks very slow.

Proposed solution:
After user updates a filter, trigger new queries when charts are visible.

  • If both filter and chart are visible (under same tab), new queries should be triggered right away.
  • If charts are not visible when filter is updated, chart will not be updated at the same time. But when user click into a new tab, all the charts become visible should trigger updated queries.

Implementation and Performance:

  • Dashboard used react-bootstrap TabContainer as root level tab. To avoid expensive mounts/unmounts of the entire dashboard upon adding/removing top-level tabs, we set unmountOnExit={false}. This means it will not remove rendered charts from the DOM when they are no longer visible. And when charts data/state is updated, each chart will re-render itself.

  • old filter flow:
    User update a filter,
    => change filter state in redux
    => Dashboard component pass down the changes to its children components
    => in Dashboard componentDidUpdate: call runQuery async action creator for every chart, which will trigger a new query for every chart
    => dashboard/components/gridComponents/Chart.jsx decide shouldComponentUpdate: only check if chart has valid props changes.
    => after chart's state is updated, each chart will trigger its render function

When dashboard calling runQuery for each chart, it doesn't check visibility of the charts. Since tab/charts visibility is stored in component state not global redux, dashboard component has no awareness of each chart visibility. It will send updated queries even when charts are not visible. This update all charts together solution has another lack for clearance: when user clicks another tab, the data is already updated, but there is no clear indicator to tell user when these charts are updated.

  • new filter flow:
    Instead of using Dashboard component to trigger query for each chart, new filter flow delegate the logic to component (react component props and redux state).
    • Chart component: added componentDidUpdate. After any chart is mounted, if its query parameters are changed (from props), we should allow chart run updated query and re-render.
    • Components in dashboard (row, column, tab, tabs, chartHolder): add isComponentVisible props. It passes visibility status from parents to it children component.

User update a filter,
=> change filter state in redux
=> Dashboard component pass down the changes to its children components
=> in Dashboard component componentDidUpdate: set each chart's triggerQuery flag be true, which mean chart should be updated. Here we don't trigger query anymore.
=> dashboard/components/gridComponents/Chart.jsx decide shouldComponentUpdate: besides valid props changes, chart only updates when it's visible.
=> chart's props changes. In componentDidUpdate, if there were a filter update, chart will have triggerQuery flag set true. And chart's query parameters are also updated, it will trigger a new query and re-render after data come back.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:
byqgGBmtqQ

After:
SB32t0Cyx5

TEST PLAN
  1. create dashboard with root level tabs and row level tabs. there should have a filter_box in dashboard.
  2. load dashboard, visit charts in different tabs.
  3. Change filter box value, you should see queries from charts in the same tab were sent to server-side.
  4. select another tab, you will see queries from current visible tabs were sent out.
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
[x] Fixes bug
[x] Refactors code
[x] Adds test(s)
REVIEWERS

@michellethomas @kristw @xtinec @williaster @mistercrunch

@graceguo-supercat graceguo-supercat force-pushed the gg-DashApplyFilter branch 5 times, most recently from 10bbc61 to 422d0f7 Compare April 11, 2019 06:20
@codecov-io
Copy link

codecov-io commented Apr 11, 2019

Codecov Report

Merging #7233 into master will increase coverage by 0.02%.
The diff coverage is 35.08%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7233      +/-   ##
==========================================
+ Coverage   65.08%   65.11%   +0.02%     
==========================================
  Files         429      430       +1     
  Lines       21002    21044      +42     
  Branches     2338     2342       +4     
==========================================
+ Hits        13669    13702      +33     
- Misses       7217     7226       +9     
  Partials      116      116
Impacted Files Coverage Δ
...ts/src/dashboard/components/gridComponents/Row.jsx 87.5% <ø> (ø) ⬆️
...s/src/dashboard/components/gridComponents/Tabs.jsx 63.93% <ø> (ø) ⬆️
...ashboard/components/gridComponents/ChartHolder.jsx 84.84% <ø> (ø) ⬆️
...ts/src/dashboard/containers/DashboardComponent.jsx 100% <ø> (ø) ⬆️
...ts/src/explore/components/ExploreViewContainer.jsx 45.71% <ø> (+13.79%) ⬆️
...sets/src/dashboard/components/DashboardBuilder.jsx 81.81% <ø> (ø) ⬆️
...src/dashboard/components/gridComponents/Column.jsx 87.87% <ø> (ø) ⬆️
.../assets/src/dashboard/components/DashboardGrid.jsx 61.11% <ø> (ø) ⬆️
...rset/assets/src/dashboard/containers/Dashboard.jsx 0% <ø> (ø) ⬆️
superset/assets/src/chart/Chart.jsx 10.86% <0%> (-1.64%) ⬇️
... and 8 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 46579b1...cb86b53. Read the comment docs.

@graceguo-supercat graceguo-supercat changed the title [wip][dashboard] After update filter, trigger queries only when charts are… [dashboard] After update filter, trigger queries only when charts are visible Apr 11, 2019
@graceguo-supercat graceguo-supercat force-pushed the gg-DashApplyFilter branch 2 times, most recently from c7779d7 to 6c05cc7 Compare April 11, 2019 21:36
@graceguo-supercat graceguo-supercat changed the title [dashboard] After update filter, trigger queries only when charts are visible [dashboard] After update filter, trigger new queries when charts are visible Apr 11, 2019
@graceguo-supercat graceguo-supercat force-pushed the gg-DashApplyFilter branch 16 times, most recently from cf29f72 to 622c276 Compare April 17, 2019 23:14
@graceguo-supercat graceguo-supercat force-pushed the gg-DashApplyFilter branch 3 times, most recently from f06142a to 6af206a Compare April 20, 2019 05:36
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.

LGTM overall, had one question and wanted to confirm chart updates happen as expected in explore view?

cy.get('.grid-container .box_plot').should('not.be.exist');
cy.get('.grid-container .line').should('not.be.exist');

// click row level tab, see 1 more chart
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be "row" => "top"?

Copy link
Author

Choose a reason for hiding this comment

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

in integration test for dashboard, i created layout a like this (so that i can test current solution works for both row-level tab and root-level tab):

root level tab A: has only 1 row

  • chart-1

root level tab B: has 2 rows

  • row 1: chart-2
  • row 2: row-level tabs
    • row-level tab 1: filter
    • row-level tab 2: chart-3

when i update filter, chart-2 is always visible, so it get updated right away.
when i click row-level tab 2, i can see chart-3 become visible, and it sends new query.
when i click root-level tab A, i can see chart-1 becomes visible, and it sends new query.

.deep.eq({ col: 'region', op: 'in', val: ['South Asia'] });
});

// click row level tab, send 1 more query
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto "row"?

@@ -106,7 +106,6 @@ class ExploreViewContainer extends React.Component {
componentWillReceiveProps(nextProps) {
if (nextProps.controls.viz_type.value !== this.props.controls.viz_type.value) {
this.props.actions.resetControls();
this.props.actions.triggerQuery(true, this.props.chart.id);
Copy link
Contributor

Choose a reason for hiding this comment

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

sorry not sure I quite understand the explore view changes with the new flow, why do we remove this line? I get that src/chart/Chart will now trigger a query if its prop.formData prop changes, but its props.triggerQuery still has to be true right? does that only happen with this line or something else causes that?

Copy link
Author

@graceguo-supercat graceguo-supercat May 3, 2019

Choose a reason for hiding this comment

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

When user change viz_type (or any control that needs trigger new query), we should show a overlay to hold the change, and allow user to update more controls. when user clicks on Run query we trigger new query with all change together. But in current master branch code, change viz_type will trigger new query right away (but not update UI because of overlay):

B48ewQojQN

This line of change (not setting triggerQuery) is just to fix this additional query issue.

@graceguo-supercat graceguo-supercat force-pushed the gg-DashApplyFilter branch 2 times, most recently from 0ab00cc to e4d7c41 Compare May 1, 2019 06:38
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.

LGTM!

@graceguo-supercat graceguo-supercat merged commit 6b8bda6 into apache:master May 8, 2019
xtinec pushed a commit that referenced this pull request May 10, 2019
* filter out all nan series (#7313)

* improve not rich tooltip (#7345)

* Create issue_label_bot.yaml (#7341)

* fix: do not save colors without a color scheme (#7347)

* [wtforms] Strip leading/trailing whitespace (#7084)

* [schema] Updating the datasources schema (#5451)

* limit tables/views returned if schema is not provided (#7358)

* limit tables/views returned if schema is not provided

* fix typo

* improve code performance

* handle the case when table name or view name does not present a schema

* Add type anno (#7342)

* Updated local dev instructions to include missing step

* First pass at type annotations

* [schema] Updating the base column schema (#5452)

* Update 937d04c16b64_update_datasources.py (#7361)

* Feature flag for client cache (#7348)

* Feature flag for client cache

* Fix integration test

* Revert "Fix integration test"

This reverts commit 58434ab.

* Feature flag for client cache

* Fix integration tests

* Add feature flag to config.py

* Add another feature check

* Fix more integration tests

* Fix raw HTML in SliceAdder (#7338)

* remove backendSync.json (#7331)

* [bubbles] issue when using duplicated metrics (#7087)

* SUPERSET-7: Docker compose config version breaks on Ubuntu 16.04 (#7359)

* SUPERSET-8: Update text in docs copyright footer (#7360)

* SUPERSET-7: Docker compose config version breaks on Ubuntu 16.04

* SUPERSET-8: Extra text in docs copyright footer

* [schema] Adding commits and removing unnecessary foreign-key definitions (#7371)

*  Store last selected dashboard in sessionStorage (#7181)

* Store last selected dashboard in sessionStorage

* Fix tests

* [schema] Updating the base metric schema (#5453)

* Fix NoneType bug & fill the test recipients with original recipients if empty (#7365)

* Added living goods as among the users of Superset (#7407)

* Added living goods as among the users of Superset

Living Goods is a non profit organisation with operation in africa and the middle east. We work in community health use data heavily on day to day. Superset is our platform of choice for dashboards.

* Update README.md

* [dashboard] allow user re-order top-level tabs (#7390)

* [SQL Lab] Increase timeout threshold for offline check (#7411)

* Bump FAB to 2.0.0 (#7323)

* Bump FAB to 2.0.0

* [tests] whitelist SecurityApi login and refresh endpoints

* [style] Fix, C812 missing trailing commas

* [security] Remove SUPERSET_UPDATE_PERMS flag

Registering sources needs to be performed after the views are
initialized on UPDATE_PERMS=False configuration

* [docs] New, FAB_UPDATE_PERMS and flask fab cli

* [docs] Fix, db upgrade needs to come first, create-admin needs a db

* [cli] New, superset init bootstraps all permissions for FAB and Superset

* [style] Fix, flakes

* [annotations] Improves UX on annotation validation, start_dttm, end_dttm (#7326)

* Setting renderTrigger on label_colors (#7410)

* Refactor out controlUtils.js module + unit tests (#7350)

* [WiP]refactor out a controlUtils.js file

* unit tests

* add missing license

* Addressing comments

* feature: see Presto row and array data types (#7413)

* Merge lastest from master into lyft-release-sp8 (#7405)

* filter out all nan series (#7313)

* improve not rich tooltip (#7345)

* Create issue_label_bot.yaml (#7341)

* fix: do not save colors without a color scheme (#7347)

* [wtforms] Strip leading/trailing whitespace (#7084)

* [schema] Updating the datasources schema (#5451)

* limit tables/views returned if schema is not provided (#7358)

* limit tables/views returned if schema is not provided

* fix typo

* improve code performance

* handle the case when table name or view name does not present a schema

* Add type anno (#7342)

* Updated local dev instructions to include missing step

* First pass at type annotations

* [schema] Updating the base column schema (#5452)

* Update 937d04c16b64_update_datasources.py (#7361)

* Feature flag for client cache (#7348)

* Feature flag for client cache

* Fix integration test

* Revert "Fix integration test"

This reverts commit 58434ab.

* Feature flag for client cache

* Fix integration tests

* Add feature flag to config.py

* Add another feature check

* Fix more integration tests

* Fix raw HTML in SliceAdder (#7338)

* remove backendSync.json (#7331)

* [bubbles] issue when using duplicated metrics (#7087)

* SUPERSET-7: Docker compose config version breaks on Ubuntu 16.04 (#7359)

* SUPERSET-8: Update text in docs copyright footer (#7360)

* SUPERSET-7: Docker compose config version breaks on Ubuntu 16.04

* SUPERSET-8: Extra text in docs copyright footer

* [schema] Adding commits and removing unnecessary foreign-key definitions (#7371)

*  Store last selected dashboard in sessionStorage (#7181)

* Store last selected dashboard in sessionStorage

* Fix tests

* [schema] Updating the base metric schema (#5453)

* Fix NoneType bug & fill the test recipients with original recipients if empty (#7365)

* feat: see Presto row and array data types (#7391)

* feat: see Presto row and array data types

* fix: address PR comments

* fix: lint and build issues

* fix: add types

* add stronger type hints where possible

* fix: lint issues and add select_star func in Hive

* add missing pkg init

* fix: build issues

* fix: pylint issues

* fix: use logging instead of print

* Removed --console-log and superset runserver (#7421)

* Fixes dashboard export button missing download and #7353 (#7427)

* Added additional German translations to string file (#6604)

* Added additional German translations to string file

Updates to German translation files as per directions

* Removed messages.json

* [fix] Fixing SQL parsing issue (#7374)

* add chinese translate (#7402)

* Quick fix to address deadlock issue (#7434)

* feat: view presto row objects in data grid (#7445)

* Merge lastest from master into lyft-release-sp8 (#7405)

* filter out all nan series (#7313)

* improve not rich tooltip (#7345)

* Create issue_label_bot.yaml (#7341)

* fix: do not save colors without a color scheme (#7347)

* [wtforms] Strip leading/trailing whitespace (#7084)

* [schema] Updating the datasources schema (#5451)

* limit tables/views returned if schema is not provided (#7358)

* limit tables/views returned if schema is not provided

* fix typo

* improve code performance

* handle the case when table name or view name does not present a schema

* Add type anno (#7342)

* Updated local dev instructions to include missing step

* First pass at type annotations

* [schema] Updating the base column schema (#5452)

* Update 937d04c16b64_update_datasources.py (#7361)

* Feature flag for client cache (#7348)

* Feature flag for client cache

* Fix integration test

* Revert "Fix integration test"

This reverts commit 58434ab.

* Feature flag for client cache

* Fix integration tests

* Add feature flag to config.py

* Add another feature check

* Fix more integration tests

* Fix raw HTML in SliceAdder (#7338)

* remove backendSync.json (#7331)

* [bubbles] issue when using duplicated metrics (#7087)

* SUPERSET-7: Docker compose config version breaks on Ubuntu 16.04 (#7359)

* SUPERSET-8: Update text in docs copyright footer (#7360)

* SUPERSET-7: Docker compose config version breaks on Ubuntu 16.04

* SUPERSET-8: Extra text in docs copyright footer

* [schema] Adding commits and removing unnecessary foreign-key definitions (#7371)

*  Store last selected dashboard in sessionStorage (#7181)

* Store last selected dashboard in sessionStorage

* Fix tests

* [schema] Updating the base metric schema (#5453)

* Fix NoneType bug & fill the test recipients with original recipients if empty (#7365)

* feat: see Presto row and array data types (#7391)

* feat: see Presto row and array data types

* fix: address PR comments

* fix: lint and build issues

* fix: add types

* Incorporate feedback from initial PR (prematurely merged to lyft-release-sp8) (#7415)

* add stronger type hints where possible

* fix: lint issues and add select_star func in Hive

* add missing pkg init

* fix: build issues

* fix: pylint issues

* fix: use logging instead of print

* feat: view presto row objects in data grid

* fix: address feedback

* fix: spacing

* feat: Scheduling queries from SQL Lab (#7416) (#7446)

* Merge lastest from master into lyft-release-sp8 (#7405)

* filter out all nan series (#7313)

* improve not rich tooltip (#7345)

* Create issue_label_bot.yaml (#7341)

* fix: do not save colors without a color scheme (#7347)

* [wtforms] Strip leading/trailing whitespace (#7084)

* [schema] Updating the datasources schema (#5451)

* limit tables/views returned if schema is not provided (#7358)

* limit tables/views returned if schema is not provided

* fix typo

* improve code performance

* handle the case when table name or view name does not present a schema

* Add type anno (#7342)

* Updated local dev instructions to include missing step

* First pass at type annotations

* [schema] Updating the base column schema (#5452)

* Update 937d04c16b64_update_datasources.py (#7361)

* Feature flag for client cache (#7348)

* Feature flag for client cache

* Fix integration test

* Revert "Fix integration test"

This reverts commit 58434ab.

* Feature flag for client cache

* Fix integration tests

* Add feature flag to config.py

* Add another feature check

* Fix more integration tests

* Fix raw HTML in SliceAdder (#7338)

* remove backendSync.json (#7331)

* [bubbles] issue when using duplicated metrics (#7087)

* SUPERSET-7: Docker compose config version breaks on Ubuntu 16.04 (#7359)

* SUPERSET-8: Update text in docs copyright footer (#7360)

* SUPERSET-7: Docker compose config version breaks on Ubuntu 16.04

* SUPERSET-8: Extra text in docs copyright footer

* [schema] Adding commits and removing unnecessary foreign-key definitions (#7371)

*  Store last selected dashboard in sessionStorage (#7181)

* Store last selected dashboard in sessionStorage

* Fix tests

* [schema] Updating the base metric schema (#5453)

* Fix NoneType bug & fill the test recipients with original recipients if empty (#7365)

* feat: see Presto row and array data types (#7391)

* feat: see Presto row and array data types

* fix: address PR comments

* fix: lint and build issues

* fix: add types

* Incorporate feedback from initial PR (prematurely merged to lyft-release-sp8) (#7415)

* add stronger type hints where possible

* fix: lint issues and add select_star func in Hive

* add missing pkg init

* fix: build issues

* fix: pylint issues

* fix: use logging instead of print

* feat: view presto row objects in data grid

* fix: address feedback

* fix: spacing

* Workaround for no results returned (#7442)

* feat: view presto row objects in data grid (#7436)

* feat: view presto row objects in data grid

* fix: address feedback

* fix: spacing

* feat: Scheduling queries from SQL Lab (#7416)

* Lightweight pipelines POC

* Add docs

* Minor fixes

* Remove Lyft URL

* Use enum

* Minor fix

* Fix unit tests

* Mark props as required

* feat: Add `validate_sql_json` endpoint for checking that a given sql query is valid for the chosen database (#7422) (#7462)

merge from lyft-release-sp8 to master

* Adds missing metric sum__SP_RUR_TOTL (#7452)

* Late import for optional lib pyhive (#7471)

* Late import for optional lib pyhive

* fix

* fix: calendar heatmap examples (#7375)

Fixing a set of examples that trip on ValueError vs TypeError

* bugfix: Improve support for special characters in schema and table names (#7297)

* Bugfix to SQL Lab to support tables and schemas with characters that require quoting

* Remove debugging prints

* Add uri encoding to secondary tables call

* Quote schema names for presto

* Quote selected_schema on Snowflake, MySQL and Hive

* Remove redundant parens

* Add python unit tests

* Add js unit test

* Fix flake8 linting error

* [dashboard] After update filter, trigger new queries when charts are visible (#7233)

* trigger query when chart is visible

* add integration test

* fix: alter sql columns to long text #7463 (#7476)

Merge lyft-release-sp8@7bfe7bc to master

* Refactor ConsoleLog (#7428)

* Revised Chinese translation (#7464)

* add chinese translate

* edit chinese translation

* druid connector: avoid using 'dimensions' for scan queries (#7377)

After the following PyDruid change (contained in version 0.5.2)
the Superset Histogram charts rendered with Druid data are
broken:

druid-io/pydruid@0a59a70

Bump the pydruid requirements accordingly in setup.py

Issue: #7368
@graceguo-supercat graceguo-supercat deleted the gg-DashApplyFilter branch June 11, 2020 23:21
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.34.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/XL 🚢 0.34.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants