DefinitelyTyped/types/react-plotly.js/index.d.ts
Ferdy Budhidharma 1d9679b2dc [react] add library managed attributes and upgrade TS requirement to 2.8 (#27901)
* feat(react): add library managed attributes and upgrade to 2.8

* fix broken tests

* fix lint errors
2018-08-06 18:51:26 +01:00

105 lines
4.1 KiB
TypeScript

// Type definitions for react-plotly.js 2.2
// Project: https://github.com/plotly/react-plotly.js#readme
// Definitions by: Jon Freedman <https://github.com/jonfreedman>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as Plotly from 'plotly.js';
import * as React from 'react';
export interface Frame {
name: string;
data: [{ x: Plotly.Datum, y: Plotly.Datum }];
group: 'lower' | 'upper';
}
export interface Figure {
data: Plotly.Data[];
layout: Partial<Plotly.Layout>;
}
export interface PlotParams {
data: Plotly.Data[];
layout: Partial<Plotly.Layout>;
frames?: Frame[];
config?: Partial<Plotly.Config>;
/**
* When provided, causes the plot to update only when the revision is incremented.
*/
revision?: number;
/**
* 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<Figure>, graphDiv: Readonly<HTMLElement>) => void;
/**
* 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<Figure>, graphDiv: Readonly<HTMLElement>) => void;
/**
* 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<Figure>, graphDiv: Readonly<HTMLElement>) => void;
/**
* Callback executed when a plotly.js API method rejects
* @param err Error
*/
onError?: (err: Readonly<Error>) => void;
/**
* id assigned to the <div> into which the plot is rendered.
*/
divId?: string;
/**
* applied to the <div> into which the plot is rendered
*/
className?: string;
/**
* used to style the <div> into which the plot is rendered
*/
style?: React.CSSProperties;
/**
* Assign the graph div to window.gd for debugging
*/
debug?: boolean;
/**
* When true, adds a call to Plotly.Plot.resize() as a window.resize event handler
*/
useResizeHandler?: boolean;
onAfterExport?: () => void;
onAfterPlot?: () => void;
onAnimated?: () => void;
onAnimatingFrame?: (event: Readonly<Plotly.FrameAnimationEvent>) => void;
onAnimationInterrupted?: () => void;
onAutoSize?: () => void;
onBeforeExport?: () => void;
onButtonClicked?: (event: Readonly<Plotly.ButtonClickEvent>) => void;
onClick?: (event: Readonly<Plotly.PlotMouseEvent>) => void;
onClickAnnotation?: (event: Readonly<Plotly.ClickAnnotationEvent>) => void;
onDeselect?: () => void;
onDoubleClick?: () => void;
onFramework?: () => void;
onHover?: (event: Readonly<Plotly.PlotMouseEvent>) => void;
onLegendClick?: (event: Readonly<Plotly.LegendClickEvent>) => boolean;
onLegendDoubleClick?: (event: Readonly<Plotly.LegendClickEvent>) => boolean;
onRelayout?: (event: Readonly<Plotly.PlotRelayoutEvent>) => void;
onRestyle?: (event: Readonly<Plotly.PlotRestyleEvent>) => void;
onRedraw?: () => void;
onSelected?: (event: Readonly<Plotly.PlotSelectionEvent>) => void;
onSelecting?: (event: Readonly<Plotly.PlotSelectionEvent>) => void;
onSliderChange?: (event: Readonly<Plotly.SliderChangeEvent>) => void;
onSliderEnd?: (event: Readonly<Plotly.SliderEndEvent>) => void;
onSliderStart?: (event: Readonly<Plotly.SliderStartEvent>) => void;
onTransitioning?: () => void;
onTransitionInterrupted?: () => void;
onUnhover?: (event: Readonly<Plotly.PlotMouseEvent>) => void;
}
export default class Plot extends React.PureComponent<PlotParams> {
}