-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
605 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ A simple and lightweight official React component for FusionCharts JavaScript ch | |
- [Custom Components](#custom-components) | ||
- [Drill Down](#drill-down-component) | ||
- [Going Beyond Charts](#going-beyond-charts) | ||
- [Usage and Integration of FusionTime](#usage-and-integration-of-fusionTime) | ||
- [For Contributors](#for-contributors) | ||
- [Licensing](#licensing) | ||
|
||
|
@@ -76,8 +77,8 @@ ReactFC.fcRoot(FusionCharts); | |
|
||
Here is a basic sample that shows how to create a chart using `react-fusioncharts`: | ||
|
||
``` | ||
import React from 'react; | ||
```javascript | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import FusionCharts from 'fusioncharts'; | ||
import Charts from 'fusioncharts/fusioncharts.charts'; | ||
|
@@ -263,6 +264,96 @@ class Chart extends Component { | |
ReactDOM.render(<Chart />, document.getElementById('root')); | ||
``` | ||
|
||
## Usage and integration of FusionTime | ||
|
||
From `[email protected]` and `[email protected]`, You can visualize timeseries data easily on react. | ||
|
||
Learn more about FusionTime [here](https://www.fusioncharts.com/fusiontime). | ||
|
||
### Consider the example below for integration of FusionTime | ||
|
||
```javascript | ||
import React from 'react'; | ||
import FusionCharts from 'fusioncharts'; | ||
import TimeSeries from 'fusioncharts/fusioncharts.timeseries'; | ||
import ReactFC from '../lib/ReactFC'; | ||
|
||
ReactFC.fcRoot(FusionCharts, TimeSeries); | ||
|
||
const jsonify = res => res.json(); | ||
const dataFetch = fetch( | ||
'https://raw.githubusercontent.com/fusioncharts/dev_centre_docs/fusiontime-beta-release/charts-resources/fusiontime/online-sales-single-series/data.json' | ||
).then(jsonify); | ||
const schemaFetch = fetch( | ||
'https://raw.githubusercontent.com/fusioncharts/dev_centre_docs/fusiontime-beta-release/charts-resources/fusiontime/online-sales-single-series/schema.json' | ||
).then(jsonify); | ||
|
||
class ChartViewer extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.onFetchData = this.onFetchData.bind(this); | ||
this.state = { | ||
timeseriesDs: { | ||
type: 'timeseries', | ||
renderAt: 'container', | ||
width: '600', | ||
height: '400', | ||
dataSource: { | ||
caption: { text: 'Online Sales of a SuperStore in the US' }, | ||
data: null, | ||
yAxis: [ | ||
{ | ||
plot: [ | ||
{ | ||
value: 'Sales ($)' | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
this.onFetchData(); | ||
} | ||
|
||
onFetchData() { | ||
Promise.all([dataFetch, schemaFetch]).then(res => { | ||
const data = res[0]; | ||
const schema = res[1]; | ||
const fusionTable = new FusionCharts.DataStore().createDataTable( | ||
data, | ||
schema | ||
); | ||
const timeseriesDs = Object.assign({}, this.state.timeseriesDs); | ||
timeseriesDs.dataSource.data = fusionTable; | ||
this.setState({ | ||
timeseriesDs | ||
}); | ||
}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
{this.state.timeseriesDs.dataSource.data ? ( | ||
<ReactFC {...this.state.timeseriesDs} /> | ||
) : ( | ||
'loading' | ||
)} | ||
</div> | ||
); | ||
} | ||
} | ||
``` | ||
|
||
Useful links for FusionTime | ||
|
||
- [How FusionTime works](https://www.fusioncharts.com/dev/fusiontime/getting-started/how-fusion-time-works) | ||
- [Create your first chart](https://www.fusioncharts.com/dev/fusiontime/getting-started/create-your-first-chart-in-fusiontime) | ||
|
||
## Drill Down Component | ||
|
||
A custom component to easily add drill down to your react application. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.