diff --git a/docs/static/feature-flags.json b/docs/static/feature-flags.json index 95738dd913f..6ca4c2ea818 100644 --- a/docs/static/feature-flags.json +++ b/docs/static/feature-flags.json @@ -247,6 +247,13 @@ "description": "Enables dashboard virtualization for improved performance", "category": "path_to_deprecation" }, + { + "name": "DASHBOARD_VIRTUALIZATION_DEFER_DATA", + "default": false, + "lifecycle": "stable", + "description": "Supports simultaneous data and dashboard virtualization for backend performance", + "category": "runtime_config" + }, { "name": "DATAPANEL_CLOSED_BY_DEFAULT", "default": false, diff --git a/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts b/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts index 2bd09edafc2..46f832cc094 100644 --- a/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts +++ b/superset-frontend/packages/superset-ui-core/src/utils/featureFlags.ts @@ -34,6 +34,7 @@ export enum FeatureFlag { ConfirmDashboardDiff = 'CONFIRM_DASHBOARD_DIFF', CssTemplates = 'CSS_TEMPLATES', DashboardVirtualization = 'DASHBOARD_VIRTUALIZATION', + DashboardVirtualizationDeferData = 'DASHBOARD_VIRTUALIZATION_DEFER_DATA', DashboardRbac = 'DASHBOARD_RBAC', DatapanelClosedByDefault = 'DATAPANEL_CLOSED_BY_DEFAULT', DatasetFolders = 'DATASET_FOLDERS', diff --git a/superset-frontend/src/components/Chart/Chart.tsx b/superset-frontend/src/components/Chart/Chart.tsx index 0b1ad8793b5..2d2303d34c6 100644 --- a/superset-frontend/src/components/Chart/Chart.tsx +++ b/superset-frontend/src/components/Chart/Chart.tsx @@ -192,7 +192,21 @@ class Chart extends PureComponent { } } + shouldRenderChart() { + return ( + this.props.isInView || + !isFeatureEnabled(FeatureFlag.DashboardVirtualization) || + isCurrentUserBot() + ); + } + runQuery() { + if ( + isFeatureEnabled(FeatureFlag.DashboardVirtualizationDeferData) && + !this.shouldRenderChart() + ) { + return; + } // Create chart with POST request this.props.actions.postChartFormData( this.props.formData, @@ -295,9 +309,7 @@ class Chart extends PureComponent { renderChartContainer() { return (
- {this.props.isInView || - !isFeatureEnabled(FeatureFlag.DashboardVirtualization) || - isCurrentUserBot() ? ( + {this.shouldRenderChart() ? (