
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
react-fusioncharts
Advanced tools
Simple and Lightweight React component for FusionCharts JavaScript Charting Library
A simple and lightweight React
component which provides bindings for FusionCharts
JavaScript Charting Library. It easily adds rich and interactive charts to any React
Projects.
To install react-fusioncharts
, run:
$ npm install react-fusioncharts --save
Also install fusioncharts
, if it is not already installed:
$ npm install fusioncharts --save
After installing react-fusioncharts
, import it in your React
app:
import React from 'react';
import ReactDOM from 'react-dom';
import FusionCharts from 'fusioncharts';
import Charts from 'fusioncharts/fusioncharts.charts';
import ReactFC from 'react-fusioncharts';
import FusionTheme from 'fusioncharts/themes/fusioncharts.theme.fusion';
ReactFC.fcRoot(FusionCharts, Charts, FusionTheme);
const myDataSource = {
"chart": {
"caption": "Countries With Most Oil Reserves [2017-18]",
"subCaption": "In MMbbl = One Million barrels",
"xAxisName": "Country",
"yAxisName": "Reserves (MMbbl)",
"numberSuffix": "K",
"theme": "fusion"
},
"data": [
{
"label": "Venezuela",
"value": "290"
},
{
"label": "Saudi",
"value": "260"
},
{
"label": "Canada",
"value": "180"
},
{
"label": "Iran",
"value": "140"
},
{
"label": "Russia",
"value": "115"
},
{
"label": "UAE",
"value": "100"
},
{
"label": "US",
"value": "30"
},
{
"label": "China",
"value": "30"
}
]
};
const chartConfigs = {
type: 'column2d',
width: 600,
height: 400,
dataFormat: 'json',
dataSource: myDataSource,
};
ReactDOM.render(
<ReactFC {...chartConfigs} />,
document.getElementById('root'),
);
To render a map, import the FusionMaps module along with the map definition.
import React from 'react';
import ReactDOM from 'react-dom';
import FusionCharts from 'fusioncharts';
import Maps from 'fusioncharts/fusioncharts.maps';
import World from 'fusioncharts/maps/fusioncharts.world';
import ReactFC from 'react-fusioncharts';
import FusionTheme from 'fusioncharts/themes/fusioncharts.theme.fusion';
ReactFC.fcRoot(FusionCharts, Maps, World, FusionTheme);
const myDataSource = {
"chart": {
"caption": "Average Annual Population Growth",
"subcaption": " 1955-2015",
"numbersuffix": "%",
"includevalueinlabels": "1",
"labelsepchar": ": ",
"entityFillHoverColor": "#FFF9C4",
"theme": "fusion"
},
"colorrange": {
"minvalue": "0",
"code": "#FFE0B2",
"gradient": "1",
"color": [
{
"minvalue": "0.5",
"maxvalue": "1.0",
"color": "#FFD74D"
},
{
"minvalue": "1.0",
"maxvalue": "2.0",
"color": "#FB8C00"
},
{
"minvalue": "2.0",
"maxvalue": "3.0",
"color": "#E65100"
}
]
},
"data": [
{
"id": "NA",
"value": ".82",
"showLabel": "1"
},
{
"id": "SA",
"value": "2.04",
"showLabel": "1"
},
{
"id": "AS",
"value": "1.78",
"showLabel": "1"
},
{
"id": "EU",
"value": ".40",
"showLabel": "1"
},
{
"id": "AF",
"value": "2.58",
"showLabel": "1"
},
{
"id": "AU",
"value": "1.30",
"showLabel": "1"
}
]
};
const chartConfigs = {
type: 'world',
width: 600,
height: 400,
dataFormat: 'json',
dataSource: myDataSource,
};
ReactDOM.render(
<ReactFC {...chartConfigs} />,
document.getElementById('root'),
);
To attach event callbacks to a FusionCharts component, follow the pattern below.
Write the callback:
As a separate function:
var chartEventCallback = function (eventObj, dataObj) {
[Code goes here]
}
Or, as a component class method:
chartEventCallback (eventObj, dataObj) {
[Code goes here]
}
Attach the callback to an event through the React-FC component:
<ReactFC {...chartConfigs} fcEvent-EVENTNAME={this.chartEventCallback} />
Where, EVENTNAME is to be replaced by the event you want to track.
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import FusionCharts from 'fusioncharts';
import Charts from 'fusioncharts/fusioncharts.charts';
import ReactFC from 'react-fusioncharts';
import FusionTheme from 'fusioncharts/Charts/fusioncharts.theme.fusion';
ReactFC.fcRoot(FusionCharts, Charts, FusionTheme);
const myDataSource = {
"chart": {
"caption": "Countries With Most Oil Reserves [2017-18]",
"subCaption": "In MMbbl = One Million barrels",
"xAxisName": "Country",
"yAxisName": "Reserves (MMbbl)",
"numberSuffix": "K",
"theme": "fusion"
},
"data": [
{
"label": "Venezuela",
"value": "290"
},
{
"label": "Saudi",
"value": "260"
},
{
"label": "Canada",
"value": "180"
},
{
"label": "Iran",
"value": "140"
},
{
"label": "Russia",
"value": "115"
},
{
"label": "UAE",
"value": "100"
},
{
"label": "US",
"value": "30"
},
{
"label": "China",
"value": "30"
}
]
};
const chartConfigs = {
type: 'column2d',
width: 600,
height: 400,
dataFormat: 'json',
dataSource: myDataSource,
};
class Chart extends Component {
constructor(props) {
super(props);
this.state = {
actualValue: 'Hover on the plot to see the value along with the label',
};
this.showPlotValue = this.showPlotValue.bind(this);
}
// Event callback handler for 'dataplotRollOver'.
// Shows the value of the hovered plot on the page.
showPlotValue(eventObj, dataObj) {
this.setState({
actualValue: `You’re are currently hovering over ${dataObj.categoryLabel} whose value is ${dataObj.displayValue}`,
});
}
render() {
return (
<div>
<ReactFC {...chartConfigs} fcEvent-dataplotRollOver={this.showPlotValue} />
<p style={{ padding: '10px', background: '#f5f2f0' }}>{this.state.actualValue}</p>
</div>
);
}
}
ReactDOM.render(
<Chart />,
document.getElementById('root'),
);
To call APIs we will need the chart object. To get the chart object for an React-FC component, pass a callback through the attribute onRender
.
Write the callback:
As a separate function:
var chartRenderCallback = function (chart) {
[Code goes here]
}
Or, as a component class method:
chartRenderCallback (chart) {
[Code goes here]
}
Pass the callback as a prop, to which the chart object will be returned on rendering
<ReactFC {...chartConfigs} onRender={chartRenderCallback} />
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import FusionCharts from 'fusioncharts';
import Charts from 'fusioncharts/fusioncharts.charts';
import ReactFC from 'react-fusioncharts';
import FusionTheme from 'fusioncharts/themes/fusioncharts.theme.fusion';
ReactFC.fcRoot(FusionCharts, Charts, FusionTheme);
const myDataSource = {
"chart": {
"caption": "Countries With Most Oil Reserves [2017-18]",
"subCaption": "In MMbbl = One Million barrels",
"xAxisName": "Country",
"yAxisName": "Reserves (MMbbl)",
"numberSuffix": "K",
"theme": "fusion"
},
"data": [
{
"label": "Venezuela",
"value": "290"
},
{
"label": "Saudi",
"value": "260"
},
{
"label": "Canada",
"value": "180"
},
{
"label": "Iran",
"value": "140"
},
{
"label": "Russia",
"value": "115"
},
{
"label": "UAE",
"value": "100"
},
{
"label": "US",
"value": "30"
},
{
"label": "China",
"value": "30"
}
]
};
const chartConfigs = {
type: 'column2d',
width: 600,
height: 400,
dataFormat: 'json',
dataSource: myDataSource,
};
class Chart extends Component {
// Convert the chart to a 2D Pie chart after 5 secs.
alterChart(chart) {
setTimeout(() => {
chart.chartType('pie2d');
}, 5000);
}
render() {
return (
<div>
<ReactFC {...chartConfigs} onRender={alterChart} />
</div>
);
}
}
ReactDOM.render(
<Chart />,
document.getElementById('root'),
);
$ npm test
npm start
to start the dev server.http://localhost:5000/
in your browser.$ git clone https://github.com/fusioncharts/react-fusioncharts-component.git
$ cd react-fusioncharts-component
$ npm i
$ npm start
To build, run:
$ npm run build
FAQs
Simple and Lightweight React component for FusionCharts JavaScript Charting Library
The npm package react-fusioncharts receives a total of 11,614 weekly downloads. As such, react-fusioncharts popularity was classified as popular.
We found that react-fusioncharts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.