Introduction
FusionCharts is a JavaScript charting library which provides more than
95 charts and 2,000 maps which can be used fully in mobile and web
applications. This library provides integrations for all popular JavaScript frameworks & back-end programming languages.
Getting Started
Note
NPM or
Yarn must be installed globally on your local pc.
Installation Guide
Note
In the demo, for designing purposes, we used the simple
bootstrap library.
Install from NPM or from Yarn
- npm install --save react-fusioncharts
-
- or
-
- yarn add react-fusioncharts
Start to integrate Fusion Chart Library in react app
- Create a React app using your specific app name in the desired folder path, using the command create-react-app.
- Once you create the React app successfully, there will be app.js file in the src folder.
- Now, we need to import react-fusioncharts and FusionCharts in our app.js file.
- import React, {Component} from 'react';
- import FusionCharts from 'fusioncharts';
- import Charts from 'fusioncharts/fusioncharts.charts';
- import ReactFC from 'react-fusioncharts';
- import './index.css';
- import FusionTheme from 'fusioncharts/themes/fusioncharts.theme.fusion';
-
- ReactFC.fcRoot(FusionCharts, Charts, FusionTheme);
Note
This way of importing will not work in IE11 and below.
Configuration setting for column chart
- type: 'column2d',
- width: '100%',
- dataFormat: 'json',
- dataSource: {
- "chart": {
-
- "theme": "fusion",
- "palettecolors": "5d62b5,29c3be,f2726f",
- "caption": "Average Annual Population Growth",
- "subcaption": ' 1955-2015',
- "xAxisName": "Population",
- "yAxisName": "Growth",
- "numberSuffix": "K",
- "showBorder": "1",
- "borderColor": "#ccc",
- "bgColor": "#FFFFFF",
-
-
- "toolTipBorderColor": "#666666",
- "toolTipBgColor": "#efefef",
- "toolTipBgAlpha": "80",
- "showToolTipShadow": "1",
-
-
- "plotBorderThickness": "0.25",
- "showxaxispercentvalues": "1",
- "showValues": "1",
- "plotToolText": "Country: $label <br> Population : $dataValue"
- },
- "data": []
- }
Data Source Collection
- "data": [{
- "label": "China",
- "value": "300"
- },
- {
- "label": "US",
- "value": "200"
- },
- {
- "label": "Russia",
- "value": "130"
- },
- {
- "label": "Canada",
- "value": "80"
- },
- {
- "label": "Iran",
- "value": "130"
- },
- {
- "label": "UAE",
- "value": "70"
- },
- {
- "label": "Saudi",
- "value": "50"
- },
- {
- "label": "India",
- "value": "140"
- }
- ]
This sample static data collection needs to pass in a configuration setting.
Attach the callback to an event through the React-FC component.
- <ReactFC {...chartConfigsSettings} />
Consider the example to integrate or implement a fusion chart in the React app.
- import React, {Component} from 'react';
-
-
- import FusionCharts from 'fusioncharts';
- import Charts from 'fusioncharts/fusioncharts.charts';
- import ReactFC from 'react-fusioncharts';
- import './index.css';
- import FusionTheme from 'fusioncharts/themes/fusioncharts.theme.fusion';
-
-
- import 'bootstrap/dist/css/bootstrap.css';
-
- ReactFC.fcRoot(FusionCharts, Charts, FusionTheme);
-
-
- const chartConfigs_colunm2d = {
- type: 'column2d',
- width: '100%',
- dataFormat: 'json',
- dataSource: {
- "chart": {
- "theme": "fusion",
- "palettecolors": "5d62b5,29c3be,f2726f",
- "caption": "Average Annual Population Growth",
- "subcaption": ' 1955-2015',
- "xAxisName": "Population",
- "yAxisName": "Growth",
- "numberSuffix": "K",
- "showBorder": "1",
- "borderColor": "#ccc",
- "bgColor": "#FFFFFF",
-
- "toolTipBorderColor": "#666666",
- "toolTipBgColor": "#efefef",
- "toolTipBgAlpha": "80",
- "showToolTipShadow": "1",
-
- "plotBorderThickness": "0.25",
- "showxaxispercentvalues": "1",
- "showValues": "1",
- "plotToolText": "Country: $label <br> Population : $dataValue"
- },
- "data": [
- {
- "label": "China",
- "value": "300"
- },
- {
- "label": "US",
- "value": "200"
- },
- {
- "label": "Russia",
- "value": "130"
- },
- {
- "label": "Canada",
- "value": "80"
- },
- {
- "label": "Iran",
- "value": "130"
- },
- {
- "label": "UAE",
- "value": "70"
- },
- {
- "label": "Saudi",
- "value": "50"
- },
- {
- "label": "India",
- "value": "140"
- }
- ]
- },
- };
-
-
- const chartConfigs_colunm3d = {
- type: 'column3d',
- width: '100%',
- dataFormat: 'json',
- dataSource: {
- "chart": {
- "theme": "fusion",
- "palettecolors": "5d62b5,29c3be,f2726f",
- "caption": "Average Annual Population Growth",
- "subcaption": ' 1955-2015',
- "xAxisName": "Population",
- "yAxisName": "Growth",
- "numberSuffix": "K",
- "showBorder": "1",
- "borderColor": "#ccc",
- "bgColor": "#FFFFFF",
-
- "toolTipBorderColor": "#666666",
- "toolTipBgColor": "#efefef",
- "toolTipBgAlpha": "80",
- "showToolTipShadow": "1",
-
- "plotBorderThickness": "0.25",
- "showxaxispercentvalues": "1",
- "showValues": "1",
- "placeValuesInside": "1",
- "plotToolText": "Country: $label <br> Population : $dataValue"
- },
- "data": [
- {
- "label": "China",
- "value": "300"
- },
- {
- "label": "US",
- "value": "200"
- },
- {
- "label": "Russia",
- "value": "130"
- },
- {
- "label": "Canada",
- "value": "80"
- },
- {
- "label": "Iran",
- "value": "130"
- },
- {
- "label": "UAE",
- "value": "70"
- },
- {
- "label": "Saudi",
- "value": "50"
- },
- {
- "label": "India",
- "value": "140"
- }
- ]
- },
- };
-
- class App extends Component {
- render() {
- return (
- <div className="container">
- <div className="row">
- {}
- <div className="col-sm-6">
- <h3>Column 2D Chart</h3>
- <ReactFC {...chartConfigs_colunm2d} />
- </div>
-
- {}
- <div className="col-sm-6">
- <h3>Column 3D Chart</h3>
- <ReactFC {...chartConfigs_colunm3d} />
- </div>
-
- </div>
- </div>)
- }
- }
-
- export default App;
Official Links