Skip to content

Commit

Permalink
Documentation added for events. Fixes #26.
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncan Walker authored and Duncan Walker committed Sep 10, 2018
1 parent 42b1d59 commit 737a857
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ See the [demo app](http://sir-dunxalot.github.io/ember-google-charts/) here.
- [Actions](#actions)
- [chartDidRender()](#chartdidrender)
- [packagesDidLoad()](#packagesdidload)
- [Events](#events)
- [Custom Charts](#custom-charts)
- [Content Security Policy](#content-security-policy)
- [Testing](#testing)
Expand Down Expand Up @@ -284,6 +285,42 @@ export default Controller.extend({
}}
```

### Events

It's easy to listen to events emitted by a chart:

```js
/* stats/controller.js */

import Controller from '@ember/controller';

export default Controller.extend({

actions: {
addChartEventListeners(chart) {
const { google: { visualization } } = window;

visualization.events.addListener(chart, 'onmouseover', function(event) {
/* Do something here... */;
});
}
},

});
```

```hbs
{{!-- stats/template.hbs --}}
{{line-chart
data=data
options=options
chartDidRender=(action 'addChartEventListeners')
}}
```

For more information on events, see the [Google Charts event documentation](https://developers.google.com/chart/interactive/docs/events).

### Custom Charts

All chart components in this addon extend from a single core component: the `GoogleChartComponent`.
Expand Down

0 comments on commit 737a857

Please sign in to comment.