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 invisible layer on loading chart #11994

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import cx from 'classnames';
import React from 'react';
import PropTypes from 'prop-types';
import { styled } from '@superset-ui/core';

import { exploreChart, exportChart } from '../../../explore/exploreUtils';
import SliceHeader from '../SliceHeader';
import ChartContainer from '../../../chart/ChartContainer';
Expand Down Expand Up @@ -81,6 +83,13 @@ const SHOULD_UPDATE_ON_PROP_CHANGES = Object.keys(propTypes).filter(
const OVERFLOWABLE_VIZ_TYPES = new Set(['filter_box']);
const DEFAULT_HEADER_HEIGHT = 22;

const ChartOverlay = styled.div`
position: absolute;
top: 0;
left: 0;
z-index: 5;
`;

export default class Chart extends React.Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -257,7 +266,8 @@ export default class Chart extends React.Component {
return <MissingChart height={this.getChartHeight()} />;
}

const { queryResponse, chartUpdateEndTime } = chart;
const { queryResponse, chartUpdateEndTime, chartStatus } = chart;
const isLoading = chartStatus === 'loading';
const isCached = queryResponse && queryResponse.is_cached;
const cachedDttm = queryResponse && queryResponse.cached_dttm;
const isOverflowable = OVERFLOWABLE_VIZ_TYPES.has(slice.viz_type);
Expand Down Expand Up @@ -319,6 +329,15 @@ export default class Chart extends React.Component {
isOverflowable && 'dashboard-chart--overflowable',
)}
>
{isLoading && (
<ChartOverlay
style={{
width,
height: this.getChartHeight(),
}}
/>
)}

<ChartContainer
width={width}
height={this.getChartHeight()}
Expand All @@ -328,7 +347,7 @@ export default class Chart extends React.Component {
annotationData={chart.annotationData}
chartAlert={chart.chartAlert}
chartId={id}
chartStatus={chart.chartStatus}
chartStatus={chartStatus}
datasource={datasource}
dashboardId={dashboardId}
initialValues={initialValues}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

.dashboard-chart {
overflow: hidden;
position: relative;
}

.dashboard-chart.dashboard-chart--overflowable {
Expand Down