|
| 1 | +import type React from 'react'; |
| 2 | + |
| 3 | +/** |
| 4 | + * The snapshot of plot state passed to figure callbacks. |
| 5 | + * `data`, `layout`, and the entries of `frames` are plotly.js objects; this |
| 6 | + * package does not depend on `@types/plotly.js`, so they are typed as |
| 7 | + * `unknown`. Consumers wanting tighter types can re-declare with imports |
| 8 | + * from `plotly.js`. |
| 9 | + */ |
| 10 | +export interface Figure { |
| 11 | + data: unknown[]; |
| 12 | + layout: unknown; |
| 13 | + frames: unknown[] | null; |
| 14 | +} |
| 15 | + |
| 16 | +export type FigureCallback = (figure: Figure, graphDiv: HTMLElement) => void; |
| 17 | +export type EventCallback = (event: any) => void; |
| 18 | + |
| 19 | +export interface PlotParams { |
| 20 | + data?: unknown[]; |
| 21 | + layout?: unknown; |
| 22 | + config?: unknown; |
| 23 | + frames?: unknown[]; |
| 24 | + revision?: number; |
| 25 | + onInitialized?: FigureCallback; |
| 26 | + onUpdate?: FigureCallback; |
| 27 | + onPurge?: FigureCallback; |
| 28 | + onError?: (err: Error) => void; |
| 29 | + debug?: boolean; |
| 30 | + style?: React.CSSProperties; |
| 31 | + className?: string; |
| 32 | + useResizeHandler?: boolean; |
| 33 | + divId?: string; |
| 34 | + |
| 35 | + onAfterExport?: EventCallback; |
| 36 | + onAfterPlot?: EventCallback; |
| 37 | + onAnimated?: EventCallback; |
| 38 | + onAnimatingFrame?: EventCallback; |
| 39 | + onAnimationInterrupted?: EventCallback; |
| 40 | + onAutoSize?: EventCallback; |
| 41 | + onBeforeExport?: EventCallback; |
| 42 | + onBeforeHover?: EventCallback; |
| 43 | + onButtonClicked?: EventCallback; |
| 44 | + onClick?: EventCallback; |
| 45 | + onClickAnnotation?: EventCallback; |
| 46 | + onClickAnywhere?: EventCallback; |
| 47 | + onDeselect?: EventCallback; |
| 48 | + onDoubleClick?: EventCallback; |
| 49 | + onFramework?: EventCallback; |
| 50 | + onHover?: EventCallback; |
| 51 | + onHoverAnywhere?: EventCallback; |
| 52 | + onLegendClick?: EventCallback; |
| 53 | + onLegendDoubleClick?: EventCallback; |
| 54 | + onRelayout?: EventCallback; |
| 55 | + onRelayouting?: EventCallback; |
| 56 | + onRestyle?: EventCallback; |
| 57 | + onRedraw?: EventCallback; |
| 58 | + onSelected?: EventCallback; |
| 59 | + onSelecting?: EventCallback; |
| 60 | + onSliderChange?: EventCallback; |
| 61 | + onSliderEnd?: EventCallback; |
| 62 | + onSliderStart?: EventCallback; |
| 63 | + onSunburstClick?: EventCallback; |
| 64 | + onTransitioning?: EventCallback; |
| 65 | + onTransitionInterrupted?: EventCallback; |
| 66 | + onUnhover?: EventCallback; |
| 67 | + onWebGlContextLost?: EventCallback; |
| 68 | +} |
| 69 | + |
| 70 | +/** |
| 71 | + * Build a Plot component bound to a specific plotly.js instance. Use this |
| 72 | + * when shipping a custom plotly.js bundle (e.g. the basic, cartesian, or |
| 73 | + * a custom partial bundle) instead of the full library. |
| 74 | + */ |
| 75 | +declare function createPlotlyComponent(Plotly: unknown): React.ComponentType<PlotParams>; |
| 76 | + |
| 77 | +export default createPlotlyComponent; |
0 commit comments