amCharts-Angular
amCharts-Angular copied to clipboard
chart.categoryAxis.listeners not being called.
I can attach event listeners to the chart object like is described in this other issue but when I try to attach it to the categoryAxis elements it does not work. I don't get an error and I know the event is being triggered it just seems as if the listener would not have been added. It is not being "Stripped" from the categoryAxis in the directiver, so I would really appreciate any hints.
The same code works like a charm without angular.
` angular.module('myApp.viewAmCharts', ['ngRoute','amChartsDirective']) .config(['$routeProvider', function($routeProvider) { $routeProvider.when('/viewAmCharts', { templateUrl: 'viewAmCharts/viewAmCharts.html', controller: 'amChartsController' }); }])
.controller('amChartsController', function ($scope) { $scope.amChartOptions = { type: "serial", addClassNames: 'true', categoryField: "year", rotate: true, plotAreaFillAlphas: 1, plotAreaFillColors: "#F0F2F7", legend: { enabled: true }, valueAxes: [{ position: "top", title: "Million USD", gridColor: "#FFFFFF", gridAlpha: 1, }], categoryAxis: { gridColor: "#FFFFFF", gridAlpha: 1, gridPosition: "start", tickLength: 0, parseDates: false, listeners: [{ event: "clickCategoryItem", method: function (e) { alert("Clicked on " + e.value); } }] }, graphs: [{ type: "column", title: "Income", valueField: "income", fillAlphas: 1, fillColors: "#F1A065", lineColor:"#F1A065", labelText: "[[income]]", }], listeners: [ { event: "clickGraphItem", method: function (e) { alert("Clicked on " + e.value); } },{ event: "clickGraphItem", method: function (e) { alert("Clicked on " + e.value); }
}
]
}
$scope.amChartOptions.data = [{
year: 2005,
income: 23.5,
expenses: 18.1
}, {
year: 2006,
income: 26.2,
expenses: 22.8
}, {
year: 2007,
income: 30.1,
expenses: 23.9
}, {
year: 2008,
income: 29.5,
expenses: 25.1
}, {
year: 2009,
income: 24.6,
expenses: 25
}];
}); `