/* eslint-disable react/no-unused-prop-types */ /* eslint-disable import/first */ if (typeof window.URL.createObjectURL === 'undefined') { // @ts-ignore window.URL.createObjectURL = () => { // Mock this function for mapbox-gl to work }; } import * as React from 'react'; import type { Plotly as PlotlyTypes } from './full'; // Copied types from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-plotly.js/index.d.ts // as it depends on "@types/plotly.js": "*", causing the latest/incompatible version to be installed. export interface Figure { data: Plotly.Data[]; layout: Partial; frames: Plotly.Frame[] | null; } export interface PlotParams { data: Plotly.Data[]; layout: Partial; frames?: Plotly.Frame[] | undefined; config?: Partial | undefined; /** * When provided, causes the plot to update only when the revision is incremented. */ revision?: number | undefined; /** * Callback executed after plot is initialized. * @param figure Object with three keys corresponding to input props: data, layout and frames. * @param graphDiv Reference to the DOM node into which the figure was rendered. */ onInitialized?: ((figure: Readonly
, graphDiv: Readonly) => void) | undefined; /** * Callback executed when when a plot is updated due to new data or layout, or when user interacts with a plot. * @param figure Object with three keys corresponding to input props: data, layout and frames. * @param graphDiv Reference to the DOM node into which the figure was rendered. */ onUpdate?: ((figure: Readonly
, graphDiv: Readonly) => void) | undefined; /** * Callback executed when component unmounts, before Plotly.purge strips the graphDiv of all private attributes. * @param figure Object with three keys corresponding to input props: data, layout and frames. * @param graphDiv Reference to the DOM node into which the figure was rendered. */ onPurge?: ((figure: Readonly
, graphDiv: Readonly) => void) | undefined; /** * Callback executed when a plotly.js API method rejects * @param err Error */ onError?: ((err: Readonly) => void) | undefined; /** * id assigned to the
into which the plot is rendered. */ divId?: string | undefined; /** * applied to the
into which the plot is rendered */ className?: string | undefined; /** * used to style the
into which the plot is rendered */ style?: React.CSSProperties | undefined; /** * Assign the graph div to window.gd for debugging */ debug?: boolean | undefined; /** * When true, adds a call to Plotly.Plot.resize() as a window.resize event handler */ useResizeHandler?: boolean | undefined; onAfterExport?: (() => void) | undefined; onAfterPlot?: (() => void) | undefined; onAnimated?: (() => void) | undefined; onAnimatingFrame?: ((event: Readonly) => void) | undefined; onAnimationInterrupted?: (() => void) | undefined; onAutoSize?: (() => void) | undefined; onBeforeExport?: (() => void) | undefined; onBeforeHover?: ((event: Readonly) => boolean) | undefined; onButtonClicked?: ((event: Readonly) => void) | undefined; onClick?: ((event: Readonly) => void) | undefined; onClickAnnotation?: ((event: Readonly) => void) | undefined; onDeselect?: (() => void) | undefined; onDoubleClick?: (() => void) | undefined; onFramework?: (() => void) | undefined; onHover?: ((event: Readonly) => void) | undefined; onLegendClick?: ((event: Readonly) => boolean) | undefined; onLegendDoubleClick?: ((event: Readonly) => boolean) | undefined; onRelayout?: ((event: Readonly) => void) | undefined; onRestyle?: ((event: Readonly) => void) | undefined; onRedraw?: (() => void) | undefined; onSelected?: ((event: Readonly) => void) | undefined; onSelecting?: ((event: Readonly) => void) | undefined; onSliderChange?: ((event: Readonly) => void) | undefined; onSliderEnd?: ((event: Readonly) => void) | undefined; onSliderStart?: ((event: Readonly) => void) | undefined; onTransitioning?: (() => void) | undefined; onTransitionInterrupted?: (() => void) | undefined; onUnhover?: ((event: Readonly) => void) | undefined; onWebGlContextLost?: (() => void) | undefined; } // Lazily load plotly.js-dist-min to allow code-splitting to occur, otherwise plotly is loaded everytime visyn_core is imported. const LazyPlotlyComponent = React.lazy(() => Promise.all([ import('plotly.js-dist-min'), // @ts-ignore import('react-plotly.js/factory'), ]).then(([plotly, createPlotlyComponent]) => ({ // Use the minified version for our own `Plotly` object default: createPlotlyComponent.default(plotly.default) as React.ComponentType, })), ); // The actually exported plotly component is wrapped in Suspense to allow lazy loading export function PlotlyComponent(props: PlotParams) { return ( ); } // Reexport only the plotly typings export { PlotlyTypes };