Skip to content

Commit

Permalink
feat: add invisible layer on loading chart (#11994)
Browse files Browse the repository at this point in the history
  • Loading branch information
Grace Guo authored Dec 11, 2020
1 parent df6efb6 commit 0fdf026
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
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

0 comments on commit 0fdf026

Please sign in to comment.