|
18 | 18 | 'use strict'; |
19 | 19 |
|
20 | 20 | Chart.defaults.global.multiTooltipTemplate = '<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>'; |
| 21 | + Chart.defaults.global.tooltips.mode = 'label'; |
21 | 22 | Chart.defaults.global.elements.line.borderWidth = 2; |
22 | 23 | Chart.defaults.global.elements.rectangle.borderWidth = 2; |
23 | 24 | Chart.defaults.global.legend.display = false; |
|
31 | 32 | '#4D5360' // dark grey |
32 | 33 | ]; |
33 | 34 |
|
34 | | - var usingExcanvas = typeof window.G_vmlCanvasManager === 'object' && |
| 35 | + var useExcanvas = typeof window.G_vmlCanvasManager === 'object' && |
35 | 36 | window.G_vmlCanvasManager !== null && |
36 | 37 | typeof window.G_vmlCanvasManager.initElement === 'function'; |
37 | 38 |
|
38 | | - if (usingExcanvas) Chart.defaults.global.animation = false; |
| 39 | + if (useExcanvas) Chart.defaults.global.animation = false; |
39 | 40 |
|
40 | 41 | return angular.module('chart.js', []) |
41 | 42 | .provider('ChartJs', ChartJsProvider) |
|
106 | 107 | link: function (scope, elem/*, attrs */) { |
107 | 108 | var chart; |
108 | 109 |
|
109 | | - if (usingExcanvas) window.G_vmlCanvasManager.initElement(elem[0]); |
| 110 | + if (useExcanvas) window.G_vmlCanvasManager.initElement(elem[0]); |
110 | 111 |
|
111 | 112 | // Order of setting "watch" matter |
112 | 113 |
|
|
139 | 140 | destroyChart(chart, scope); |
140 | 141 | }); |
141 | 142 |
|
| 143 | + scope.$on('$resize', function () { |
| 144 | + if (chart) chart.resize(); |
| 145 | + }); |
| 146 | + |
142 | 147 | function resetChart (newVal, oldVal) { |
143 | 148 | if (isEmpty(newVal)) return; |
144 | 149 | if (angular.equals(newVal, oldVal)) return; |
|
242 | 247 | function getColor (color) { |
243 | 248 | return { |
244 | 249 | backgroundColor: rgba(color, 0.2), |
245 | | - borderColor: rgba(color, 1), |
246 | 250 | pointBackgroundColor: rgba(color, 1), |
| 251 | + pointHoverBackgroundColor: rgba(color, 0.8), |
| 252 | + borderColor: rgba(color, 1), |
247 | 253 | pointBorderColor: '#fff', |
248 | | - pointHoverBackgroundColor: '#fff', |
249 | | - pointHoverBorderColor: rgba(color, 0.8) |
| 254 | + pointHoverBorderColor: rgba(color, 1) |
250 | 255 | }; |
251 | 256 | } |
252 | 257 |
|
|
255 | 260 | } |
256 | 261 |
|
257 | 262 | function rgba (color, alpha) { |
258 | | - if (usingExcanvas) { |
259 | | - // rgba not supported by IE8 |
260 | | - return 'rgb(' + color.join(',') + ')'; |
261 | | - } else { |
262 | | - return 'rgba(' + color.concat(alpha).join(',') + ')'; |
263 | | - } |
| 263 | + // rgba not supported by IE8 |
| 264 | + return useExcanvas ? 'rgb(' + color.join(',') + ')' : 'rgba(' + color.concat(alpha).join(',') + ')'; |
264 | 265 | } |
265 | 266 |
|
266 | 267 | // Credit: http://stackoverflow.com/a/11508164/1190235 |
|
0 commit comments