MCPcopy Index your code
hub / github.com/REditorSupport/vscode-R / refreshPlots

Method refreshPlots

src/plotViewer/index.ts:592–622  ·  view source on GitHub ↗
(plotsIdResponse: HttpgdIdResponse[], redraw: boolean = false, force: boolean = false)

Source from the content-addressed store, hash-verified

590 }
591
592 protected async refreshPlots(plotsIdResponse: HttpgdIdResponse[], redraw: boolean = false, force: boolean = false): Promise<void> {
593 const nPlots = this.plots.length;
594 let plotIds = plotsIdResponse.map((x) => x.id);
595 plotIds = plotIds.filter((id) => !this.hiddenPlots.includes(id));
596 const newPlotPromises = plotIds.map(async (id) => {
597 const plot = this.plots.find((plt) => plt.id === id);
598 if (force || !plot || id === this.activePlot) {
599 return await this.getPlotContent(id, this.viewWidth, this.viewHeight, this.zoom);
600 } else {
601 return plot;
602 }
603 });
604 const newPlots = await Promise.all(newPlotPromises);
605 const oldPlotIds = this.plots.map(plt => plt.id);
606 this.plots = newPlots;
607 if (this.plots.length !== nPlots) {
608 this.activePlot = this.plots[this.plots.length - 1]?.id;
609 }
610 if (redraw || !this.webviewPanel) {
611 this.refreshHtml();
612 } else {
613 for (const plt of this.plots) {
614 if (oldPlotIds.includes(plt.id)) {
615 this.updatePlot(plt);
616 } else {
617 this.addPlot(plt);
618 }
619 }
620 this._focusPlot();
621 }
622 }
623
624 protected updatePlot(plt: HttpgdPlot<string>): void {
625 const msg: UpdatePlotMessage = {

Callers 3

focusPlotMethod · 0.95
resetPlotsMethod · 0.95
refreshPlotsDelayedMethod · 0.95

Calls 5

getPlotContentMethod · 0.95
refreshHtmlMethod · 0.95
updatePlotMethod · 0.95
addPlotMethod · 0.95
_focusPlotMethod · 0.95

Tested by

no test coverage detected