Bump up ChartJs to 2.2.1 and AngularChart to 1.0
Change-Id: I9ac9e9fa381e63dbfa2c0cf715c4e1280dc80c2d
Showing
8 changed files
with
190 additions
and
233 deletions
... | @@ -92,7 +92,6 @@ | ... | @@ -92,7 +92,6 @@ |
92 | <script src="app/fw/layer/loading.js"></script> | 92 | <script src="app/fw/layer/loading.js"></script> |
93 | 93 | ||
94 | <!-- Framework and library stylesheets included here --> | 94 | <!-- Framework and library stylesheets included here --> |
95 | - <link rel="stylesheet" href="tp/angular-chart.min.css"> | ||
96 | 95 | ||
97 | <!-- TODO: use a single catenated-minified file here --> | 96 | <!-- TODO: use a single catenated-minified file here --> |
98 | <link rel="stylesheet" href="app/onos.css"> | 97 | <link rel="stylesheet" href="app/onos.css"> | ... | ... |
web/gui/src/main/webapp/tp/Chart.js
100755 → 100644
This diff could not be displayed because it is too large.
web/gui/src/main/webapp/tp/Chart.min.js
100755 → 100644
This diff could not be displayed because it is too large.
1 | -.chart-legend, | ||
2 | -.bar-legend, | ||
3 | -.line-legend, | ||
4 | -.pie-legend, | ||
5 | -.radar-legend, | ||
6 | -.polararea-legend, | ||
7 | -.doughnut-legend { | ||
8 | - list-style-type: none; | ||
9 | - margin-top: 5px; | ||
10 | - text-align: center; | ||
11 | - /* NOTE: Browsers automatically add 40px of padding-left to all lists, so we should offset that, otherwise the legend is off-center */ | ||
12 | - -webkit-padding-start: 0; | ||
13 | - /* Webkit */ | ||
14 | - -moz-padding-start: 0; | ||
15 | - /* Mozilla */ | ||
16 | - padding-left: 0; | ||
17 | - /* IE (handles all cases, really, but we should also include the vendor-specific properties just to be safe) */ | ||
18 | -} | ||
19 | -.chart-legend li, | ||
20 | -.bar-legend li, | ||
21 | -.line-legend li, | ||
22 | -.pie-legend li, | ||
23 | -.radar-legend li, | ||
24 | -.polararea-legend li, | ||
25 | -.doughnut-legend li { | ||
26 | - display: inline-block; | ||
27 | - white-space: nowrap; | ||
28 | - position: relative; | ||
29 | - margin-bottom: 4px; | ||
30 | - border-radius: 5px; | ||
31 | - padding: 2px 8px 2px 28px; | ||
32 | - font-size: smaller; | ||
33 | - cursor: default; | ||
34 | -} | ||
35 | -.chart-legend-icon, | ||
36 | -.bar-legend-icon, | ||
37 | -.line-legend-icon, | ||
38 | -.pie-legend-icon, | ||
39 | -.radar-legend-icon, | ||
40 | -.polararea-legend-icon, | ||
41 | -.doughnut-legend-icon { | ||
42 | - display: block; | ||
43 | - position: absolute; | ||
44 | - left: 0; | ||
45 | - top: 0; | ||
46 | - width: 20px; | ||
47 | - height: 20px; | ||
48 | - border-radius: 5px; | ||
49 | -} |
1 | +/*! | ||
2 | + * angular-chart.js - An angular.js wrapper for Chart.js | ||
3 | + * http://jtblin.github.io/angular-chart.js/ | ||
4 | + * Version: 1.0.0 | ||
5 | + * | ||
6 | + * Copyright 2016 Jerome Touffe-Blin | ||
7 | + * Released under the BSD-2-Clause license | ||
8 | + * https://github.com/jtblin/angular-chart.js/blob/master/LICENSE | ||
9 | + */ | ||
1 | (function (factory) { | 10 | (function (factory) { |
2 | 'use strict'; | 11 | 'use strict'; |
3 | if (typeof exports === 'object') { | 12 | if (typeof exports === 'object') { |
... | @@ -10,15 +19,19 @@ | ... | @@ -10,15 +19,19 @@ |
10 | define(['angular', 'chart'], factory); | 19 | define(['angular', 'chart'], factory); |
11 | } else { | 20 | } else { |
12 | // Browser globals | 21 | // Browser globals |
22 | + if (typeof angular === 'undefined' || typeof Chart === 'undefined') | ||
23 | + throw new Error('Chart.js library needs to included, see http://jtblin.github.io/angular-chart.js/'); | ||
13 | factory(angular, Chart); | 24 | factory(angular, Chart); |
14 | } | 25 | } |
15 | }(function (angular, Chart) { | 26 | }(function (angular, Chart) { |
16 | 'use strict'; | 27 | 'use strict'; |
17 | 28 | ||
18 | - Chart.defaults.global.responsive = true; | ||
19 | Chart.defaults.global.multiTooltipTemplate = '<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>'; | 29 | Chart.defaults.global.multiTooltipTemplate = '<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>'; |
20 | - | 30 | + Chart.defaults.global.tooltips.mode = 'label'; |
21 | - Chart.defaults.global.colours = [ | 31 | + Chart.defaults.global.elements.line.borderWidth = 2; |
32 | + Chart.defaults.global.elements.rectangle.borderWidth = 2; | ||
33 | + Chart.defaults.global.legend.display = false; | ||
34 | + Chart.defaults.global.colors = [ | ||
22 | '#97BBCD', // blue | 35 | '#97BBCD', // blue |
23 | '#DCDCDC', // light grey | 36 | '#DCDCDC', // light grey |
24 | '#F7464A', // red | 37 | '#F7464A', // red |
... | @@ -28,34 +41,37 @@ | ... | @@ -28,34 +41,37 @@ |
28 | '#4D5360' // dark grey | 41 | '#4D5360' // dark grey |
29 | ]; | 42 | ]; |
30 | 43 | ||
31 | - var usingExcanvas = typeof window.G_vmlCanvasManager === 'object' && | 44 | + var useExcanvas = typeof window.G_vmlCanvasManager === 'object' && |
32 | window.G_vmlCanvasManager !== null && | 45 | window.G_vmlCanvasManager !== null && |
33 | typeof window.G_vmlCanvasManager.initElement === 'function'; | 46 | typeof window.G_vmlCanvasManager.initElement === 'function'; |
34 | 47 | ||
35 | - if (usingExcanvas) Chart.defaults.global.animation = false; | 48 | + if (useExcanvas) Chart.defaults.global.animation = false; |
36 | 49 | ||
37 | return angular.module('chart.js', []) | 50 | return angular.module('chart.js', []) |
38 | .provider('ChartJs', ChartJsProvider) | 51 | .provider('ChartJs', ChartJsProvider) |
39 | .factory('ChartJsFactory', ['ChartJs', '$timeout', ChartJsFactory]) | 52 | .factory('ChartJsFactory', ['ChartJs', '$timeout', ChartJsFactory]) |
40 | .directive('chartBase', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory(); }]) | 53 | .directive('chartBase', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory(); }]) |
41 | - .directive('chartLine', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Line'); }]) | 54 | + .directive('chartLine', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('line'); }]) |
42 | - .directive('chartBar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Bar'); }]) | 55 | + .directive('chartBar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('bar'); }]) |
43 | - .directive('chartRadar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Radar'); }]) | 56 | + .directive('chartHorizontalBar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('horizontalBar'); }]) |
44 | - .directive('chartDoughnut', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Doughnut'); }]) | 57 | + .directive('chartRadar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('radar'); }]) |
45 | - .directive('chartPie', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('Pie'); }]) | 58 | + .directive('chartDoughnut', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('doughnut'); }]) |
46 | - .directive('chartPolarArea', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('PolarArea'); }]); | 59 | + .directive('chartPie', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('pie'); }]) |
60 | + .directive('chartPolarArea', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('polarArea'); }]) | ||
61 | + .directive('chartBubble', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('bubble'); }]) | ||
62 | + .name; | ||
47 | 63 | ||
48 | /** | 64 | /** |
49 | * Wrapper for chart.js | 65 | * Wrapper for chart.js |
50 | * Allows configuring chart js using the provider | 66 | * Allows configuring chart js using the provider |
51 | * | 67 | * |
52 | * angular.module('myModule', ['chart.js']).config(function(ChartJsProvider) { | 68 | * angular.module('myModule', ['chart.js']).config(function(ChartJsProvider) { |
53 | - * ChartJsProvider.setOptions({ responsive: true }); | 69 | + * ChartJsProvider.setOptions({ responsive: false }); |
54 | - * ChartJsProvider.setOptions('Line', { responsive: false }); | 70 | + * ChartJsProvider.setOptions('Line', { responsive: true }); |
55 | * }))) | 71 | * }))) |
56 | */ | 72 | */ |
57 | function ChartJsProvider () { | 73 | function ChartJsProvider () { |
58 | - var options = {}; | 74 | + var options = { responsive: true }; |
59 | var ChartJs = { | 75 | var ChartJs = { |
60 | Chart: Chart, | 76 | Chart: Chart, |
61 | getOptions: function (type) { | 77 | getOptions: function (type) { |
... | @@ -88,84 +104,52 @@ | ... | @@ -88,84 +104,52 @@ |
88 | return { | 104 | return { |
89 | restrict: 'CA', | 105 | restrict: 'CA', |
90 | scope: { | 106 | scope: { |
91 | - data: '=?', | 107 | + chartGetColor: '=?', |
92 | - labels: '=?', | ||
93 | - options: '=?', | ||
94 | - series: '=?', | ||
95 | - colours: '=?', | ||
96 | - getColour: '=?', | ||
97 | chartType: '=', | 108 | chartType: '=', |
98 | - legend: '@', | ||
99 | - click: '=?', | ||
100 | - hover: '=?', | ||
101 | - | ||
102 | chartData: '=?', | 109 | chartData: '=?', |
103 | chartLabels: '=?', | 110 | chartLabels: '=?', |
104 | chartOptions: '=?', | 111 | chartOptions: '=?', |
105 | chartSeries: '=?', | 112 | chartSeries: '=?', |
106 | - chartColours: '=?', | 113 | + chartColors: '=?', |
107 | - chartLegend: '@', | ||
108 | chartClick: '=?', | 114 | chartClick: '=?', |
109 | - chartHover: '=?' | 115 | + chartHover: '=?', |
116 | + chartDatasetOverride: '=?' | ||
110 | }, | 117 | }, |
111 | link: function (scope, elem/*, attrs */) { | 118 | link: function (scope, elem/*, attrs */) { |
112 | - var chart, container = document.createElement('div'); | 119 | + if (useExcanvas) window.G_vmlCanvasManager.initElement(elem[0]); |
113 | - container.className = 'chart-container'; | ||
114 | - elem.replaceWith(container); | ||
115 | - container.appendChild(elem[0]); | ||
116 | - | ||
117 | - if (usingExcanvas) window.G_vmlCanvasManager.initElement(elem[0]); | ||
118 | - | ||
119 | - ['data', 'labels', 'options', 'series', 'colours', 'legend', 'click', 'hover'].forEach(deprecated); | ||
120 | - function aliasVar (fromName, toName) { | ||
121 | - scope.$watch(fromName, function (newVal) { | ||
122 | - if (typeof newVal === 'undefined') return; | ||
123 | - scope[toName] = newVal; | ||
124 | - }); | ||
125 | - } | ||
126 | - /* provide backward compatibility to "old" directive names, by | ||
127 | - * having an alias point from the new names to the old names. */ | ||
128 | - aliasVar('chartData', 'data'); | ||
129 | - aliasVar('chartLabels', 'labels'); | ||
130 | - aliasVar('chartOptions', 'options'); | ||
131 | - aliasVar('chartSeries', 'series'); | ||
132 | - aliasVar('chartColours', 'colours'); | ||
133 | - aliasVar('chartLegend', 'legend'); | ||
134 | - aliasVar('chartClick', 'click'); | ||
135 | - aliasVar('chartHover', 'hover'); | ||
136 | 120 | ||
137 | // Order of setting "watch" matter | 121 | // Order of setting "watch" matter |
122 | + scope.$watch('chartData', watchData, true); | ||
123 | + scope.$watch('chartSeries', watchOther, true); | ||
124 | + scope.$watch('chartLabels', watchOther, true); | ||
125 | + scope.$watch('chartOptions', watchOther, true); | ||
126 | + scope.$watch('chartColors', watchOther, true); | ||
127 | + scope.$watch('chartDatasetOverride', watchOther, true); | ||
128 | + scope.$watch('chartType', watchType, false); | ||
129 | + | ||
130 | + scope.$on('$destroy', function () { | ||
131 | + destroyChart(scope); | ||
132 | + }); | ||
133 | + | ||
134 | + scope.$on('$resize', function () { | ||
135 | + if (scope.chart) scope.chart.resize(); | ||
136 | + }); | ||
138 | 137 | ||
139 | - scope.$watch('data', function (newVal, oldVal) { | 138 | + function watchData (newVal, oldVal) { |
140 | if (! newVal || ! newVal.length || (Array.isArray(newVal[0]) && ! newVal[0].length)) { | 139 | if (! newVal || ! newVal.length || (Array.isArray(newVal[0]) && ! newVal[0].length)) { |
141 | - destroyChart(chart, scope); | 140 | + destroyChart(scope); |
142 | return; | 141 | return; |
143 | } | 142 | } |
144 | var chartType = type || scope.chartType; | 143 | var chartType = type || scope.chartType; |
145 | if (! chartType) return; | 144 | if (! chartType) return; |
146 | 145 | ||
147 | - if (chart && canUpdateChart(newVal, oldVal)) | 146 | + if (scope.chart && canUpdateChart(newVal, oldVal)) |
148 | - return updateChart(chart, newVal, scope, elem); | 147 | + return updateChart(newVal, scope); |
149 | - | ||
150 | - createChart(chartType); | ||
151 | - }, true); | ||
152 | 148 | ||
153 | - scope.$watch('series', resetChart, true); | 149 | + createChart(chartType, scope, elem); |
154 | - scope.$watch('labels', resetChart, true); | 150 | + } |
155 | - scope.$watch('options', resetChart, true); | ||
156 | - scope.$watch('colours', resetChart, true); | ||
157 | - | ||
158 | - scope.$watch('chartType', function (newVal, oldVal) { | ||
159 | - if (isEmpty(newVal)) return; | ||
160 | - if (angular.equals(newVal, oldVal)) return; | ||
161 | - createChart(newVal); | ||
162 | - }); | ||
163 | - | ||
164 | - scope.$on('$destroy', function () { | ||
165 | - destroyChart(chart, scope); | ||
166 | - }); | ||
167 | 151 | ||
168 | - function resetChart (newVal, oldVal) { | 152 | + function watchOther (newVal, oldVal) { |
169 | if (isEmpty(newVal)) return; | 153 | if (isEmpty(newVal)) return; |
170 | if (angular.equals(newVal, oldVal)) return; | 154 | if (angular.equals(newVal, oldVal)) return; |
171 | var chartType = type || scope.chartType; | 155 | var chartType = type || scope.chartType; |
... | @@ -173,49 +157,40 @@ | ... | @@ -173,49 +157,40 @@ |
173 | 157 | ||
174 | // chart.update() doesn't work for series and labels | 158 | // chart.update() doesn't work for series and labels |
175 | // so we have to re-create the chart entirely | 159 | // so we have to re-create the chart entirely |
176 | - createChart(chartType); | 160 | + createChart(chartType, scope, elem); |
177 | } | 161 | } |
178 | 162 | ||
179 | - function createChart (type) { | 163 | + function watchType (newVal, oldVal) { |
180 | - if (isResponsive(type, scope) && elem[0].clientHeight === 0 && container.clientHeight === 0) { | 164 | + if (isEmpty(newVal)) return; |
181 | - return $timeout(function () { | 165 | + if (angular.equals(newVal, oldVal)) return; |
182 | - createChart(type); | 166 | + createChart(newVal, scope, elem); |
183 | - }, 50, false); | 167 | + } |
184 | } | 168 | } |
185 | - if (! scope.data || ! scope.data.length) return; | 169 | + }; |
186 | - scope.getColour = typeof scope.getColour === 'function' ? scope.getColour : getRandomColour; | 170 | + }; |
187 | - var colours = getColours(type, scope); | ||
188 | - var cvs = elem[0], ctx = cvs.getContext('2d'); | ||
189 | - var data = Array.isArray(scope.data[0]) ? | ||
190 | - getDataSets(scope.labels, scope.data, scope.series || [], colours) : | ||
191 | - getData(scope.labels, scope.data, colours); | ||
192 | - var options = angular.extend({}, ChartJs.getOptions(type), scope.options); | ||
193 | 171 | ||
194 | - // Destroy old chart if it exists to avoid ghost charts issue | 172 | + function createChart (type, scope, elem) { |
195 | - // https://github.com/jtblin/angular-chart.js/issues/187 | 173 | + var options = getChartOptions(type, scope); |
196 | - destroyChart(chart, scope); | 174 | + if (! hasData(scope) || ! canDisplay(type, scope, elem, options)) return; |
197 | - chart = new ChartJs.Chart(ctx)[type](data, options); | ||
198 | - scope.$emit('create', chart); | ||
199 | 175 | ||
200 | - // Bind events | 176 | + var cvs = elem[0]; |
201 | - cvs.onclick = scope.click ? getEventHandler(scope, chart, 'click', false) : angular.noop; | 177 | + var ctx = cvs.getContext('2d'); |
202 | - cvs.onmousemove = scope.hover ? getEventHandler(scope, chart, 'hover', true) : angular.noop; | ||
203 | 178 | ||
204 | - if (scope.legend && scope.legend !== 'false') setLegend(elem, chart); | 179 | + scope.chartGetColor = getChartColorFn(scope); |
205 | - } | 180 | + var data = getChartData(type, scope); |
206 | 181 | ||
207 | - function deprecated (attr) { | 182 | + // Destroy old chart if it exists to avoid ghost charts issue |
208 | - if (typeof console !== 'undefined' && ChartJs.getOptions().env !== 'test') { | 183 | + // https://github.com/jtblin/angular-chart.js/issues/187 |
209 | - var warn = typeof console.warn === 'function' ? console.warn : console.log; | 184 | + destroyChart(scope); |
210 | - if (!! scope[attr]) { | 185 | + |
211 | - warn.call(console, '"%s" is deprecated and will be removed in a future version. ' + | 186 | + scope.chart = new ChartJs.Chart(ctx, { |
212 | - 'Please use "chart-%s" instead.', attr, attr); | 187 | + type: type, |
213 | - } | 188 | + data: data, |
214 | - } | 189 | + options: options |
215 | - } | 190 | + }); |
191 | + scope.$emit('chart-create', scope.chart); | ||
192 | + bindEvents(cvs, scope); | ||
216 | } | 193 | } |
217 | - }; | ||
218 | - }; | ||
219 | 194 | ||
220 | function canUpdateChart (newVal, oldVal) { | 195 | function canUpdateChart (newVal, oldVal) { |
221 | if (newVal && oldVal && newVal.length && oldVal.length) { | 196 | if (newVal && oldVal && newVal.length && oldVal.length) { |
... | @@ -231,56 +206,54 @@ | ... | @@ -231,56 +206,54 @@ |
231 | return carry + val; | 206 | return carry + val; |
232 | } | 207 | } |
233 | 208 | ||
234 | - function getEventHandler (scope, chart, action, triggerOnlyOnChange) { | 209 | + function getEventHandler (scope, action, triggerOnlyOnChange) { |
235 | var lastState = null; | 210 | var lastState = null; |
236 | return function (evt) { | 211 | return function (evt) { |
237 | - var atEvent = chart.getPointsAtEvent || chart.getBarsAtEvent || chart.getSegmentsAtEvent; | 212 | + var atEvent = scope.chart.getElementsAtEvent || scope.chart.getPointsAtEvent; |
238 | if (atEvent) { | 213 | if (atEvent) { |
239 | - var activePoints = atEvent.call(chart, evt); | 214 | + var activePoints = atEvent.call(scope.chart, evt); |
240 | if (triggerOnlyOnChange === false || angular.equals(lastState, activePoints) === false) { | 215 | if (triggerOnlyOnChange === false || angular.equals(lastState, activePoints) === false) { |
241 | lastState = activePoints; | 216 | lastState = activePoints; |
242 | scope[action](activePoints, evt); | 217 | scope[action](activePoints, evt); |
243 | - scope.$apply(); | ||
244 | } | 218 | } |
245 | } | 219 | } |
246 | }; | 220 | }; |
247 | } | 221 | } |
248 | 222 | ||
249 | - function getColours (type, scope) { | 223 | + function getColors (type, scope) { |
250 | - var notEnoughColours = false; | 224 | + var colors = angular.copy(scope.chartColors || |
251 | - var colours = angular.copy(scope.colours || | 225 | + ChartJs.getOptions(type).chartColors || |
252 | - ChartJs.getOptions(type).colours || | 226 | + Chart.defaults.global.colors |
253 | - Chart.defaults.global.colours | ||
254 | ); | 227 | ); |
255 | - while (colours.length < scope.data.length) { | 228 | + var notEnoughColors = colors.length < scope.chartData.length; |
256 | - colours.push(scope.getColour()); | 229 | + while (colors.length < scope.chartData.length) { |
257 | - notEnoughColours = true; | 230 | + colors.push(scope.chartGetColor()); |
258 | } | 231 | } |
259 | - // mutate colours in this case as we don't want | 232 | + // mutate colors in this case as we don't want |
260 | - // the colours to change on each refresh | 233 | + // the colors to change on each refresh |
261 | - if (notEnoughColours) scope.colours = colours; | 234 | + if (notEnoughColors) scope.chartColors = colors; |
262 | - return colours.map(convertColour); | 235 | + return colors.map(convertColor); |
263 | } | 236 | } |
264 | 237 | ||
265 | - function convertColour (colour) { | 238 | + function convertColor (color) { |
266 | - if (typeof colour === 'object' && colour !== null) return colour; | 239 | + if (typeof color === 'object' && color !== null) return color; |
267 | - if (typeof colour === 'string' && colour[0] === '#') return getColour(hexToRgb(colour.substr(1))); | 240 | + if (typeof color === 'string' && color[0] === '#') return getColor(hexToRgb(color.substr(1))); |
268 | - return getRandomColour(); | 241 | + return getRandomColor(); |
269 | } | 242 | } |
270 | 243 | ||
271 | - function getRandomColour () { | 244 | + function getRandomColor () { |
272 | - var colour = [getRandomInt(0, 255), getRandomInt(0, 255), getRandomInt(0, 255)]; | 245 | + var color = [getRandomInt(0, 255), getRandomInt(0, 255), getRandomInt(0, 255)]; |
273 | - return getColour(colour); | 246 | + return getColor(color); |
274 | } | 247 | } |
275 | 248 | ||
276 | - function getColour (colour) { | 249 | + function getColor (color) { |
277 | return { | 250 | return { |
278 | - fillColor: rgba(colour, 0.2), | 251 | + backgroundColor: rgba(color, 0.2), |
279 | - strokeColor: rgba(colour, 1), | 252 | + pointBackgroundColor: rgba(color, 1), |
280 | - pointColor: rgba(colour, 1), | 253 | + pointHoverBackgroundColor: rgba(color, 0.8), |
281 | - pointStrokeColor: '#fff', | 254 | + borderColor: rgba(color, 1), |
282 | - pointHighlightFill: '#fff', | 255 | + pointBorderColor: '#fff', |
283 | - pointHighlightStroke: rgba(colour, 0.8) | 256 | + pointHoverBorderColor: rgba(color, 1) |
284 | }; | 257 | }; |
285 | } | 258 | } |
286 | 259 | ||
... | @@ -288,13 +261,9 @@ | ... | @@ -288,13 +261,9 @@ |
288 | return Math.floor(Math.random() * (max - min + 1)) + min; | 261 | return Math.floor(Math.random() * (max - min + 1)) + min; |
289 | } | 262 | } |
290 | 263 | ||
291 | - function rgba (colour, alpha) { | 264 | + function rgba (color, alpha) { |
292 | - if (usingExcanvas) { | ||
293 | // rgba not supported by IE8 | 265 | // rgba not supported by IE8 |
294 | - return 'rgb(' + colour.join(',') + ')'; | 266 | + return useExcanvas ? 'rgb(' + color.join(',') + ')' : 'rgba(' + color.concat(alpha).join(',') + ')'; |
295 | - } else { | ||
296 | - return 'rgba(' + colour.concat(alpha).join(',') + ')'; | ||
297 | - } | ||
298 | } | 267 | } |
299 | 268 | ||
300 | // Credit: http://stackoverflow.com/a/11508164/1190235 | 269 | // Credit: http://stackoverflow.com/a/11508164/1190235 |
... | @@ -307,52 +276,76 @@ | ... | @@ -307,52 +276,76 @@ |
307 | return [r, g, b]; | 276 | return [r, g, b]; |
308 | } | 277 | } |
309 | 278 | ||
310 | - function getDataSets (labels, data, series, colours) { | 279 | + function hasData (scope) { |
280 | + return scope.chartData && scope.chartData.length; | ||
281 | + } | ||
282 | + | ||
283 | + function getChartColorFn (scope) { | ||
284 | + return typeof scope.chartGetColor === 'function' ? scope.chartGetColor : getRandomColor; | ||
285 | + } | ||
286 | + | ||
287 | + function getChartData (type, scope) { | ||
288 | + var colors = getColors(type, scope); | ||
289 | + return Array.isArray(scope.chartData[0]) ? | ||
290 | + getDataSets(scope.chartLabels, scope.chartData, scope.chartSeries || [], colors, scope.chartDatasetOverride) : | ||
291 | + getData(scope.chartLabels, scope.chartData, colors, scope.chartDatasetOverride); | ||
292 | + } | ||
293 | + | ||
294 | + function getDataSets (labels, data, series, colors, datasetOverride) { | ||
311 | return { | 295 | return { |
312 | labels: labels, | 296 | labels: labels, |
313 | datasets: data.map(function (item, i) { | 297 | datasets: data.map(function (item, i) { |
314 | - return angular.extend({}, colours[i], { | 298 | + var dataset = angular.extend({}, colors[i], { |
315 | label: series[i], | 299 | label: series[i], |
316 | data: item | 300 | data: item |
317 | }); | 301 | }); |
302 | + if (datasetOverride && datasetOverride.length >= i) { | ||
303 | + angular.merge(dataset, datasetOverride[i]); | ||
304 | + } | ||
305 | + return dataset; | ||
318 | }) | 306 | }) |
319 | }; | 307 | }; |
320 | } | 308 | } |
321 | 309 | ||
322 | - function getData (labels, data, colours) { | 310 | + function getData (labels, data, colors, datasetOverride) { |
323 | - return labels.map(function (label, i) { | 311 | + var dataset = { |
324 | - return angular.extend({}, colours[i], { | 312 | + labels: labels, |
325 | - label: label, | 313 | + datasets: [{ |
326 | - value: data[i], | 314 | + data: data, |
327 | - color: colours[i].strokeColor, | 315 | + backgroundColor: colors.map(function (color) { |
328 | - highlight: colours[i].pointHighlightStroke | 316 | + return color.pointBackgroundColor; |
329 | - }); | 317 | + }), |
330 | - }); | 318 | + hoverBackgroundColor: colors.map(function (color) { |
319 | + return color.backgroundColor; | ||
320 | + }) | ||
321 | + }] | ||
322 | + }; | ||
323 | + if (datasetOverride) { | ||
324 | + angular.merge(dataset.datasets[0], datasetOverride); | ||
325 | + } | ||
326 | + return dataset; | ||
331 | } | 327 | } |
332 | 328 | ||
333 | - function setLegend (elem, chart) { | 329 | + function getChartOptions (type, scope) { |
334 | - var $parent = elem.parent(), | 330 | + return angular.extend({}, ChartJs.getOptions(type), scope.chartOptions); |
335 | - $oldLegend = $parent.find('chart-legend'), | ||
336 | - legend = '<chart-legend>' + chart.generateLegend() + '</chart-legend>'; | ||
337 | - if ($oldLegend.length) $oldLegend.replaceWith(legend); | ||
338 | - else $parent.append(legend); | ||
339 | } | 331 | } |
340 | 332 | ||
341 | - function updateChart (chart, values, scope, elem) { | 333 | + function bindEvents (cvs, scope) { |
342 | - if (Array.isArray(scope.data[0])) { | 334 | + cvs.onclick = scope.chartClick ? getEventHandler(scope, 'chartClick', false) : angular.noop; |
343 | - chart.datasets.forEach(function (dataset, i) { | 335 | + cvs.onmousemove = scope.chartHover ? getEventHandler(scope, 'chartHover', true) : angular.noop; |
344 | - (dataset.points || dataset.bars).forEach(function (dataItem, j) { | 336 | + } |
345 | - dataItem.value = values[i][j]; | 337 | + |
346 | - }); | 338 | + function updateChart (values, scope) { |
339 | + if (Array.isArray(scope.chartData[0])) { | ||
340 | + scope.chart.data.datasets.forEach(function (dataset, i) { | ||
341 | + dataset.data = values[i]; | ||
347 | }); | 342 | }); |
348 | } else { | 343 | } else { |
349 | - chart.segments.forEach(function (segment, i) { | 344 | + scope.chart.data.datasets[0].data = values; |
350 | - segment.value = values[i]; | ||
351 | - }); | ||
352 | } | 345 | } |
353 | - chart.update(); | 346 | + |
354 | - scope.$emit('update', chart); | 347 | + scope.chart.update(); |
355 | - if (scope.legend && scope.legend !== 'false') setLegend(elem, chart); | 348 | + scope.$emit('chart-update', scope.chart); |
356 | } | 349 | } |
357 | 350 | ||
358 | function isEmpty (value) { | 351 | function isEmpty (value) { |
... | @@ -361,15 +354,21 @@ | ... | @@ -361,15 +354,21 @@ |
361 | (typeof value === 'object' && ! Object.keys(value).length); | 354 | (typeof value === 'object' && ! Object.keys(value).length); |
362 | } | 355 | } |
363 | 356 | ||
364 | - function isResponsive (type, scope) { | 357 | + function canDisplay (type, scope, elem, options) { |
365 | - var options = angular.extend({}, Chart.defaults.global, ChartJs.getOptions(type), scope.options); | 358 | + // TODO: check parent? |
366 | - return options.responsive; | 359 | + if (options.responsive && elem[0].clientHeight === 0) { |
360 | + $timeout(function () { | ||
361 | + createChart(type, scope, elem); | ||
362 | + }, 50, false); | ||
363 | + return false; | ||
364 | + } | ||
365 | + return true; | ||
367 | } | 366 | } |
368 | 367 | ||
369 | - function destroyChart(chart, scope) { | 368 | + function destroyChart(scope) { |
370 | - if(! chart) return; | 369 | + if(! scope.chart) return; |
371 | - chart.destroy(); | 370 | + scope.chart.destroy(); |
372 | - scope.$emit('destroy', chart); | 371 | + scope.$emit('chart-destroy', scope.chart); |
373 | } | 372 | } |
374 | } | 373 | } |
375 | })); | 374 | })); | ... | ... |
1 | -.bar-legend,.chart-legend,.doughnut-legend,.line-legend,.pie-legend,.polararea-legend,.radar-legend{list-style-type:none;margin-top:5px;text-align:center;-webkit-padding-start:0;-moz-padding-start:0;padding-left:0}.bar-legend li,.chart-legend li,.doughnut-legend li,.line-legend li,.pie-legend li,.polararea-legend li,.radar-legend li{display:inline-block;white-space:nowrap;position:relative;margin-bottom:4px;border-radius:5px;padding:2px 8px 2px 28px;font-size:smaller;cursor:default}.bar-legend-icon,.chart-legend-icon,.doughnut-legend-icon,.line-legend-icon,.pie-legend-icon,.polararea-legend-icon,.radar-legend-icon{display:block;position:absolute;left:0;top:0;width:20px;height:20px;border-radius:5px} | ||
2 | -/*# sourceMappingURL=angular-chart.min.css.map */ |
1 | -!function(t){"use strict";"object"==typeof exports?module.exports=t("undefined"!=typeof angular?angular:require("angular"),"undefined"!=typeof Chart?Chart:require("chart.js")):"function"==typeof define&&define.amd?define(["angular","chart"],t):t(angular,Chart)}(function(t,e){"use strict";function n(){var n={},r={Chart:e,getOptions:function(e){var r=e&&n[e]||{};return t.extend({},n,r)}};this.setOptions=function(e,r){return r?void(n[e]=t.extend(n[e]||{},r)):(r=e,void(n=t.extend(n,r)))},this.$get=function(){return r}}function r(n,r){function o(t,e){return t&&e&&t.length&&e.length?Array.isArray(t[0])?t.length===e.length&&t.every(function(t,n){return t.length===e[n].length}):e.reduce(i,0)>0?t.length===e.length:!1:!1}function i(t,e){return t+e}function c(e,n,r,a){var o=null;return function(i){var c=n.getPointsAtEvent||n.getBarsAtEvent||n.getSegmentsAtEvent;if(c){var l=c.call(n,i);a!==!1&&t.equals(o,l)!==!1||(o=l,e[r](l,i),e.$apply())}}}function l(r,a){for(var o=!1,i=t.copy(a.colours||n.getOptions(r).colours||e.defaults.global.colours);i.length<a.data.length;)i.push(a.getColour()),o=!0;return o&&(a.colours=i),i.map(u)}function u(t){return"object"==typeof t&&null!==t?t:"string"==typeof t&&"#"===t[0]?f(g(t.substr(1))):s()}function s(){var t=[h(0,255),h(0,255),h(0,255)];return f(t)}function f(t){return{fillColor:d(t,.2),strokeColor:d(t,1),pointColor:d(t,1),pointStrokeColor:"#fff",pointHighlightFill:"#fff",pointHighlightStroke:d(t,.8)}}function h(t,e){return Math.floor(Math.random()*(e-t+1))+t}function d(t,e){return a?"rgb("+t.join(",")+")":"rgba("+t.concat(e).join(",")+")"}function g(t){var e=parseInt(t,16),n=e>>16&255,r=e>>8&255,a=255&e;return[n,r,a]}function p(e,n,r,a){return{labels:e,datasets:n.map(function(e,n){return t.extend({},a[n],{label:r[n],data:e})})}}function v(e,n,r){return e.map(function(e,a){return t.extend({},r[a],{label:e,value:n[a],color:r[a].strokeColor,highlight:r[a].pointHighlightStroke})})}function y(t,e){var n=t.parent(),r=n.find("chart-legend"),a="<chart-legend>"+e.generateLegend()+"</chart-legend>";r.length?r.replaceWith(a):n.append(a)}function C(t,e,n,r){Array.isArray(n.data[0])?t.datasets.forEach(function(t,n){(t.points||t.bars).forEach(function(t,r){t.value=e[n][r]})}):t.segments.forEach(function(t,n){t.value=e[n]}),t.update(),n.$emit("update",t),n.legend&&"false"!==n.legend&&y(r,t)}function b(t){return!t||Array.isArray(t)&&!t.length||"object"==typeof t&&!Object.keys(t).length}function m(r,a){var o=t.extend({},e.defaults.global,n.getOptions(r),a.options);return o.responsive}function w(t,e){t&&(t.destroy(),e.$emit("destroy",t))}return function(e){return{restrict:"CA",scope:{data:"=?",labels:"=?",options:"=?",series:"=?",colours:"=?",getColour:"=?",chartType:"=",legend:"@",click:"=?",hover:"=?",chartData:"=?",chartLabels:"=?",chartOptions:"=?",chartSeries:"=?",chartColours:"=?",chartLegend:"@",chartClick:"=?",chartHover:"=?"},link:function(i,u){function f(t,e){i.$watch(t,function(t){"undefined"!=typeof t&&(i[e]=t)})}function h(n,r){if(!b(n)&&!t.equals(n,r)){var a=e||i.chartType;a&&d(a)}}function d(e){if(m(e,i)&&0===u[0].clientHeight&&0===k.clientHeight)return r(function(){d(e)},50,!1);if(i.data&&i.data.length){i.getColour="function"==typeof i.getColour?i.getColour:s;var a=l(e,i),o=u[0],f=o.getContext("2d"),h=Array.isArray(i.data[0])?p(i.labels,i.data,i.series||[],a):v(i.labels,i.data,a),g=t.extend({},n.getOptions(e),i.options);w(A,i),A=new n.Chart(f)[e](h,g),i.$emit("create",A),o.onclick=i.click?c(i,A,"click",!1):t.noop,o.onmousemove=i.hover?c(i,A,"hover",!0):t.noop,i.legend&&"false"!==i.legend&&y(u,A)}}function g(t){if("undefined"!=typeof console&&"test"!==n.getOptions().env){var e="function"==typeof console.warn?console.warn:console.log;i[t]&&e.call(console,'"%s" is deprecated and will be removed in a future version. Please use "chart-%s" instead.',t,t)}}var A,k=document.createElement("div");k.className="chart-container",u.replaceWith(k),k.appendChild(u[0]),a&&window.G_vmlCanvasManager.initElement(u[0]),["data","labels","options","series","colours","legend","click","hover"].forEach(g),f("chartData","data"),f("chartLabels","labels"),f("chartOptions","options"),f("chartSeries","series"),f("chartColours","colours"),f("chartLegend","legend"),f("chartClick","click"),f("chartHover","hover"),i.$watch("data",function(t,n){if(!t||!t.length||Array.isArray(t[0])&&!t[0].length)return void w(A,i);var r=e||i.chartType;if(r)return A&&o(t,n)?C(A,t,i,u):void d(r)},!0),i.$watch("series",h,!0),i.$watch("labels",h,!0),i.$watch("options",h,!0),i.$watch("colours",h,!0),i.$watch("chartType",function(e,n){b(e)||t.equals(e,n)||d(e)}),i.$on("$destroy",function(){w(A,i)})}}}}e.defaults.global.responsive=!0,e.defaults.global.multiTooltipTemplate="<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>",e.defaults.global.colours=["#97BBCD","#DCDCDC","#F7464A","#46BFBD","#FDB45C","#949FB1","#4D5360"];var a="object"==typeof window.G_vmlCanvasManager&&null!==window.G_vmlCanvasManager&&"function"==typeof window.G_vmlCanvasManager.initElement;return a&&(e.defaults.global.animation=!1),t.module("chart.js",[]).provider("ChartJs",n).factory("ChartJsFactory",["ChartJs","$timeout",r]).directive("chartBase",["ChartJsFactory",function(t){return new t}]).directive("chartLine",["ChartJsFactory",function(t){return new t("Line")}]).directive("chartBar",["ChartJsFactory",function(t){return new t("Bar")}]).directive("chartRadar",["ChartJsFactory",function(t){return new t("Radar")}]).directive("chartDoughnut",["ChartJsFactory",function(t){return new t("Doughnut")}]).directive("chartPie",["ChartJsFactory",function(t){return new t("Pie")}]).directive("chartPolarArea",["ChartJsFactory",function(t){return new t("PolarArea")}])}); | 1 | +/*! |
2 | + * angular-chart.js - An angular.js wrapper for Chart.js | ||
3 | + * http://jtblin.github.io/angular-chart.js/ | ||
4 | + * Version: 1.0.0 | ||
5 | + * | ||
6 | + * Copyright 2016 Jerome Touffe-Blin | ||
7 | + * Released under the BSD-2-Clause license | ||
8 | + * https://github.com/jtblin/angular-chart.js/blob/master/LICENSE | ||
9 | + */ | ||
10 | +!function(t){"use strict";if("object"==typeof exports)module.exports=t("undefined"!=typeof angular?angular:require("angular"),"undefined"!=typeof Chart?Chart:require("chart.js"));else if("function"==typeof define&&define.amd)define(["angular","chart"],t);else{if("undefined"==typeof angular||"undefined"==typeof Chart)throw new Error("Chart.js library needs to included, see http://jtblin.github.io/angular-chart.js/");t(angular,Chart)}}(function(t,r){"use strict";function a(){var a={responsive:!0},e={Chart:r,getOptions:function(r){var e=r&&a[r]||{};return t.extend({},a,e)}};this.setOptions=function(r,e){return e?void(a[r]=t.extend(a[r]||{},e)):(e=r,void(a=t.extend(a,e)))},this.$get=function(){return e}}function e(a,e){function o(t,r,e){var n=w(t,r);if(p(r)&&$(t,r,e,n)){var o=e[0],c=o.getContext("2d");r.chartGetColor=C(r);var i=y(t,r);F(r),r.chart=new a.Chart(c,{type:t,data:i,options:n}),r.$emit("chart-create",r.chart),D(o,r)}}function c(t,r){return t&&r&&t.length&&r.length?Array.isArray(t[0])?t.length===r.length&&t.every(function(t,a){return t.length===r[a].length}):r.reduce(i,0)>0?t.length===r.length:!1:!1}function i(t,r){return t+r}function u(r,a,e){var n=null;return function(o){var c=r.chart.getElementsAtEvent||r.chart.getPointsAtEvent;if(c){var i=c.call(r.chart,o);e!==!1&&t.equals(n,i)!==!1||(n=i,r[a](i,o))}}}function h(e,n){for(var o=t.copy(n.chartColors||a.getOptions(e).chartColors||r.defaults.global.colors),c=o.length<n.chartData.length;o.length<n.chartData.length;)o.push(n.chartGetColor());return c&&(n.chartColors=o),o.map(l)}function l(t){return"object"==typeof t&&null!==t?t:"string"==typeof t&&"#"===t[0]?f(v(t.substr(1))):s()}function s(){var t=[d(0,255),d(0,255),d(0,255)];return f(t)}function f(t){return{backgroundColor:g(t,.2),pointBackgroundColor:g(t,1),pointHoverBackgroundColor:g(t,.8),borderColor:g(t,1),pointBorderColor:"#fff",pointHoverBorderColor:g(t,1)}}function d(t,r){return Math.floor(Math.random()*(r-t+1))+t}function g(t,r){return n?"rgb("+t.join(",")+")":"rgba("+t.concat(r).join(",")+")"}function v(t){var r=parseInt(t,16),a=r>>16&255,e=r>>8&255,n=255&r;return[a,e,n]}function p(t){return t.chartData&&t.chartData.length}function C(t){return"function"==typeof t.chartGetColor?t.chartGetColor:s}function y(t,r){var a=h(t,r);return Array.isArray(r.chartData[0])?b(r.chartLabels,r.chartData,r.chartSeries||[],a,r.chartDatasetOverride):m(r.chartLabels,r.chartData,a,r.chartDatasetOverride)}function b(r,a,e,n,o){return{labels:r,datasets:a.map(function(r,a){var c=t.extend({},n[a],{label:e[a],data:r});return o&&o.length>=a&&t.merge(c,o[a]),c})}}function m(r,a,e,n){var o={labels:r,datasets:[{data:a,backgroundColor:e.map(function(t){return t.pointBackgroundColor}),hoverBackgroundColor:e.map(function(t){return t.backgroundColor})}]};return n&&t.merge(o.datasets[0],n),o}function w(r,e){return t.extend({},a.getOptions(r),e.chartOptions)}function D(r,a){r.onclick=a.chartClick?u(a,"chartClick",!1):t.noop,r.onmousemove=a.chartHover?u(a,"chartHover",!0):t.noop}function B(t,r){Array.isArray(r.chartData[0])?r.chart.data.datasets.forEach(function(r,a){r.data=t[a]}):r.chart.data.datasets[0].data=t,r.chart.update(),r.$emit("chart-update",r.chart)}function A(t){return!t||Array.isArray(t)&&!t.length||"object"==typeof t&&!Object.keys(t).length}function $(t,r,a,n){return n.responsive&&0===a[0].clientHeight?(e(function(){o(t,r,a)},50,!1),!1):!0}function F(t){t.chart&&(t.chart.destroy(),t.$emit("chart-destroy",t.chart))}return function(r){return{restrict:"CA",scope:{chartGetColor:"=?",chartType:"=",chartData:"=?",chartLabels:"=?",chartOptions:"=?",chartSeries:"=?",chartColors:"=?",chartClick:"=?",chartHover:"=?",chartDatasetOverride:"=?"},link:function(a,e){function i(t,n){if(!t||!t.length||Array.isArray(t[0])&&!t[0].length)return void F(a);var i=r||a.chartType;if(i)return a.chart&&c(t,n)?B(t,a):void o(i,a,e)}function u(n,c){if(!A(n)&&!t.equals(n,c)){var i=r||a.chartType;i&&o(i,a,e)}}function h(r,n){A(r)||t.equals(r,n)||o(r,a,e)}n&&window.G_vmlCanvasManager.initElement(e[0]),a.$watch("chartData",i,!0),a.$watch("chartSeries",u,!0),a.$watch("chartLabels",u,!0),a.$watch("chartOptions",u,!0),a.$watch("chartColors",u,!0),a.$watch("chartDatasetOverride",u,!0),a.$watch("chartType",h,!1),a.$on("$destroy",function(){F(a)}),a.$on("$resize",function(){a.chart&&a.chart.resize()})}}}}r.defaults.global.multiTooltipTemplate="<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>",r.defaults.global.tooltips.mode="label",r.defaults.global.elements.line.borderWidth=2,r.defaults.global.elements.rectangle.borderWidth=2,r.defaults.global.legend.display=!1,r.defaults.global.colors=["#97BBCD","#DCDCDC","#F7464A","#46BFBD","#FDB45C","#949FB1","#4D5360"];var n="object"==typeof window.G_vmlCanvasManager&&null!==window.G_vmlCanvasManager&&"function"==typeof window.G_vmlCanvasManager.initElement;return n&&(r.defaults.global.animation=!1),t.module("chart.js",[]).provider("ChartJs",a).factory("ChartJsFactory",["ChartJs","$timeout",e]).directive("chartBase",["ChartJsFactory",function(t){return new t}]).directive("chartLine",["ChartJsFactory",function(t){return new t("line")}]).directive("chartBar",["ChartJsFactory",function(t){return new t("bar")}]).directive("chartHorizontalBar",["ChartJsFactory",function(t){return new t("horizontalBar")}]).directive("chartRadar",["ChartJsFactory",function(t){return new t("radar")}]).directive("chartDoughnut",["ChartJsFactory",function(t){return new t("doughnut")}]).directive("chartPie",["ChartJsFactory",function(t){return new t("pie")}]).directive("chartPolarArea",["ChartJsFactory",function(t){return new t("polarArea")}]).directive("chartBubble",["ChartJsFactory",function(t){return new t("bubble")}]).name}); | ||
2 | //# sourceMappingURL=angular-chart.min.js.map | 11 | //# sourceMappingURL=angular-chart.min.js.map | ... | ... |
1 | +{"version":3,"sources":["angular-chart.js"],"names":["factory","exports","module","angular","require","Chart","define","amd","Error","ChartJsProvider","options","responsive","ChartJs","getOptions","type","typeOptions","extend","this","setOptions","customOptions","$get","ChartJsFactory","$timeout","createChart","scope","elem","getChartOptions","hasData","canDisplay","cvs","ctx","getContext","chartGetColor","getChartColorFn","data","getChartData","destroyChart","chart","$emit","bindEvents","canUpdateChart","newVal","oldVal","length","Array","isArray","every","element","index","reduce","sum","carry","val","getEventHandler","action","triggerOnlyOnChange","lastState","evt","atEvent","getElementsAtEvent","getPointsAtEvent","activePoints","call","equals","getColors","colors","copy","chartColors","defaults","global","notEnoughColors","chartData","push","map","convertColor","color","getColor","hexToRgb","substr","getRandomColor","getRandomInt","backgroundColor","rgba","pointBackgroundColor","pointHoverBackgroundColor","borderColor","pointBorderColor","pointHoverBorderColor","min","max","Math","floor","random","alpha","useExcanvas","join","concat","hex","bigint","parseInt","r","g","b","getDataSets","chartLabels","chartSeries","chartDatasetOverride","getData","labels","series","datasetOverride","datasets","item","i","dataset","label","merge","hoverBackgroundColor","chartOptions","onclick","chartClick","noop","onmousemove","chartHover","updateChart","values","forEach","update","isEmpty","value","Object","keys","clientHeight","destroy","restrict","chartType","link","watchData","watchOther","watchType","window","G_vmlCanvasManager","initElement","$watch","$on","resize","multiTooltipTemplate","tooltips","mode","elements","line","borderWidth","rectangle","legend","display","animation","provider","directive","name"],"mappings":";;;;;;;;;CAAA,SAAAA,GACA,YACA,IAAA,gBAAAC,SAEAC,OAAAD,QAAAD,EACA,mBAAAG,SAAAA,QAAAC,QAAA,WACA,mBAAAC,OAAAA,MAAAD,QAAA,iBACA,IAAA,kBAAAE,SAAAA,OAAAC,IAEAD,QAAA,UAAA,SAAAN,OACA,CAEA,GAAA,mBAAAG,UAAA,mBAAAE,OACA,KAAA,IAAAG,OAAA,oFACAR,GAAAG,QAAAE,SAEA,SAAAF,EAAAE,GACA,YA8CA,SAAAI,KACA,GAAAC,IAAAC,YAAA,GACAC,GACAP,MAAAA,EACAQ,WAAA,SAAAC,GACA,GAAAC,GAAAD,GAAAJ,EAAAI,MACA,OAAAX,GAAAa,UAAAN,EAAAK,IAOAE,MAAAC,WAAA,SAAAJ,EAAAK,GAEA,MAAAA,QAMAT,EAAAI,GAAAX,EAAAa,OAAAN,EAAAI,OAAAK,KALAA,EAAAL,OACAJ,EAAAP,EAAAa,OAAAN,EAAAS,MAOAF,KAAAG,KAAA,WACA,MAAAR,IAIA,QAAAS,GAAAT,EAAAU,GAsEA,QAAAC,GAAAT,EAAAU,EAAAC,GACA,GAAAf,GAAAgB,EAAAZ,EAAAU,EACA,IAAAG,EAAAH,IAAAI,EAAAd,EAAAU,EAAAC,EAAAf,GAAA,CAEA,GAAAmB,GAAAJ,EAAA,GACAK,EAAAD,EAAAE,WAAA,KAEAP,GAAAQ,cAAAC,EAAAT,EACA,IAAAU,GAAAC,EAAArB,EAAAU,EAIAY,GAAAZ,GAEAA,EAAAa,MAAA,GAAAzB,GAAAP,MAAAyB,GACAhB,KAAAA,EACAoB,KAAAA,EACAxB,QAAAA,IAEAc,EAAAc,MAAA,eAAAd,EAAAa,OACAE,EAAAV,EAAAL,IA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AA,EACAlJ,EAAA+D,SAAAC,OAAAoF,OAAAC,SAAA,EACArJ,EAAA+D,SAAAC,OAAAJ,QACA,UACA,UACA,UACA,UACA,UACA,UACA,UAGA,IAAA6B,GAAA,gBAAA8C,QAAAC,oBACA,OAAAD,OAAAC,oBACA,kBAAAD,QAAAC,mBAAAC,WAIA,OAFAhD,KAAAzF,EAAA+D,SAAAC,OAAAsF,WAAA,GAEAxJ,EAAAD,OAAA,eACA0J,SAAA,UAAAnJ,GACAT,QAAA,kBAAA,UAAA,WAAAqB,IACAwI,UAAA,aAAA,iBAAA,SAAAxI,GAAA,MAAA,IAAAA,MACAwI,UAAA,aAAA,iBAAA,SAAAxI,GAAA,MAAA,IAAAA,GAAA,WACAwI,UAAA,YAAA,iBAAA,SAAAxI,GAAA,MAAA,IAAAA,GAAA,UACAwI,UAAA,sBAAA,iBAAA,SAAAxI,GAAA,MAAA,IAAAA,GAAA,oBACAwI,UAAA,cAAA,iBAAA,SAAAxI,GAAA,MAAA,IAAAA,GAAA,YACAwI,UAAA,iBAAA,iBAAA,SAAAxI,GAAA,MAAA,IAAAA,GAAA,eACAwI,UAAA,YAAA,iBAAA,SAAAxI,GAAA,MAAA,IAAAA,GAAA,UACAwI,UAAA,kBAAA,iBAAA,SAAAxI,GAAA,MAAA,IAAAA,GAAA,gBACAwI,UAAA,eAAA,iBAAA,SAAAxI,GAAA,MAAA,IAAAA,GAAA,aACAyI","file":"angular-chart.min.js","sourcesContent":["(function (factory) {\n 'use strict';\n if (typeof exports === 'object') {\n // Node/CommonJS\n module.exports = factory(\n typeof angular !== 'undefined' ? angular : require('angular'),\n typeof Chart !== 'undefined' ? Chart : require('chart.js'));\n } else if (typeof define === 'function' && define.amd) {\n // AMD. Register as an anonymous module.\n define(['angular', 'chart'], factory);\n } else {\n // Browser globals\n if (typeof angular === 'undefined' || typeof Chart === 'undefined')\n throw new Error('Chart.js library needs to included, see http://jtblin.github.io/angular-chart.js/');\n factory(angular, Chart);\n }\n}(function (angular, Chart) {\n 'use strict';\n\n Chart.defaults.global.multiTooltipTemplate = '<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>';\n Chart.defaults.global.tooltips.mode = 'label';\n Chart.defaults.global.elements.line.borderWidth = 2;\n Chart.defaults.global.elements.rectangle.borderWidth = 2;\n Chart.defaults.global.legend.display = false;\n Chart.defaults.global.colors = [\n '#97BBCD', // blue\n '#DCDCDC', // light grey\n '#F7464A', // red\n '#46BFBD', // green\n '#FDB45C', // yellow\n '#949FB1', // grey\n '#4D5360' // dark grey\n ];\n\n var useExcanvas = typeof window.G_vmlCanvasManager === 'object' &&\n window.G_vmlCanvasManager !== null &&\n typeof window.G_vmlCanvasManager.initElement === 'function';\n\n if (useExcanvas) Chart.defaults.global.animation = false;\n\n return angular.module('chart.js', [])\n .provider('ChartJs', ChartJsProvider)\n .factory('ChartJsFactory', ['ChartJs', '$timeout', ChartJsFactory])\n .directive('chartBase', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory(); }])\n .directive('chartLine', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('line'); }])\n .directive('chartBar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('bar'); }])\n .directive('chartHorizontalBar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('horizontalBar'); }])\n .directive('chartRadar', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('radar'); }])\n .directive('chartDoughnut', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('doughnut'); }])\n .directive('chartPie', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('pie'); }])\n .directive('chartPolarArea', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('polarArea'); }])\n .directive('chartBubble', ['ChartJsFactory', function (ChartJsFactory) { return new ChartJsFactory('bubble'); }])\n .name;\n\n /**\n * Wrapper for chart.js\n * Allows configuring chart js using the provider\n *\n * angular.module('myModule', ['chart.js']).config(function(ChartJsProvider) {\n * ChartJsProvider.setOptions({ responsive: false });\n * ChartJsProvider.setOptions('Line', { responsive: true });\n * })))\n */\n function ChartJsProvider () {\n var options = { responsive: true };\n var ChartJs = {\n Chart: Chart,\n getOptions: function (type) {\n var typeOptions = type && options[type] || {};\n return angular.extend({}, options, typeOptions);\n }\n };\n\n /**\n * Allow to set global options during configuration\n */\n this.setOptions = function (type, customOptions) {\n // If no type was specified set option for the global object\n if (! customOptions) {\n customOptions = type;\n options = angular.extend(options, customOptions);\n return;\n }\n // Set options for the specific chart\n options[type] = angular.extend(options[type] || {}, customOptions);\n };\n\n this.$get = function () {\n return ChartJs;\n };\n }\n\n function ChartJsFactory (ChartJs, $timeout) {\n return function chart (type) {\n return {\n restrict: 'CA',\n scope: {\n chartGetColor: '=?',\n chartType: '=',\n chartData: '=?',\n chartLabels: '=?',\n chartOptions: '=?',\n chartSeries: '=?',\n chartColors: '=?',\n chartClick: '=?',\n chartHover: '=?',\n chartDatasetOverride: '=?'\n },\n link: function (scope, elem/*, attrs */) {\n if (useExcanvas) window.G_vmlCanvasManager.initElement(elem[0]);\n\n // Order of setting \"watch\" matter\n scope.$watch('chartData', watchData, true);\n scope.$watch('chartSeries', watchOther, true);\n scope.$watch('chartLabels', watchOther, true);\n scope.$watch('chartOptions', watchOther, true);\n scope.$watch('chartColors', watchOther, true);\n scope.$watch('chartDatasetOverride', watchOther, true);\n scope.$watch('chartType', watchType, false);\n\n scope.$on('$destroy', function () {\n destroyChart(scope);\n });\n\n scope.$on('$resize', function () {\n if (scope.chart) scope.chart.resize();\n });\n\n function watchData (newVal, oldVal) {\n if (! newVal || ! newVal.length || (Array.isArray(newVal[0]) && ! newVal[0].length)) {\n destroyChart(scope);\n return;\n }\n var chartType = type || scope.chartType;\n if (! chartType) return;\n\n if (scope.chart && canUpdateChart(newVal, oldVal))\n return updateChart(newVal, scope);\n\n createChart(chartType, scope, elem);\n }\n\n function watchOther (newVal, oldVal) {\n if (isEmpty(newVal)) return;\n if (angular.equals(newVal, oldVal)) return;\n var chartType = type || scope.chartType;\n if (! chartType) return;\n\n // chart.update() doesn't work for series and labels\n // so we have to re-create the chart entirely\n createChart(chartType, scope, elem);\n }\n\n function watchType (newVal, oldVal) {\n if (isEmpty(newVal)) return;\n if (angular.equals(newVal, oldVal)) return;\n createChart(newVal, scope, elem);\n }\n }\n };\n };\n\n function createChart (type, scope, elem) {\n var options = getChartOptions(type, scope);\n if (! hasData(scope) || ! canDisplay(type, scope, elem, options)) return;\n\n var cvs = elem[0];\n var ctx = cvs.getContext('2d');\n\n scope.chartGetColor = getChartColorFn(scope);\n var data = getChartData(type, scope);\n\n // Destroy old chart if it exists to avoid ghost charts issue\n // https://github.com/jtblin/angular-chart.js/issues/187\n destroyChart(scope);\n\n scope.chart = new ChartJs.Chart(ctx, {\n type: type,\n data: data,\n options: options\n });\n scope.$emit('chart-create', scope.chart);\n bindEvents(cvs, scope);\n }\n\n function canUpdateChart (newVal, oldVal) {\n if (newVal && oldVal && newVal.length && oldVal.length) {\n return Array.isArray(newVal[0]) ?\n newVal.length === oldVal.length && newVal.every(function (element, index) {\n return element.length === oldVal[index].length; }) :\n oldVal.reduce(sum, 0) > 0 ? newVal.length === oldVal.length : false;\n }\n return false;\n }\n\n function sum (carry, val) {\n return carry + val;\n }\n\n function getEventHandler (scope, action, triggerOnlyOnChange) {\n var lastState = null;\n return function (evt) {\n var atEvent = scope.chart.getElementsAtEvent || scope.chart.getPointsAtEvent;\n if (atEvent) {\n var activePoints = atEvent.call(scope.chart, evt);\n if (triggerOnlyOnChange === false || angular.equals(lastState, activePoints) === false) {\n lastState = activePoints;\n scope[action](activePoints, evt);\n }\n }\n };\n }\n\n function getColors (type, scope) {\n var colors = angular.copy(scope.chartColors ||\n ChartJs.getOptions(type).chartColors ||\n Chart.defaults.global.colors\n );\n var notEnoughColors = colors.length < scope.chartData.length;\n while (colors.length < scope.chartData.length) {\n colors.push(scope.chartGetColor());\n }\n // mutate colors in this case as we don't want\n // the colors to change on each refresh\n if (notEnoughColors) scope.chartColors = colors;\n return colors.map(convertColor);\n }\n\n function convertColor (color) {\n if (typeof color === 'object' && color !== null) return color;\n if (typeof color === 'string' && color[0] === '#') return getColor(hexToRgb(color.substr(1)));\n return getRandomColor();\n }\n\n function getRandomColor () {\n var color = [getRandomInt(0, 255), getRandomInt(0, 255), getRandomInt(0, 255)];\n return getColor(color);\n }\n\n function getColor (color) {\n return {\n backgroundColor: rgba(color, 0.2),\n pointBackgroundColor: rgba(color, 1),\n pointHoverBackgroundColor: rgba(color, 0.8),\n borderColor: rgba(color, 1),\n pointBorderColor: '#fff',\n pointHoverBorderColor: rgba(color, 1)\n };\n }\n\n function getRandomInt (min, max) {\n return Math.floor(Math.random() * (max - min + 1)) + min;\n }\n\n function rgba (color, alpha) {\n // rgba not supported by IE8\n return useExcanvas ? 'rgb(' + color.join(',') + ')' : 'rgba(' + color.concat(alpha).join(',') + ')';\n }\n\n // Credit: http://stackoverflow.com/a/11508164/1190235\n function hexToRgb (hex) {\n var bigint = parseInt(hex, 16),\n r = (bigint >> 16) & 255,\n g = (bigint >> 8) & 255,\n b = bigint & 255;\n\n return [r, g, b];\n }\n\n function hasData (scope) {\n return scope.chartData && scope.chartData.length;\n }\n\n function getChartColorFn (scope) {\n return typeof scope.chartGetColor === 'function' ? scope.chartGetColor : getRandomColor;\n }\n\n function getChartData (type, scope) {\n var colors = getColors(type, scope);\n return Array.isArray(scope.chartData[0]) ?\n getDataSets(scope.chartLabels, scope.chartData, scope.chartSeries || [], colors, scope.chartDatasetOverride) :\n getData(scope.chartLabels, scope.chartData, colors, scope.chartDatasetOverride);\n }\n\n function getDataSets (labels, data, series, colors, datasetOverride) {\n return {\n labels: labels,\n datasets: data.map(function (item, i) {\n var dataset = angular.extend({}, colors[i], {\n label: series[i],\n data: item\n });\n if (datasetOverride && datasetOverride.length >= i) {\n angular.merge(dataset, datasetOverride[i]);\n }\n return dataset;\n })\n };\n }\n\n function getData (labels, data, colors, datasetOverride) {\n var dataset = {\n labels: labels,\n datasets: [{\n data: data,\n backgroundColor: colors.map(function (color) {\n return color.pointBackgroundColor;\n }),\n hoverBackgroundColor: colors.map(function (color) {\n return color.backgroundColor;\n })\n }]\n };\n if (datasetOverride) {\n angular.merge(dataset.datasets[0], datasetOverride);\n }\n return dataset;\n }\n\n function getChartOptions (type, scope) {\n return angular.extend({}, ChartJs.getOptions(type), scope.chartOptions);\n }\n\n function bindEvents (cvs, scope) {\n cvs.onclick = scope.chartClick ? getEventHandler(scope, 'chartClick', false) : angular.noop;\n cvs.onmousemove = scope.chartHover ? getEventHandler(scope, 'chartHover', true) : angular.noop;\n }\n\n function updateChart (values, scope) {\n if (Array.isArray(scope.chartData[0])) {\n scope.chart.data.datasets.forEach(function (dataset, i) {\n dataset.data = values[i];\n });\n } else {\n scope.chart.data.datasets[0].data = values;\n }\n\n scope.chart.update();\n scope.$emit('chart-update', scope.chart);\n }\n\n function isEmpty (value) {\n return ! value ||\n (Array.isArray(value) && ! value.length) ||\n (typeof value === 'object' && ! Object.keys(value).length);\n }\n\n function canDisplay (type, scope, elem, options) {\n // TODO: check parent?\n if (options.responsive && elem[0].clientHeight === 0) {\n $timeout(function () {\n createChart(type, scope, elem);\n }, 50, false);\n return false;\n }\n return true;\n }\n\n function destroyChart(scope) {\n if(! scope.chart) return;\n scope.chart.destroy();\n scope.$emit('chart-destroy', scope.chart);\n }\n }\n}));\n"],"sourceRoot":"/source/"} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment