diff --git a/frontend/src/figure/FigureEditor.tsx b/frontend/src/figure/FigureEditor.tsx index 41ca25df..1d8b9932 100644 --- a/frontend/src/figure/FigureEditor.tsx +++ b/frontend/src/figure/FigureEditor.tsx @@ -2,6 +2,7 @@ // Licensed under the GNU Affero General Public License version 3 (AGPLv3). import { useEffect, useLayoutEffect, useRef, useState } from 'react' import Plotly from 'plotly.js-dist-min' +import type { Data as PlotlyData } from 'plotly.js' import { api } from '../api/client' import { errorMessage } from '../api/errorMessage' import type { AnnotationSource, ComparisonRunSpec } from '../api/types' @@ -89,7 +90,7 @@ function PanePlot({ study, pane, doc, showLegend, w, h, version, onEntries }: { if (cancelled) return const fig = paneFigure(raw, pane, doc, { showLegend, widthPx: w, heightPx: h }) onEntries(legendEntries(fig)) - return Plotly.react(el, fig.data as Plotly.Data[], fig.layout, { staticPlot: true, displayModeBar: false }) + return Plotly.react(el, fig.data as PlotlyData[], fig.layout, { staticPlot: true, displayModeBar: false }) }) .catch(e => { if (!cancelled) setError(errorMessage(e)) }) .finally(() => { if (!cancelled) setLoading(false) }) diff --git a/frontend/src/figure/export.ts b/frontend/src/figure/export.ts index c33684b3..7d3973bd 100644 --- a/frontend/src/figure/export.ts +++ b/frontend/src/figure/export.ts @@ -1,6 +1,7 @@ // © 2026 Joshua Benjamin Jewell. All rights reserved. // Licensed under the GNU Affero General Public License version 3 (AGPLv3). import Plotly from 'plotly.js-dist-min' +import type { Data as PlotlyData, Layout as PlotlyLayout } from 'plotly.js' import { PX_PER_MM, PX_PER_PT, MM_PER_IN, figureGeometry, titlePt, type FigureDoc } from './types' import { layoutLegend, legendEntries, mergeEntries } from './legend' import type { PlotSpec } from './charts' @@ -11,7 +12,7 @@ const SVG_NS = 'http://www.w3.org/2000/svg' /** Plotly's SVG of one pane. */ async function paneSvg(fig: PlotSpec): Promise { const w = fig.layout.width as number, h = fig.layout.height as number - const url = await Plotly.toImage({ data: fig.data as Plotly.Data[], layout: fig.layout as Partial }, + const url = await Plotly.toImage({ data: fig.data as PlotlyData[], layout: fig.layout as Partial }, { format: 'svg', width: w, height: h }) const text = decodeURIComponent(url.slice(url.indexOf(',') + 1)) return new DOMParser().parseFromString(text, 'image/svg+xml').documentElement as unknown as SVGSVGElement