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

Commit f3e8c21

Browse files
authored
Streamlit: Dont forget to change streamlit height when resizing plugins (#223)
Co-authored-by: danthe3rd <[email protected]>
1 parent 074826a commit f3e8c21

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

src/distribution/plugin.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export class HiPlotDistributionPlugin extends React.Component<DistributionPlugin
8888
}
8989
componentDidUpdate(prevProps: HiPlotPluginData, prevState: HiPlotDistributionPluginState) {
9090
if (prevState.axis != this.state.axis) {
91+
this.props.sendMessage("height_changed", () => null);
9192
if (this.props.persistentState) {
9293
this.props.persistentState.set('axis', this.state.axis);
9394
}
@@ -123,6 +124,7 @@ export class HiPlotDistributionPlugin extends React.Component<DistributionPlugin
123124
onResize = _.debounce(function(height: number, width: number) {
124125
if (height != this.state.height || width != this.state.width) {
125126
this.setState({height: height, width: width});
127+
this.props.sendMessage("height_changed", () => null);
126128
}
127129
}.bind(this), 150);
128130
disable(): void {

src/hiplot_streamlit.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ReactTemplate extends StreamlitComponentBase<State> {
4343
'selected_uids': this.onChange.bind(this),
4444
'filtered_uids': this.onChange.bind(this),
4545
'brush_extents': this.onChange.bind(this),
46+
'height_changed': () => Streamlit.setFrameHeight(),
4647
};
4748
return <HiPlot experiment={this.state.experiment} onChange={onChangeHandlers} />;
4849
}

src/parallel/parallel.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ export class ParallelPlot extends React.Component<ParallelPlotData, ParallelPlot
623623

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

628629
me.compute_dimensions();

src/plotxy.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -591,10 +591,14 @@ export class PlotXY extends React.Component<PlotXYProps, PlotXYState> {
591591
if (prevState.height != this.state.height || prevState.width != this.state.width) {
592592
if (this.plot) {
593593
this.plot.on_resize();
594+
this.props.sendMessage("height_changed", () => null);
594595
}
595596
}
596597
if (!this.isEnabled()) {
597-
this.plot = null;
598+
if (this.plot !== null) {
599+
this.plot = null;
600+
this.props.sendMessage("height_changed", () => null);
601+
}
598602
if (this.state.hover_uid !== null) {
599603
this.setState({
600604
hover_uid: null,
@@ -604,6 +608,7 @@ export class PlotXY extends React.Component<PlotXYProps, PlotXYState> {
604608
else {
605609
if (anyAxisChanged) {
606610
this.plot.update_axis();
611+
this.props.sendMessage("height_changed", () => null);
607612
}
608613
}
609614
if (this.state.hover_uid != prevState.hover_uid) {

0 commit comments

Comments
 (0)