Skip to content

Commit 09d7900

Browse files
committed
0.6.0
1 parent 2e2428a commit 09d7900

File tree

7 files changed

+22
-26
lines changed

7 files changed

+22
-26
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-chart.js",
3-
"version": "0.5.3",
3+
"version": "0.6.0",
44
"main": [
55
"./dist/angular-chart.js",
66
"./dist/angular-chart.css"

dist/angular-chart.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
getColour: '=?',
3636
chartType: '=',
3737
legend: '@',
38-
click: '='
38+
click: '=',
39+
hover: '='
3940
},
4041
link: function (scope, elem/*, attrs */) {
4142
var chart, container = document.createElement('div');
@@ -120,21 +121,24 @@
120121
var chart = new Chart(ctx)[type](data, scope.options || {});
121122
scope.$emit('create', chart);
122123

123-
if (scope.click) {
124-
cvs.onclick = function (evt) {
125-
var click = chart.getPointsAtEvent || chart.getBarsAtEvent || chart.getSegmentsAtEvent;
126-
127-
if (click) {
128-
var activePoints = click.call(chart, evt);
129-
scope.click(activePoints, evt);
130-
scope.$apply();
131-
}
132-
};
133-
}
124+
['hover', 'click'].forEach(function (action) {
125+
if (scope[action]) cvs[action === 'click' ? 'onclick' : 'onmousemove'] = getEventHandler(scope, chart, action);
126+
});
134127
if (scope.legend && scope.legend !== 'false') setLegend(elem, chart);
135128
return chart;
136129
}
137130

131+
function getEventHandler (scope, chart, action) {
132+
return function (evt) {
133+
var atEvent = chart.getPointsAtEvent || chart.getBarsAtEvent || chart.getSegmentsAtEvent;
134+
if (atEvent) {
135+
var activePoints = atEvent.call(chart, evt);
136+
scope[action](activePoints, evt);
137+
scope.$apply();
138+
}
139+
};
140+
}
141+
138142
function getColours (scope) {
139143
var colours = angular.copy(scope.colours) || angular.copy(Chart.defaults.global.colours);
140144
while (colours.length < scope.data.length) {

dist/angular-chart.js.tar.gz

209 Bytes
Binary file not shown.

dist/angular-chart.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)