{"version":3,"sources":["angular-chart.min.js"],"names":["chart","type","restrict","scope","data","labels","options","series","colours","getColour","chartType","legend","click","link","elem","resetChart","newVal","oldVal","isEmpty","angular","equals","destroy","createChart","container","document","createElement","className","replaceWith","appendChild","window","G_vmlCanvasManager","initElement","$watch","length","Array","isArray","canUpdateChart","updateChart","$on","reduce","sum","carry","val","getRandomColour","getColours","cvs","ctx","getContext","getDataSets","getData","Chart","$emit","onclick","evt","getPointsAtEvent","getBarsAtEvent","getSegmentsAtEvent","activePoints","call","$apply","setLegend","copy","defaults","global","push","map","convertColour","colour","hexToRgb","substr","getRandomInt","fillColor","rgba","strokeColor","pointColor","pointStrokeColor","pointHighlightFill","pointHighlightStroke","min","max","Math","floor","random","alpha","concat","join","hex","bigint","parseInt","r","g","b","datasets","item","i","dataSet","label","value","color","highlight","$parent","parent","$oldLegend","find","generateLegend","append","values","forEach","dataset","points","bars","dataItem","j","segments","segment","update","Object","keys","responsive","multiTooltipTemplate","module","directive"],"mappings":"CAAA,WACE,YAyEA,SAASA,GAAOC,GACd,OACEC,SAAU,KACVC,OACEC,KAAM,IACNC,OAAQ,IACRC,QAAS,IACTC,OAAQ,IACRC,QAAS,KACTC,UAAW,KACXC,UAAW,IACXC,OAAQ,IACRC,MAAO,KAETC,KAAM,SAAUV,EAAOW,GA2CrB,QAASC,GAAYC,EAAQC,GAC3B,IAAIC,EAAQF,KACRG,QAAQC,OAAOJ,EAAQC,GAA3B,CACA,GAAIP,GAAYT,GAAQE,EAAMO,SACxBA,KAIFV,GAAOA,EAAMqB,UAEjBrB,EAAQsB,EAAYZ,EAAWP,EAAOW,KApDxC,GAAId,GAAOuB,EAAYC,SAASC,cAAc,MAC9CF,GAAUG,UAAY,kBACtBZ,EAAKa,YAAYJ,GACjBA,EAAUK,YAAYd,EAAK,IAEc,gBAA9Be,QAAOC,oBAAiE,OAA9BD,OAAOC,oBACL,kBAA1CD,QAAOC,mBAAmBC,aACnCF,OAAOC,mBAAmBC,YAAYjB,EAAK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file":"angular-chart.min.js","sourcesContent":["(function () {\n 'use strict';\n\n Chart.defaults.global.responsive = true;\n Chart.defaults.global.multiTooltipTemplate = '<%if (datasetLabel){%><%=datasetLabel%>: <%}%><%= value %>';\n\n Chart.defaults.global.colours = [\n { // blue\n fillColor: 'rgba(151,187,205,0.2)',\n strokeColor: 'rgba(151,187,205,1)',\n pointColor: 'rgba(151,187,205,1)',\n pointStrokeColor: '#fff',\n pointHighlightFill: '#fff',\n pointHighlightStroke: 'rgba(151,187,205,0.8)'\n },\n { // light grey\n fillColor: 'rgba(220,220,220,0.2)',\n strokeColor: 'rgba(220,220,220,1)',\n pointColor: 'rgba(220,220,220,1)',\n pointStrokeColor: '#fff',\n pointHighlightFill: '#fff',\n pointHighlightStroke: 'rgba(220,220,220,0.8)'\n },\n { // red\n fillColor: 'rgba(247,70,74,0.2)',\n strokeColor: 'rgba(247,70,74,1)',\n pointColor: 'rgba(247,70,74,1)',\n pointStrokeColor: '#fff',\n pointHighlightFill: '#fff',\n pointHighlightStroke: 'rgba(247,70,74,0.8)'\n },\n { // green\n fillColor: 'rgba(70,191,189,0.2)',\n strokeColor: 'rgba(70,191,189,1)',\n pointColor: 'rgba(70,191,189,1)',\n pointStrokeColor: '#fff',\n pointHighlightFill: '#fff',\n pointHighlightStroke: 'rgba(70,191,189,0.8)'\n },\n { // yellow\n fillColor: 'rgba(253,180,92,0.2)',\n strokeColor: 'rgba(253,180,92,1)',\n pointColor: 'rgba(253,180,92,1)',\n pointStrokeColor: '#fff',\n pointHighlightFill: '#fff',\n pointHighlightStroke: 'rgba(253,180,92,0.8)'\n },\n { // grey\n fillColor: 'rgba(148,159,177,0.2)',\n strokeColor: 'rgba(148,159,177,1)',\n pointColor: 'rgba(148,159,177,1)',\n pointStrokeColor: '#fff',\n pointHighlightFill: '#fff',\n pointHighlightStroke: 'rgba(148,159,177,0.8)'\n },\n { // dark grey\n fillColor: 'rgba(77,83,96,0.2)',\n strokeColor: 'rgba(77,83,96,1)',\n pointColor: 'rgba(77,83,96,1)',\n pointStrokeColor: '#fff',\n pointHighlightFill: '#fff',\n pointHighlightStroke: 'rgba(77,83,96,1)'\n }\n ];\n\n angular.module('chart.js', [])\n .directive('chartBase', function () { return chart(); })\n .directive('chartLine', function () { return chart('Line'); })\n .directive('chartBar', function () { return chart('Bar'); })\n .directive('chartRadar', function () { return chart('Radar'); })\n .directive('chartDoughnut', function () { return chart('Doughnut'); })\n .directive('chartPie', function () { return chart('Pie'); })\n .directive('chartPolarArea', function () { return chart('PolarArea'); });\n\n function chart (type) {\n return {\n restrict: 'CA',\n scope: {\n data: '=',\n labels: '=',\n options: '=',\n series: '=',\n colours: '=?',\n getColour: '=?',\n chartType: '=',\n legend: '@',\n click: '='\n },\n link: function (scope, elem/*, attrs */) {\n var chart, container = document.createElement('div');\n container.className = 'chart-container';\n elem.replaceWith(container);\n container.appendChild(elem[0]);\n\n if (typeof window.G_vmlCanvasManager === 'object' && window.G_vmlCanvasManager !== null) {\n if (typeof window.G_vmlCanvasManager.initElement === 'function') {\n window.G_vmlCanvasManager.initElement(elem[0]);\n }\n }\n\n // Order of setting \"watch\" matter\n\n scope.$watch('data', function (newVal, oldVal) {\n if (! newVal || ! newVal.length || (Array.isArray(newVal[0]) && ! newVal[0].length)) return;\n var chartType = type || scope.chartType;\n if (! chartType) return;\n\n if (chart) {\n if (canUpdateChart(newVal, oldVal)) return updateChart(chart, newVal, scope);\n chart.destroy();\n }\n\n chart = createChart(chartType, scope, elem);\n }, true);\n\n scope.$watch('series', resetChart, true);\n scope.$watch('labels', resetChart, true);\n scope.$watch('options', resetChart, true);\n scope.$watch('colours', resetChart, true);\n\n scope.$watch('chartType', function (newVal, oldVal) {\n if (isEmpty(newVal)) return;\n if (angular.equals(newVal, oldVal)) return;\n if (chart) chart.destroy();\n chart = createChart(newVal, scope, elem);\n });\n\n scope.$on('$destroy', function () {\n if (chart) chart.destroy();\n });\n\n function resetChart (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 if (chart) chart.destroy();\n\n chart = createChart(chartType, scope, elem);\n }\n }\n };\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[0].length === oldVal[0].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 createChart (type, scope, elem) {\n if (! scope.data || ! scope.data.length) return;\n scope.getColour = typeof scope.getColour === 'function' ? scope.getColour : getRandomColour;\n scope.colours = getColours(scope);\n var cvs = elem[0], ctx = cvs.getContext('2d');\n var data = Array.isArray(scope.data[0]) ?\n getDataSets(scope.labels, scope.data, scope.series || [], scope.colours) :\n getData(scope.labels, scope.data, scope.colours);\n var chart = new Chart(ctx)[type](data, scope.options || {});\n scope.$emit('create', chart);\n\n if (scope.click) {\n cvs.onclick = function (evt) {\n var click = chart.getPointsAtEvent || chart.getBarsAtEvent || chart.getSegmentsAtEvent;\n\n if (click) {\n var activePoints = click.call(chart, evt);\n scope.click(activePoints, evt);\n scope.$apply();\n }\n };\n }\n if (scope.legend && scope.legend !== 'false') setLegend(elem, chart);\n return chart;\n }\n\n function getColours (scope) {\n var colours = angular.copy(scope.colours) || angular.copy(Chart.defaults.global.colours);\n while (colours.length < scope.data.length) {\n colours.push(scope.getColour());\n }\n return colours.map(convertColour);\n }\n\n function convertColour (colour) {\n if (typeof colour === 'object' && colour !== null) return colour;\n if (typeof colour === 'string' && colour[0] === '#') return getColour(hexToRgb(colour.substr(1)));\n return getRandomColour();\n }\n\n function getRandomColour () {\n var colour = [getRandomInt(0, 255), getRandomInt(0, 255), getRandomInt(0, 255)];\n return getColour(colour);\n }\n\n function getColour (colour) {\n return {\n fillColor: rgba(colour, 0.2),\n strokeColor: rgba(colour, 1),\n pointColor: rgba(colour, 1),\n pointStrokeColor: '#fff',\n pointHighlightFill: '#fff',\n pointHighlightStroke: rgba(colour, 0.8)\n };\n }\n\n function getRandomInt (min, max) {\n return Math.floor(Math.random() * (max - min + 1)) + min;\n }\n\n function rgba(colour, alpha) {\n return 'rgba(' + colour.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 getDataSets (labels, data, series, colours) {\n return {\n labels: labels,\n datasets: data.map(function (item, i) {\n var dataSet = angular.copy(colours[i]);\n dataSet.label = series[i];\n dataSet.data = item;\n return dataSet;\n })\n };\n }\n\n function getData (labels, data, colours) {\n return labels.map(function (label, i) {\n return {\n label: label,\n value: data[i],\n color: colours[i].strokeColor,\n highlight: colours[i].pointHighlightStroke\n };\n });\n }\n\n function setLegend (elem, chart) {\n var $parent = elem.parent(),\n $oldLegend = $parent.find('chart-legend'),\n legend = '' + chart.generateLegend() + '';\n if ($oldLegend.length) $oldLegend.replaceWith(legend);\n else $parent.append(legend);\n }\n\n function updateChart (chart, values, scope) {\n if (Array.isArray(scope.data[0])) {\n chart.datasets.forEach(function (dataset, i) {\n (dataset.points || dataset.bars).forEach(function (dataItem, j) {\n dataItem.value = values[i][j];\n });\n });\n } else {\n chart.segments.forEach(function (segment, i) {\n segment.value = values[i];\n });\n }\n chart.update();\n scope.$emit('update', 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})();\n"],"sourceRoot":"/source/"}