Skip to content

Commit

Permalink
Fixed #469 - Charts do not immediately adapt to a smaller width when …
Browse files Browse the repository at this point in the history
…you switch between visualizers
  • Loading branch information
tsv2013 committed Sep 4, 2024
1 parent 6dad754 commit 83743f8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/plotly/histogram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export class HistogramPlotly extends HistogramModel {

protected async renderContentAsync(container: HTMLElement) {
const chartNode: HTMLElement = DocumentHelper.createElement("div");
await this._chartAdapter.create(chartNode);
container.innerHTML = "";
container.appendChild(chartNode);
await this._chartAdapter.create(chartNode);
return container;
}

Expand Down
2 changes: 1 addition & 1 deletion src/plotly/matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export class MatrixPlotly extends Matrix {

protected async renderContentAsync(container: HTMLElement) {
const chartNode: HTMLElement = DocumentHelper.createElement("div");
await this._chartAdapter.create(chartNode);
container.innerHTML = "";
container.appendChild(chartNode);
await this._chartAdapter.create(chartNode);
return container;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/plotly/matrixdropdown-grouped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export class MatrixDropdownGroupedPlotly extends MatrixDropdownGrouped {

protected async renderContentAsync(container: HTMLElement) {
const chartNode: HTMLElement = DocumentHelper.createElement("div");
await this._chartAdapter.create(chartNode);
container.innerHTML = "";
container.appendChild(chartNode);
await this._chartAdapter.create(chartNode);
return container;
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/plotly/rating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,15 @@ export class PlotlyGaugeAdapter {
};
PlotlySetup.onPlotCreating.fire(this.model, options);

return (<any>Plotly).newPlot(
const plot = (<any>Plotly).newPlot(
chartNode,
options.data,
options.layout,
options.config
);
// setTimeout(() => Plotly.Plots.resize(chartNode), 10);

return plot;
}

public destroy(node: HTMLElement) {
Expand Down Expand Up @@ -142,9 +145,9 @@ export class GaugePlotly extends NumberModel {

protected async renderContentAsync(container: HTMLElement) {
const chartNode: HTMLElement = DocumentHelper.createElement("div");
await this._chartAdapter.create(chartNode);
container.innerHTML = "";
container.appendChild(chartNode);
await this._chartAdapter.create(chartNode);
return container;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/plotly/selectBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export class PlotlyChartAdapter {
dragLayer && (dragLayer.style.cursor = "");
});

// setTimeout(() => Plotly.Plots.resize(chartNode), 10);
this._chart = plot;
return plot;
}
Expand Down Expand Up @@ -158,9 +159,9 @@ export class SelectBasePlotly extends SelectBase {

protected async renderContentAsync(container: HTMLElement) {
const chartNode: HTMLElement = DocumentHelper.createElement("div");
await this._chartAdapter.create(chartNode);
container.innerHTML = "";
container.appendChild(chartNode);
await this._chartAdapter.create(chartNode);
return container;
}

Expand Down

0 comments on commit 83743f8

Please sign in to comment.