Skip to content

Commit 06b40b1

Browse files
author
Rahul9046
committed
updated readme file
1 parent e6d95a1 commit 06b40b1

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

README.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,102 @@ In `index.html`
177177
```
178178
Load it in browser , Chart should get displayed
179179

180+
### Listening to events
181+
182+
Fusincharts events can be subscribed by attaching scope functions to event attributes.
183+
All the events attributes start with `fcevent-`
184+
followed by the event name in lowercase
185+
186+
Usage in template :
187+
188+
```xml
189+
<fusioncharts
190+
width="400"
191+
height="400"
192+
type="column2d"
193+
datasource="{{myDataSource}}"
194+
fcevent-dataplotrollover="rollover(event, args)">
195+
</fusioncharts>
196+
```
197+
In the given above template, `rollover` is the scope function that needs to be defined in the controller's code.
198+
199+
For more on this read [here](https://www.fusioncharts.com/dev/api/fusioncharts/fusioncharts-events)
200+
201+
```
202+
var app = angular.module('myApp', ['ng-fusioncharts']);
203+
204+
app.controller('MyController', function($scope){
205+
$scope.myDataSource = {
206+
"chart": {
207+
"caption": "Countries With Most Oil Reserves [2017-18]",
208+
"subCaption": "In MMbbl = One Million barrels",
209+
"xAxisName": "Country",
210+
"yAxisName": "Reserves (MMbbl)",
211+
"numberSuffix": "K",
212+
"theme": "fusion"
213+
},
214+
"data": [
215+
{ "label": "Venezuela", "value": "290" },
216+
{ "label": "Saudi", "value": "260" },
217+
{ "label": "Canada", "value": "180" },
218+
{ "label": "Iran", "value": "140" },
219+
{ "label": "Russia", "value": "115" },
220+
{ "label": "UAE", "value": "100" },
221+
{ "label": "US", "value": "30" },
222+
{ "label": "China", "value": "30" }
223+
]
224+
};
225+
226+
$scope.rollover = function(event, name){
227+
console.log(event, name);
228+
}
229+
});
230+
```
231+
232+
Get the list of fusioncharts' [events](https://www.fusioncharts.com/dev/advanced-chart-configurations/events/classifying-events)
233+
234+
### Chart API
235+
236+
Using api of charts involves getting the FusionCharts chart instance from the ```initialized``` event. It provides the chart object as a parameter which can be operated upon later.
237+
238+
In template, we add ```initialized``` event
239+
240+
```xml
241+
<fusioncharts
242+
width="400"
243+
height="400"
244+
type="column2d"
245+
datasource="{{myDataSource}}"
246+
initialized="onInitialized(chart)">
247+
</fusioncharts>
248+
<button ng-click="changeCaption()">Change Chart Caption</button>
249+
```
250+
251+
In order to use the chart instance , we need to store it.
252+
253+
```
254+
var app = angular.module('myApp', ['ng-fusioncharts']);
255+
256+
app.controller('MyController', function($scope){
257+
var chart;
258+
$scope.datasource = {
259+
...// same data as above
260+
};
261+
262+
$scope.onInitialized = function(chartObj){
263+
chart = chartObj;
264+
}
265+
266+
$scope.changeCaption = function(){
267+
chart.setChartAttribute('caption', 'Caption changed');
268+
}
269+
});
270+
```
271+
In the given above example clicking on the button changes the caption of the chart to ```Caption changed```
272+
273+
Get the list of fusioncharts' [methods](https://www.fusioncharts.com/dev/api/fusioncharts/fusioncharts-methods)
274+
275+
180276
### Tutorial
181277

182278
Following tutorials will help you get started:

0 commit comments

Comments
 (0)