Skip to content

Commit 74f482c

Browse files
committed
Fix dcc.Graph backward compatibility with dash 2.0
1 parent ab73036 commit 74f482c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

components/dash-core-components/src/fragments/Graph.react.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import {
1313
import PropTypes from 'prop-types';
1414
import {graphPropTypes, graphDefaultProps} from '../components/Graph.react';
1515

16-
import LoadingElement from '../utils/LoadingElement';
17-
1816
/* global Plotly:true */
1917

2018
import ResizeDetector from '../utils/ResizeDetector';
@@ -537,23 +535,32 @@ class PlotlyGraph extends Component {
537535
}
538536

539537
render() {
540-
const {className, id} = this.props;
538+
const {className, id, loading_state} = this.props;
541539
const style = this.getStyle();
542540

541+
let isLoading;
542+
if (window.dash_component_api !== undefined) {
543+
const ctx = window.dash_component_api.useDashContext();
544+
isLoading = ctx.useLoading();
545+
} else {
546+
isLoading = loading_state && loading_state.is_loading;
547+
}
548+
543549
return (
544-
<LoadingElement
550+
<div
545551
id={id}
546552
key={id}
547553
className={className}
548554
style={style}
549555
ref={this.parentElement}
556+
data-dash-is-loading={isLoading ? true : undefined}
550557
>
551558
<ResizeDetector
552559
onResize={this.graphResize}
553560
targets={[this.parentElement, this.gd]}
554561
/>
555562
<div ref={this.gd} style={{height: '100%', width: '100%'}} />
556-
</LoadingElement>
563+
</div>
557564
);
558565
}
559566
}

0 commit comments

Comments
 (0)