Skip to content
Nicholas Bering edited this page Sep 6, 2015 · 2 revisions

API Documentation

Documentation Note

This page is not documentation on the Google Charts API. For that, please see https://developers.google.com/chart. This page is about the API provided with this project for use in your own custom directives.

Disclaimer

While changes made in the directive to expose this API were as backward-compatible as possible for normal use, this API is very new (as of May 12, 2015), and may be subject to change with little or no notice.

GoogleChartController

Methods

registerWrapperListener(eventName, listenerFn, [listenerObject]);

Used to register a listener function to a Google Charts API event on the ChartWrapper object within the googleChart directive.

Param Name Type Description
eventName string Can be any event exposed by the Google Charts API on ChartWrapper. Currently these are: error, ready, and select.
listenerFn function The callback function for the event. Will be called with AngularJS' $inject.invoke() having the local variables chartWrapper, chart, and args. args is the JavaScript arguments object returned in the Google Charts API function call. This exposes anything returned to the directive in the event. It's a bit confusing, but extremely powerful.
listenerObject Object Optional. The object context for the callback to run in. Pass this in most cases to preserve context of this when the callback runs.

registerServiceListener(eventName, listenerFn, [listenerObject]);

Used to register a listener function to a Google Charts API event on the ChartWrapper object within the googleChart directive.

Param Name Type Description
eventName string Can be any event exposed by the Google Charts API on ChartWrapper. Currently the only event is beforeDraw.
listenerFn function The callback function for the event. Will be called with AngularJS' $inject.invoke() having the local variable chartWrapper.
listenerObject Object Optional. The object context for the callback to run in. Pass this in most cases to preserve context of this when the callback runs.

registerChartListener(eventName, listenerFn, [listenerObject]);

Same as registerWrapperListener(...), except that these listener functions are applied to the inner chart. This chart (the one that actually draws your chart on screen). This can handle events available on specific chart types, such is the GeoChart's regionClick event.

Param Name Type Description
eventName string Can be any event exposed by the Google Charts API on the chart in use. See Google's reference for your chart for a list.
listenerFn function The callback function for the event. Will be called with AngularJS' $inject.invoke() having the local variables chartWrapper, chart, and args. args is the JavaScript arguments object returned in the Google Charts API function call. This exposes anything returned to the directive in the event. It's a bit confusing, but extremely powerful.
listenerObject Object Optional. The object context for the callback to run in. Pass this in most cases to preserve context of this when the callback runs.

Examples

See source code in ng-google-chart.js. The agcOnReady directive is a great simple example. See agcOnSelect for a slightly more complex example. Better examples in the docs should be coming soon, but this will likely be changing quickly in the immediate future.