Skip to content

Commit

Permalink
explicitly set figure height, for jupyterlab v4
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcjohnson committed May 19, 2023
1 parent 411d66a commit 3b4b324
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
3 changes: 3 additions & 0 deletions packages/javascript/jupyterlab-plotly/src/Figure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,9 @@ export class FigureView extends DOMWidgetView {
// the model is not directly mutated by the Plotly.js library.
var initialTraces = _.cloneDeep(this.model.get("_data"));
var initialLayout = _.cloneDeep(this.model.get("_layout"));
if (!initialLayout.height) {
initialLayout.height = 360;
}
var config = this.model.get("_config");
config.editSelection = false;

Expand Down
6 changes: 5 additions & 1 deletion packages/javascript/jupyterlab-plotly/src/plotly-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,16 @@ export class RenderedPlotly extends Widget implements IRenderMime.IRenderer {
| any
| IPlotlySpec;

if (!layout.height) {
layout.height = 360;
}

// Load plotly asynchronously
const loadPlotly = async (): Promise<void> => {
if (RenderedPlotly.Plotly === null) {
RenderedPlotly.Plotly = await import("plotly.js/dist/plotly");
RenderedPlotly._resolveLoadingPlotly();
}
}
return RenderedPlotly.loadingPlotly;
};

Expand Down
7 changes: 1 addition & 6 deletions packages/javascript/jupyterlab-plotly/style/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@
overflow: hidden;
}

/* Output styles */
.jp-OutputArea .jp-RenderedPlotly {
min-height: 360px;
}

/* Document icon */
.jp-PlotlyIcon {
background-image: var(--jp-icon-plotly);
}
}

0 comments on commit 3b4b324

Please sign in to comment.