DefinitelyTyped/types/react-plotly.js/react-plotly.js-tests.tsx
Domino987 e0f3c915f4 Added factory.d.ts (#35779)
* Added factory.d.ts

This enables the modular import of plotly descibere [here](https://github.com/plotly/plotly.js/tree/master/dist#partial-bundles).

import Plotly from 'plotly.js-basic-dist'
import createPlotlyComponent from 'react-plotly.js/factory';
export const Plot = createPlotlyComponent(Plotly);

* Add factory to index

This is needed because travis will fail due to unused file error

* removal of default

* Update index.d.ts

* Update index.d.ts

* Update tsconfig.json

* Update index.d.ts

* Add factory test
2019-06-21 08:42:13 -07:00

51 lines
1.4 KiB
TypeScript

import * as React from 'react';
import Plot from 'react-plotly.js';
import createPlotlyComponent from 'react-plotly.js/factory';
/**
* based on https://plot.ly/javascript/react/#quick-start
*/
export class SimpleChartComponent extends React.PureComponent<any> {
render() {
return(
<Plot
data={[
{
x: [1, 2, 3],
y: [2, 6, 3],
type: 'scatter',
marker: {color: 'red'},
},
{type: 'bar', x: [1, 2, 3], y: [2, 5, 3]},
]}
layout={ {width: 320, height: 240, title: 'A Fancy Plot'} }
/>
);
}
}
/**
* This creates a minified Plotly Plot, if a minified version is
* supplied to createPlotlyComponent for example plotly.js-basic-dist
*/
const MinPlot = createPlotlyComponent(Plot);
export class MinChartComponent extends React.PureComponent<any> {
render() {
return(
<MinPlot
data={[
{
x: [1, 2, 3],
y: [2, 6, 3],
type: 'scatter',
marker: {color: 'red'},
},
{type: 'bar', x: [1, 2, 3], y: [2, 5, 3]},
]}
layout={ {width: 320, height: 240, title: 'A Fancy Plot'} }
/>
);
}
}