@@ -24,6 +24,7 @@ A simple and lightweight official React component for FusionCharts JavaScript ch
2424- [ Custom Components] ( #custom-components )
2525 - [ Drill Down] ( #drill-down-component )
2626- [ Going Beyond Charts] ( #going-beyond-charts )
27+ - [ Usage and Integration of FusionTime] ( #usage-and-integration-of-fusionTime )
2728- [ For Contributors] ( #for-contributors )
2829- [ Licensing] ( #licensing )
2930
@@ -76,7 +77,7 @@ ReactFC.fcRoot(FusionCharts);
7677
7778Here is a basic sample that shows how to create a chart using ` react-fusioncharts ` :
7879
79- ```
80+ ``` javascript
8081import React from ' react;
8182import ReactDOM from ' react-dom' ;
8283import FusionCharts from ' fusioncharts' ;
@@ -263,6 +264,92 @@ class Chart extends Component {
263264ReactDOM.render(<Chart />, document.getElementById(' root' ));
264265```
265266
267+ ## Usage and integration of FusionTime
268+
269+ From `fusioncharts@3.13.3-sr.1` and `react-fusioncharts@3.0.0`, You can visualize timeseries data easily on react.
270+
271+ Learn more about FusionTime [here](https://www.fusioncharts.com/fusiontime).
272+
273+ ### Consider the example below for integration of FusionTime
274+
275+ ```javascript
276+ import React from ' react' ;
277+ import FusionCharts from ' fusioncharts' ;
278+ import TimeSeries from ' fusioncharts/fusioncharts.timeseries' ;
279+ import ReactFC from ' ../lib/ReactFC' ;
280+
281+ ReactFC.fcRoot(FusionCharts, TimeSeries);
282+
283+ const jsonify = res => res.json();
284+ const dataFetch = fetch(
285+ ' https:// raw.githubusercontent.com/fusioncharts/dev_centre_docs/fusiontime-beta-release/charts-resources/fusiontime/online-sales-single-series/data.json'
286+ ).then (jsonify);
287+ const schemaFetch = fetch (
288+ ' https://raw.githubusercontent.com/fusioncharts/dev_centre_docs/fusiontime-beta-release/charts-resources/fusiontime/online-sales-single-series/schema.json'
289+ ).then (jsonify);
290+
291+ class ChartViewer extends React .Component {
292+ constructor (props ) {
293+ super (props);
294+
295+ this .state = {
296+ timeseriesDs: {
297+ type: ' timeseries' ,
298+ renderAt: ' container' ,
299+ width: ' 600' ,
300+ height: ' 400' ,
301+ dataSource: {
302+ caption: { text: ' Online Sales of a SuperStore in the US' },
303+ data: null ,
304+ yAxis: [
305+ {
306+ plot: [
307+ {
308+ value: ' Sales ($)'
309+ }
310+ ]
311+ }
312+ ]
313+ }
314+ }
315+ };
316+ this .onFetchData = this .onFetchData .bind (this );
317+ }
318+
319+ componentDidMount () {
320+ this .onFetchData ();
321+ }
322+
323+ onFetchData () {
324+ Promise .all ([dataFetch, schemaFetch]).then (res => {
325+ const data = res[0 ];
326+ const schema = res[1 ];
327+ const fusionTable = new FusionCharts.DataStore ().createDataTable (
328+ data,
329+ schema
330+ );
331+ const timeseriesDs = Object .assign ({}, this .state .timeseriesDs );
332+ timeseriesDs .dataSource .data = fusionTable;
333+ this .setState ({
334+ timeseriesDs
335+ });
336+ });
337+ }
338+
339+ render () {
340+ return (
341+ < div>
342+ {this .state .timeseriesDs .dataSource .data ? (
343+ < ReactFC {... this .state .timeseriesDs } / >
344+ ) : (
345+ ' loading'
346+ )}
347+ < / div>
348+ );
349+ }
350+ }
351+ ```
352+
266353## Drill Down Component
267354
268355A custom component to easily add drill down to your react application.
0 commit comments