Skip to content

Commit 0700c3b

Browse files
committed
Added requirejs docs
1 parent c1f807d commit 0700c3b

File tree

1 file changed

+98
-1
lines changed

1 file changed

+98
-1
lines changed

README.md

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,37 @@ Use this AngularJS charts plugin to add interactive charts to your web and mobil
77

88
You can access all the rich charting features like events, annotations, macros, themes, image-export etc. to make your visualizations stand-out.
99

10+
### Installation
11+
12+
13+
Install fusioncharts library
14+
```bash
15+
$ npm install fusioncharts --save
16+
```
17+
Alternatively you can use downloaded fusioncharts files.
18+
19+
20+
Install angular 1.x.x
21+
```bash
22+
# Any angular 1.x version is compatible
23+
$ npm install [email protected] --save
24+
```
25+
26+
Install angularjs-fusioncharts module
27+
```bash
28+
$ npm install angularjs-fusioncharts --save
29+
```
30+
Alternatively you can use downloaded angularjs-fusioncharts wrapper.
31+
32+
1033
### Demos
1134
To learn what you can do using this Angular charts plugin, explore some [live demos](http://www.fusioncharts.com/angularjs-charts/).
1235

1336
### Usage
1437
#### Step 1: Include angularjs-fusioncharts.js and fusioncharts
1538
In your index.html
1639
```xml
17-
<script type="text/javascript" src="/path/to/fusioncharts.js"></script>
40+
<script type="text/javascript" src="node_modules/fusioncharts/fusioncharts.js"></script>
1841
<script type="text/javascript" src="/path/to/angular.js"></script>
1942
<script type="text/javascript" src="/path/to/angularjs-fusioncharts.js"></script>
2043
```
@@ -72,6 +95,80 @@ app.controller('MyController', function($scope){
7295
```
7396
And your chart should display when you load the page.
7497

98+
### Using `require()` syntax
99+
In script.js
100+
```javascript
101+
// Require AngularJS
102+
var angular = require('angular');
103+
104+
// Require FusionCharts
105+
var FusionCharts = require('fusioncharts');
106+
107+
// Include angularjs-fusioncharts
108+
require('angular-fusioncharts');
109+
110+
// Require Chart modules
111+
var Charts = require('fusioncharts/fusioncharts.charts');
112+
113+
// Initialize Charts with FusionCharts instance
114+
Charts(FusionCharts);
115+
116+
var app = angular.module('myApp', [ 'ng-fusioncharts' ]);
117+
118+
app.controller('MyController', ['$scope', function($scope) {
119+
$scope.dataSource = {
120+
"chart": {
121+
"caption": "Countries With Most Oil Reserves [2017-18]",
122+
"subCaption": "In MMbbl = One Million barrels",
123+
"xAxisName": "Country",
124+
"yAxisName": "Reserves (MMbbl)",
125+
"numberSuffix": "K",
126+
"theme": "fusion"
127+
},
128+
"data": [
129+
{ "label": "Venezuela", "value": "290" },
130+
{ "label": "Saudi", "value": "260" },
131+
{ "label": "Canada", "value": "180" },
132+
{ "label": "Iran", "value": "140" },
133+
{ "label": "Russia", "value": "115" },
134+
{ "label": "UAE", "value": "100" },
135+
{ "label": "US", "value": "30" },
136+
{ "label": "China", "value": "30" }
137+
]
138+
};
139+
}]);
140+
```
141+
Use a bundler like `browserify` to bundle the script
142+
See the installation docs [here](http://browserify.org/)
143+
144+
```bash
145+
$ browserify script.js -o bundle.js
146+
```
147+
In `index.html`
148+
```xml
149+
<html>
150+
<head>
151+
152+
<!-- Include compiled bundle in script tag -->
153+
<script type="text/javascript" src="./bundle.js"></script>
154+
</head>
155+
156+
<body ng-app="myApp">
157+
<div ng-controller="MyController">
158+
<div
159+
fusioncharts
160+
width="600"
161+
height="400"
162+
type="column2d"
163+
datasource="{{myDataSource}}">
164+
</div>
165+
</div>
166+
</body>
167+
</html>
168+
169+
170+
```
171+
Load it in browser , Chart should get displayed
75172

76173
### Tutorial
77174

0 commit comments

Comments
 (0)