Skip to content

Commit

Permalink
explore: redraw chart on width change too
Browse files Browse the repository at this point in the history
Fix #3028
  • Loading branch information
xrmx committed Jul 29, 2017
1 parent 219f33f commit 8f0c48a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const propTypes = {
column_formats: PropTypes.object,
containerId: PropTypes.string.isRequired,
height: PropTypes.string.isRequired,
width: PropTypes.string.isRequired,
isStarred: PropTypes.bool.isRequired,
slice: PropTypes.object,
table_name: PropTypes.string,
Expand Down Expand Up @@ -60,6 +61,7 @@ class ChartContainer extends React.PureComponent {
(
prevProps.queryResponse !== this.props.queryResponse ||
prevProps.height !== this.props.height ||
prevProps.width !== this.props.width ||
this.props.triggerRender
) && !this.props.queryResponse.error
&& this.props.chartStatus !== 'failed'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ExploreViewContainer extends React.Component {
super(props);
this.state = {
height: this.getHeight(),
width: this.getWidth(),
showModal: false,
};
}
Expand Down Expand Up @@ -75,6 +76,10 @@ class ExploreViewContainer extends React.Component {
this.props.actions.chartUpdateStopped(this.props.queryRequest);
}

getWidth() {
return `${window.innerWidth}px`;
}

getHeight() {
if (this.props.forcedHeight) {
return this.props.forcedHeight + 'px';
Expand All @@ -93,7 +98,7 @@ class ExploreViewContainer extends React.Component {
handleResize() {
clearTimeout(this.resizeTimer);
this.resizeTimer = setTimeout(() => {
this.setState({ height: this.getHeight() });
this.setState({ height: this.getHeight(), width: this.getWidth() });
}, 250);
}

Expand Down Expand Up @@ -131,6 +136,7 @@ class ExploreViewContainer extends React.Component {
return (
<ChartContainer
actions={this.props.actions}
width={this.state.width}
height={this.state.height}
/>);
}
Expand Down

0 comments on commit 8f0c48a

Please sign in to comment.