import { lazy, Suspense } from "react"; import type { Data, Layout } from "plotly.js"; const LazyPlot = lazy(async () => { const [{ default: Plotly }, { default: createPlotlyComponent }] = await Promise.all([ // @ts-expect-error plotly.js-dist-min ships no type declarations; runtime shape matches plotly.js import("plotly.js-dist-min"), import("react-plotly.js/factory"), ]); return { default: createPlotlyComponent(Plotly) }; }); export interface PlotlyChartSpec { schema?: string; chart_type?: string; title?: string; plotly: { data: Data[]; layout?: Partial; }; } export function PlotlyChartBlock({ spec }: { spec: PlotlyChartSpec }) { if (!spec?.plotly?.data) return null; return (
Loading chart…
} > ); }