Skip to content

Commit 399a800

Browse files
committed
Merge branch 'release/1.0.0'
2 parents 0a17326 + 8ff8d43 commit 399a800

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+44368
-0
lines changed

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
10+
# Coverage tools
11+
lib-cov
12+
coverage
13+
coverage.html
14+
.cover*
15+
16+
# Dependency directory
17+
node_modules
18+
bower_components
19+
20+
# Example build directory
21+
example/dist
22+
.publish
23+
24+
# Editor and other tmp files
25+
*.swp
26+
*.un~
27+
*.iml
28+
*.ipr
29+
*.iws
30+
*.sublime-*
31+
.idea/
32+
*.DS_Store

README.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
### [Demos and Documentation](http://fusioncharts.github.io/react-fusioncharts/)
2+
3+
## Introduction
4+
5+
FusionCharts Suite XT is a front-end, JavaScript-based, comprehensive collection of 90+ charts and 1000+ maps. This includes basic and complex charts like the column and bar charts, pie and doughnut charts, treemap, heatmap, logarithmic charts, and so on; gauges like the angular gauge, bulb gauge, thermometer gauge, and so on; and maps for all continents, major countries, and all US states.
6+
7+
The **react-fusioncharts** plugin, along with FusionCharts Suite XT, lets you add interactive JavaScript charts and graphs to your web and mobile applications using only a single ReactJS component.
8+
9+
This article outlines the steps to be executed for rendering charts using the **react-fusioncharts** plugin.
10+
11+
#### Step 1: Install **fusioncharts**, **react**, **react-dom**, and **react-fusioncharts** npm package
12+
Execute the commands below in the terminal to install **fusioncharts**, **react**, **react-dom**, and **react-fusioncharts** node modules.
13+
14+
```sh
15+
npm install react --save
16+
npm install react-dom --save
17+
npm install fusioncharts --save
18+
npm install react-fusioncharts --save
19+
20+
# or single line
21+
npm install react react-dom fusioncharts react-fusioncharts --save
22+
```
23+
24+
#### Step 2: Add the HTML container element for rendering the chart
25+
26+
In your HTML, find the section where you wish to render the chart place a `<div>` for the FusionCharts to be rendered.
27+
28+
`<div id='chart-container'></div>`
29+
30+
#### Step 3: Import react-fusioncharts package from npm
31+
32+
Import **react**, **react-dom**, **fusioncharts**, and **react-fusioncharts** modules, in this order, through npm. In your JavaScript code, define an object that consists of all the configurations and their values, required to render FusionCharts.
33+
34+
```
35+
import React from 'react';
36+
import ReactDOM from 'react-dom';
37+
import fusioncharts from 'fusioncharts';
38+
// Load the charts module
39+
import charts from 'fusioncharts/fusioncharts.charts';
40+
import react-fusioncharts from 'react-fusioncharts';
41+
42+
// Pass fusioncharts as a dependency of charts
43+
charts(FusionCharts)
44+
45+
var chartConfigs = {
46+
type: ...,
47+
renderAt: ...,
48+
className: ..., // ReactJS attribute-name for DOM classes
49+
dataFormat: ...,
50+
dataSource: ...
51+
};
52+
```
53+
54+
#### Step 4: Pass the configurations required for FusionCharts and render the chart
55+
##### FusionCharts plugin for **react** can be used in two ways:
56+
1. Use the **ReactFC** component directly in **ReactDOM** to render the chart. The configurations are passed as props of the component.
57+
2. Create multiple **ReactFC** component inside your custom defined component to render individual charts. This way you would be able to hold the state in your custom component and will be able to perform various activities using the component’s lifecycle hooks.
58+
59+
##### Method 1:
60+
Render the chart in the **React** application for a standalone chart, we can choose to make a component class or directly render the chart with the **ReactFC** component class. The object containing the chart configuration properties are passed to the **FusionCharts** component as props, as shown below:
61+
62+
```
63+
ReactDOM.render(
64+
<ReactFC {...chartConfigs} />,
65+
document.getElementById('chart-container')
66+
);
67+
```
68+
69+
##### Method 2:
70+
Create a custom MyApp component to render the chart as shown below:
71+
72+
```
73+
var MyApp = React.createClass({
74+
..., // Rest of the React Component Code
75+
render: function () {
76+
return (
77+
<ReactFC {...categoryChartConfigs} />
78+
<ReactFC {...revenueChartConfigs} />
79+
);
80+
}
81+
});
82+
83+
ReactDOM.render(
84+
<MyApp />,
85+
document.getElementById('chart-container')
86+
);
87+
```
88+
89+
While it is recommended to create an object, with the configuration properties, and passing the values defined, you can also pass the configuration properties separately as shown below:
90+
91+
```
92+
ReactDOM.render(
93+
<ReactFC
94+
type: ...,
95+
renderAt: ...,
96+
className: ...,
97+
dataFormat: ...,
98+
dataSource: ... />,
99+
document.getElementById('chart-container')
100+
);
101+
```
102+
103+
Your chart should now render when the page is loaded.
104+
105+
### Licensing
106+
React-FusionCharts is open-source and distributed under the terms of the MIT/X11 License. You will still need to download and include FusionCharts in your page. This project provides no direct functionality. You can [Download an evaluation](http://fusioncharts.com/download/). You will still need to purchase a FusionCharts license to use in a commercial environment (FusionCharts is [free for non-commercial and personal use](http://www.fusioncharts.com/download/free/)) .

bower.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "react-fusioncharts",
3+
"version": "0.0.0",
4+
"description": "React FusionCharts",
5+
"main": "dist/react-fusioncharts.min.js",
6+
"homepage": "https://github.com/rohitkr/react-fusioncharts",
7+
"authors": [
8+
"FusionCharts"
9+
],
10+
"moduleType": [
11+
"amd",
12+
"globals",
13+
"node"
14+
],
15+
"keywords": [
16+
"react",
17+
"react-component"
18+
],
19+
"license": "MIT",
20+
"ignore": [
21+
".editorconfig",
22+
".gitignore",
23+
"package.json",
24+
"src",
25+
"node_modules",
26+
"example",
27+
"test"
28+
]
29+
}

dist/react-fusioncharts.js

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ReactFC = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2+
(function (global){
3+
'use strict';
4+
5+
Object.defineProperty(exports, '__esModule', {
6+
value: true
7+
});
8+
9+
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
10+
11+
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
12+
13+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
14+
15+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
16+
17+
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
18+
19+
var _react = (typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null);
20+
21+
var _react2 = _interopRequireDefault(_react);
22+
23+
var FusionCharts = typeof window !== "undefined" ? window['FusionCharts'] : typeof global !== "undefined" ? global['FusionCharts'] : null;
24+
25+
if (typeof FusionCharts === "undefined") {
26+
FusionCharts = require('fusioncharts');
27+
}
28+
29+
var ReactFC = (function (_React$Component) {
30+
_inherits(ReactFC, _React$Component);
31+
32+
function ReactFC(props) {
33+
var _this = this;
34+
35+
_classCallCheck(this, ReactFC);
36+
37+
_get(Object.getPrototypeOf(ReactFC.prototype), 'constructor', this).call(this, props);
38+
39+
this.state = {
40+
caption: props.name
41+
};
42+
43+
this.fcConfig = props;
44+
this.renderAt = props.renderAt;
45+
// this.fcConfig.renderAt = undefined;
46+
47+
this.chartObj = new FusionCharts(this.fcConfig);
48+
49+
this.getRenderAt = function () {
50+
return _this.renderAt || _this.chartObj.id + '-container';
51+
};
52+
}
53+
54+
_createClass(ReactFC, [{
55+
key: 'componentDidMount',
56+
value: function componentDidMount() {
57+
var global = this;
58+
59+
global.chartObj.render(global.getRenderAt());
60+
}
61+
}, {
62+
key: 'componentWillUnmount',
63+
value: function componentWillUnmount() {
64+
this.chartObj && this.chartObj.dispose();
65+
}
66+
}, {
67+
key: 'componentDidUpdate',
68+
value: function componentDidUpdate() {
69+
var global = this,
70+
fcConfig = global.fcConfig,
71+
props = global.props,
72+
chartObj = global.chartObj,
73+
arrImpactedBy;
74+
75+
if (fcConfig.type !== props.type) {
76+
chartObj.chartType(props.type);
77+
}
78+
79+
if (fcConfig.dataSource !== props.dataSource) {
80+
chartObj.setChartData(props.dataSource, props.dataFormat);
81+
}
82+
83+
if (fcConfig.width !== props.width || fcConfig.height !== props.height) {
84+
chartObj.resizeTo(props.width, props.height);
85+
}
86+
87+
arrImpactedBy = fcConfig.impactedBy;
88+
if (arrImpactedBy && arrImpactedBy.length > 0 && arrImpactedBy.indexOf(props.eventSource) > -1) {
89+
chartObj.setChartAttribute(global.fcConfig);
90+
chartObj.setChartData(fcConfig.dataSource);
91+
}
92+
}
93+
}, {
94+
key: 'render',
95+
value: function render() {
96+
var global = this,
97+
renderAt = global.getRenderAt();
98+
99+
return _react2['default'].createElement('div', { className: global.state.className, id: renderAt });
100+
}
101+
}]);
102+
103+
return ReactFC;
104+
})(_react2['default'].Component);
105+
106+
exports['default'] = ReactFC;
107+
module.exports = exports['default'];
108+
109+
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
110+
},{"fusioncharts":undefined}]},{},[1])(1)
111+
});

dist/react-fusioncharts.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
27 KB
Binary file not shown.
26.6 KB
Binary file not shown.
19.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)