Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
Streamlit: Dont forget to change streamlit height when resizing plugi…
Browse files Browse the repository at this point in the history
…ns (#223)

Co-authored-by: danthe3rd <[email protected]>
  • Loading branch information
danthe3rd and danthe3rd committed Nov 4, 2021
1 parent 074826a commit f3e8c21
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/distribution/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export class HiPlotDistributionPlugin extends React.Component<DistributionPlugin
}
componentDidUpdate(prevProps: HiPlotPluginData, prevState: HiPlotDistributionPluginState) {
if (prevState.axis != this.state.axis) {
this.props.sendMessage("height_changed", () => null);
if (this.props.persistentState) {
this.props.persistentState.set('axis', this.state.axis);
}
Expand Down Expand Up @@ -123,6 +124,7 @@ export class HiPlotDistributionPlugin extends React.Component<DistributionPlugin
onResize = _.debounce(function(height: number, width: number) {
if (height != this.state.height || width != this.state.width) {
this.setState({height: height, width: width});
this.props.sendMessage("height_changed", () => null);
}
}.bind(this), 150);
disable(): void {
Expand Down
1 change: 1 addition & 0 deletions src/hiplot_streamlit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ReactTemplate extends StreamlitComponentBase<State> {
'selected_uids': this.onChange.bind(this),
'filtered_uids': this.onChange.bind(this),
'brush_extents': this.onChange.bind(this),
'height_changed': () => Streamlit.setFrameHeight(),
};
return <HiPlot experiment={this.state.experiment} onChange={onChangeHandlers} />;
}
Expand Down
1 change: 1 addition & 0 deletions src/parallel/parallel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ export class ParallelPlot extends React.Component<ParallelPlotData, ParallelPlot

// render data
this.setState(function(prevState) { return { brush_count: prevState.brush_count + 1}; });
this.props.sendMessage("height_changed", () => null);
}, 100);

me.compute_dimensions();
Expand Down
7 changes: 6 additions & 1 deletion src/plotxy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,14 @@ export class PlotXY extends React.Component<PlotXYProps, PlotXYState> {
if (prevState.height != this.state.height || prevState.width != this.state.width) {
if (this.plot) {
this.plot.on_resize();
this.props.sendMessage("height_changed", () => null);
}
}
if (!this.isEnabled()) {
this.plot = null;
if (this.plot !== null) {
this.plot = null;
this.props.sendMessage("height_changed", () => null);
}
if (this.state.hover_uid !== null) {
this.setState({
hover_uid: null,
Expand All @@ -604,6 +608,7 @@ export class PlotXY extends React.Component<PlotXYProps, PlotXYState> {
else {
if (anyAxisChanged) {
this.plot.update_axis();
this.props.sendMessage("height_changed", () => null);
}
}
if (this.state.hover_uid != prevState.hover_uid) {
Expand Down

0 comments on commit f3e8c21

Please sign in to comment.