Skip to content

Commit cc65cd2

Browse files
author
Subrat
committed
Release branch 1.0.5 merged
2 parents e9f5891 + 1d77a81 commit cc65cd2

Some content is hidden

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

81 files changed

+2158
-44187
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["es2015", "stage-0", "react"]
3+
}

.eslintignore

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
.publish/*
2-
dist/*
3-
example/*
4-
lib/*
5-
node_modules/*
1+
dist/
2+
lib/
3+
node_modules/

.eslintrc

Lines changed: 0 additions & 32 deletions
This file was deleted.

.eslintrc.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
extends: airbnb
2+
env:
3+
browser: true
4+
node: true
5+
rules:
6+
import/no-extraneous-dependencies: 0
7+
react/jsx-filename-extension: 0
8+
react/prop-types: 0
9+
class-methods-use-this: 0
10+
no-plusplus: 0
11+
no-prototype-builtins: 0
12+
react/sort-comp: 0
13+
no-param-reassign: 0
14+
no-return-assign: 0
15+
no-sequences: 0
16+
global-require: 0
17+
import/prefer-default-export: 0

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ example/dist
3030
*.sublime-*
3131
.idea/
3232
*.DS_Store
33+
34+
package-lock.json

README.md

Lines changed: 119 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,156 @@
1-
### [Demos and Documentation](http://fusioncharts.github.io/react-fusioncharts-component/)
1+
#### [Demos and Documentation](https://fusioncharts.github.io/react-fusioncharts-component/)
22

3-
## Introduction
3+
# react-fusionCharts
44

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.
5+
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.
66

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.
7+
## Installation
88

9-
This article outlines the steps to be executed for rendering charts using the **react-fusioncharts** plugin.
9+
To install `react-fusioncharts`, run:
1010

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.
11+
```bash
12+
$ npm install react-fusioncharts --save
13+
```
1314

14-
```sh
15-
npm install react --save
16-
npm install react-dom --save
17-
npm install fusioncharts --save
18-
npm install react-fusioncharts --save
15+
Also install `fusionCharts`, if it is not already installed:
1916

20-
# or single line
21-
npm install react react-dom fusioncharts react-fusioncharts --save
17+
```bash
18+
$ npm install fusioncharts --save
2219
```
2320

24-
#### Step 2: Add the HTML container element for rendering the chart
21+
## Getting Started
2522

26-
In your HTML, find the section where you wish to render the chart place a `<div>` for the FusionCharts to be rendered.
23+
After installing `react-fusioncharts`, import it in your `React` app:
2724

28-
`<div id='chart-container'></div>`
25+
```javascript
26+
import React from 'react';
27+
import ReactDOM from 'react-dom';
28+
import FusionCharts from 'fusioncharts';
29+
import Charts from 'fusioncharts/fusioncharts.charts';
30+
import ReactFC from 'react-fusioncharts';
2931

30-
#### Step 3: Import react-fusioncharts package from npm
32+
Charts(FusionCharts);
33+
34+
const myDataSource = {
35+
chart: {
36+
caption: 'Harry\'s SuperMart',
37+
subCaption: 'Top 5 stores in last month by revenue',
38+
numberPrefix: '$',
39+
},
40+
data: [
41+
{
42+
label: 'Bakersfield Central',
43+
value: '880000',
44+
},
45+
{
46+
label: 'Garden Groove harbour',
47+
value: '730000',
48+
},
49+
{
50+
label: 'Los Angeles Topanga',
51+
value: '590000',
52+
},
53+
{
54+
label: 'Compton-Rancho Dom',
55+
value: '520000',
56+
},
57+
{
58+
label: 'Daly City Serramonte',
59+
value: '330000',
60+
},
61+
],
62+
};
3163

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.
64+
const chartConfigs = {
65+
type: 'column2d',
66+
width: 600,
67+
height: 400,
68+
dataFormat: 'json',
69+
dataSource: myDataSource,
70+
};
3371

72+
ReactDOM.render(
73+
<ReactFC {...chartConfigs} />,
74+
document.getElementById('root'),
75+
);
3476
```
77+
78+
## Using Licensed Version of FusionCharts
79+
80+
While using licensed version of `FusionCharts`, you need to specify library as follows:
81+
82+
Specify library for all charts:
83+
84+
```javascript
3585
import React from 'react';
3686
import ReactDOM from 'react-dom';
37-
import fusioncharts from 'fusioncharts';
38-
// Load the charts module
39-
import charts from 'fusioncharts/fusioncharts.charts';
4087
import ReactFC from 'react-fusioncharts';
4188

42-
// Pass fusioncharts as a dependency of charts
43-
charts(FusionCharts)
89+
// Here import licensed version of FusionCharts
90+
import FusionCharts from './path/to/fusioncharts';
91+
import Charts from './path/to/fusioncharts/fusioncharts.charts';
92+
93+
// Provide FusionCharts core and other modules to resolve
94+
ReactFC.fcRoot(FusionCharts, Charts)
95+
96+
// Rest of the application code
4497

45-
var chartConfigs = {
46-
type: ...,
47-
renderAt: ...,
48-
className: ..., // ReactJS attribute-name for DOM classes
49-
dataFormat: ...,
50-
dataSource: ...
51-
};
5298
```
5399

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.
100+
Specify library for a particular chart:
101+
102+
```javascript
103+
import React from 'react';
104+
import ReactDOM from 'react-dom';
105+
import ReactFC from 'react-fusioncharts';
58106

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:
107+
// Here import licensed version of FusionCharts
108+
import FusionCharts from './path/to/fusioncharts';
109+
import Charts from './path/to/fusioncharts/fusioncharts.charts';
110+
111+
// Resolve modules
112+
Charts(FusionCharts)
61113

62-
```
63114
ReactDOM.render(
64-
<ReactFC {...chartConfigs} />,
65-
document.getElementById('chart-container')
115+
<ReactFC
116+
width="600"
117+
height="400"
118+
type="column2d"
119+
dataSource={ /* Chart data source */ }
120+
fcLibrary={FusionCharts} // Provide FusionCharts library
121+
/>,
122+
document.getElementById('root'),
66123
);
67-
```
68124

69-
##### Method 2:
70-
Create a custom MyApp component to render the chart as shown below:
125+
// Rest of the application code
71126

72127
```
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-
});
82128

83-
ReactDOM.render(
84-
<MyApp />,
85-
document.getElementById('chart-container')
86-
);
129+
## Test
130+
131+
```sh
132+
$ npm test
87133
```
88134

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:
135+
## Contributing
136+
137+
* Clone the repository.
138+
* Install dependencies
139+
* Run `npm start` to start the dev server.
140+
* Open `http://localhost:5000/` in your browser.
90141

142+
```sh
143+
$ git clone https://github.com/fusioncharts/react-fusioncharts-component.git
144+
$ cd react-fusioncharts-component
145+
$ npm i
146+
$ npm start
91147
```
92-
ReactDOM.render(
93-
<ReactFC
94-
type: ...,
95-
renderAt: ...,
96-
className: ...,
97-
dataFormat: ...,
98-
dataSource: ... />,
99-
document.getElementById('chart-container')
100-
);
148+
149+
To build, run:
150+
151+
```sh
152+
$ npm run build
101153
```
102154

103-
Your chart should now render when the page is loaded.
155+
### [Demos and Documentation](https://fusioncharts.github.io/react-fusioncharts-component/)
104156

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/)) .

0 commit comments

Comments
 (0)