Skip to content

Commit c1f807d

Browse files
committed
Changed readme
1 parent 07fa181 commit c1f807d

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,69 @@ Use this AngularJS charts plugin to add interactive charts to your web and mobil
1010
### Demos
1111
To learn what you can do using this Angular charts plugin, explore some [live demos](http://www.fusioncharts.com/angularjs-charts/).
1212

13+
### Usage
14+
#### Step 1: Include angularjs-fusioncharts.js and fusioncharts
15+
In your index.html
16+
```xml
17+
<script type="text/javascript" src="/path/to/fusioncharts.js"></script>
18+
<script type="text/javascript" src="/path/to/angular.js"></script>
19+
<script type="text/javascript" src="/path/to/angularjs-fusioncharts.js"></script>
20+
```
21+
22+
### Step 2: Include ng-fusioncharts in your module
23+
In the app, include ng-fusioncharts as a dependency. If you looking for where to add the dependency, look for the call to angular.module in your code.
24+
25+
```javascript
26+
angular.module("myApp", ["ng-fusioncharts"]);
27+
```
28+
29+
### Step 3: Add the fusioncharts directive
30+
In your HTML, find the section where you wish to add the chart and add a <div> with the fusioncharts directive. We are assuming it's inside a controller called MyController which would change based on your usage.
31+
32+
```xml
33+
<div ng-controller="MyController">
34+
<div
35+
fusioncharts
36+
width="600"
37+
height="400"
38+
type="column2d"
39+
datasource="{{myDataSource}}">
40+
</div>
41+
</div>
42+
```
43+
44+
### Step 4:Populate required variables in controller
45+
In the previous code, we are binding to a scope variable myDataSource, but that hasn't been defined yet. In your controller, set the DataSource as you would for a regular FusionCharts JSON format DataSource ([see this](http://docs.fusioncharts.com/tutorial-getting-started-your-first-charts-building-your-first-chart.html) tutorial for a general introduction to this format).
46+
47+
48+
```javascript
49+
app.controller('MyController', function($scope){
50+
$scope.dataSource = {
51+
"chart": {
52+
"caption": "Countries With Most Oil Reserves [2017-18]",
53+
"subCaption": "In MMbbl = One Million barrels",
54+
"xAxisName": "Country",
55+
"yAxisName": "Reserves (MMbbl)",
56+
"numberSuffix": "K",
57+
"theme": "fusion"
58+
},
59+
"data": [
60+
{ "label": "Venezuela", "value": "290" },
61+
{ "label": "Saudi", "value": "260" },
62+
{ "label": "Canada", "value": "180" },
63+
{ "label": "Iran", "value": "140" },
64+
{ "label": "Russia", "value": "115" },
65+
{ "label": "UAE", "value": "100" },
66+
{ "label": "US", "value": "30" },
67+
{ "label": "China", "value": "30" }
68+
]
69+
};
70+
71+
});
72+
```
73+
And your chart should display when you load the page.
74+
75+
1376
### Tutorial
1477

1578
Following tutorials will help you get started:

0 commit comments

Comments
 (0)