From 84720ecd5dadb0b60e1db4c4dca7e7b886e1571c Mon Sep 17 00:00:00 2001 From: Jerome Touffe-Blin Date: Mon, 5 Dec 2016 12:54:52 +1100 Subject: [PATCH] 1.1.0 --- bower.json | 2 +- dist/angular-chart.js | 52 +++++++++++++++++++++++++--------- dist/angular-chart.js.tar.gz | Bin 9279 -> 9981 bytes dist/angular-chart.min.js | 4 +-- dist/angular-chart.min.js.map | 2 +- examples/charts.html | 6 ++-- package.json | 2 +- 7 files changed, 46 insertions(+), 22 deletions(-) diff --git a/bower.json b/bower.json index 50c2df9b..292b2f6b 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-chart.js", - "version": "1.0.3", + "version": "1.1.0", "main": [ "./dist/angular-chart.js" ], diff --git a/dist/angular-chart.js b/dist/angular-chart.js index da920953..df7fce44 100644 --- a/dist/angular-chart.js +++ b/dist/angular-chart.js @@ -1,7 +1,7 @@ /*! * angular-chart.js - An angular.js wrapper for Chart.js * http://jtblin.github.io/angular-chart.js/ - * Version: 1.0.3 + * Version: 1.1.0 * * Copyright 2016 Jerome Touffe-Blin * Released under the BSD-2-Clause license @@ -19,8 +19,11 @@ define(['angular', 'chart'], factory); } else { // Browser globals - if (typeof angular === 'undefined' || typeof Chart === 'undefined') + if (typeof angular === 'undefined') { + throw new Error('AngularJS framework needs to be included, see https://angularjs.org/'); + } else if (typeof Chart === 'undefined') { throw new Error('Chart.js library needs to be included, see http://jtblin.github.io/angular-chart.js/'); + } factory(angular, Chart); } }(function (angular, Chart) { @@ -180,7 +183,6 @@ scope.chartGetColor = getChartColorFn(scope); var data = getChartData(type, scope); - // Destroy old chart if it exists to avoid ghost charts issue // https://github.com/jtblin/angular-chart.js/issues/187 destroyChart(scope); @@ -209,14 +211,23 @@ } function getEventHandler (scope, action, triggerOnlyOnChange) { - var lastState = null; + var lastState = { + point: void 0, + points: void 0 + }; return function (evt) { - var atEvent = scope.chart.getElementsAtEvent || scope.chart.getPointsAtEvent; - if (atEvent) { - var activePoints = atEvent.call(scope.chart, evt); - if (triggerOnlyOnChange === false || angular.equals(lastState, activePoints) === false) { - lastState = activePoints; - scope[action](activePoints, evt); + var atEvent = scope.chart.getElementAtEvent || scope.chart.getPointAtEvent; + var atEvents = scope.chart.getElementsAtEvent || scope.chart.getPointsAtEvent; + if (atEvents) { + var points = atEvents.call(scope.chart, evt); + var point = atEvent ? atEvent.call(scope.chart, evt)[0] : void 0; + + if (triggerOnlyOnChange === false || + (! angular.equals(lastState.points, points) && ! angular.equals(lastState.point, point)) + ) { + lastState.point = point; + lastState.points = points; + scope[action](points, evt, point); } } }; @@ -238,8 +249,12 @@ } function convertColor (color) { - if (typeof color === 'object' && color !== null) return color; + // Allows RGB and RGBA colors to be input as a string: e.g.: "rgb(159,204,0)", "rgba(159,204,0, 0.5)" + if (typeof color === 'string' && color[0] === 'r') return getColor(rgbStringToRgb(color)); + // Allows hex colors to be input as a string. if (typeof color === 'string' && color[0] === '#') return getColor(hexToRgb(color.substr(1))); + // Allows colors to be input as an object, bypassing getColor() entirely + if (typeof color === 'object' && color !== null) return color; return getRandomColor(); } @@ -249,13 +264,15 @@ } function getColor (color) { + var alpha = color[3] || 1; + color = color.slice(0, 3); return { backgroundColor: rgba(color, 0.2), - pointBackgroundColor: rgba(color, 1), + pointBackgroundColor: rgba(color, alpha), pointHoverBackgroundColor: rgba(color, 0.8), - borderColor: rgba(color, 1), + borderColor: rgba(color, alpha), pointBorderColor: '#fff', - pointHoverBorderColor: rgba(color, 1) + pointHoverBorderColor: rgba(color, alpha) }; } @@ -278,6 +295,13 @@ return [r, g, b]; } + function rgbStringToRgb (color) { + var match = color.match(/^rgba?\(([\d,.]+)\)$/); + if (! match) throw new Error('Cannot parse rgb value'); + color = match[1].split(','); + return color.map(Number); + } + function hasData (scope) { return scope.chartData && scope.chartData.length; } diff --git a/dist/angular-chart.js.tar.gz b/dist/angular-chart.js.tar.gz index b260957117098aec31337346bf4c5a83b649d88c..f6782817906bb4ca833f4c23f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644 --- a/dist/angular-chart.min.js +++ b/dist/angular-chart.min.js @@ -1,11 +1,11 @@ /*! * angular-chart.js - An angular.js wrapper for Chart.js * http://jtblin.github.io/angular-chart.js/ - * Version: 1.0.3 + * Version: 1.1.0 * * Copyright 2016 Jerome Touffe-Blin * Released under the BSD-2-Clause license * https://github.com/jtblin/angular-chart.js/blob/master/LICENSE */ -!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 be 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,n){n?a[r]=t.merge(a[r]||{},n):(n=r,a=t.merge(a,n)),t.merge(e.Chart.defaults,a)},this.$get=function(){return e}}function e(a,e){function o(t,r,e){var n=w(t,r);if(v(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)}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>16&255,e=r>>8&255,n=255&r;return[a,e,n]}function v(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)}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}); +!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)throw new Error("AngularJS framework needs to be included, see https://angularjs.org/");if("undefined"==typeof Chart)throw new Error("Chart.js library needs to be included, see http://jtblin.github.io/angular-chart.js/");t(angular,Chart)}}(function(t,r){"use strict";function e(){var e={responsive:!0},a={Chart:r,getOptions:function(r){var a=r&&e[r]||{};return t.extend({},e,a)}};this.setOptions=function(r,n){n?e[r]=t.merge(e[r]||{},n):(n=r,e=t.merge(e,n)),t.merge(a.Chart.defaults,e)},this.$get=function(){return a}}function a(e,a){function o(t,r,a){var n=D(t,r);if(C(r)&&k(t,r,a,n)){var o=a[0],c=o.getContext("2d");r.chartGetColor=y(r);var i=b(t,r);F(r),r.chart=new e.Chart(c,{type:t,data:i,options:n}),r.$emit("chart-create",r.chart),A(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,e){return t.length===r[e].length}):r.reduce(i,0)>0&&t.length===r.length)}function i(t,r){return t+r}function u(r,e,a){var n={point:void 0,points:void 0};return function(o){var c=r.chart.getElementAtEvent||r.chart.getPointAtEvent,i=r.chart.getElementsAtEvent||r.chart.getPointsAtEvent;if(i){var u=i.call(r.chart,o),l=c?c.call(r.chart,o)[0]:void 0;a!==!1&&(t.equals(n.points,u)||t.equals(n.point,l))||(n.point=l,n.points=u,r[e](u,o,l))}}}function l(a,n){for(var o=t.copy(n.chartColors||e.getOptions(a).chartColors||r.defaults.global.colors),c=o.length>16&255,a=r>>8&255,n=255&r;return[e,a,n]}function v(t){var r=t.match(/^rgba?\(([\d,.]+)\)$/);if(!r)throw new Error("Cannot parse rgb value");return t=r[1].split(","),t.map(Number)}function C(t){return t.chartData&&t.chartData.length}function y(t){return"function"==typeof t.chartGetColor?t.chartGetColor:s}function b(t,r){var e=l(t,r);return Array.isArray(r.chartData[0])?m(r.chartLabels,r.chartData,r.chartSeries||[],e,r.chartDatasetOverride):w(r.chartLabels,r.chartData,e,r.chartDatasetOverride)}function m(r,e,a,n,o){return{labels:r,datasets:e.map(function(r,e){var c=t.extend({},n[e],{label:a[e],data:r});return o&&o.length>=e&&t.merge(c,o[e]),c})}}function w(r,e,a,n){var o={labels:r,datasets:[{data:e,backgroundColor:a.map(function(t){return t.pointBackgroundColor}),hoverBackgroundColor:a.map(function(t){return t.backgroundColor})}]};return n&&t.merge(o.datasets[0],n),o}function D(r,a){return t.extend({},e.getOptions(r),a.chartOptions)}function A(r,e){r.onclick=e.chartClick?u(e,"chartClick",!1):t.noop,r.onmousemove=e.chartHover?u(e,"chartHover",!0):t.noop}function B(t,r){Array.isArray(r.chartData[0])?r.chart.data.datasets.forEach(function(r,e){r.data=t[e]}):r.chart.data.datasets[0].data=t,r.chart.update(),r.$emit("chart-update",r.chart)}function $(t){return!t||Array.isArray(t)&&!t.length||"object"==typeof t&&!Object.keys(t).length}function k(t,r,e,n){return!n.responsive||0!==e[0].clientHeight||(a(function(){o(t,r,e)},50,!1),!1)}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(e,a){function i(t,n){if(!t||!t.length||Array.isArray(t[0])&&!t[0].length)return void F(e);var i=r||e.chartType;if(i)return e.chart&&c(t,n)?B(t,e):void o(i,e,a)}function u(n,c){if(!$(n)&&!t.equals(n,c)){var i=r||e.chartType;i&&o(i,e,a)}}function l(r,n){$(r)||t.equals(r,n)||o(r,e,a)}n&&window.G_vmlCanvasManager.initElement(a[0]),e.$watch("chartData",i,!0),e.$watch("chartSeries",u,!0),e.$watch("chartLabels",u,!0),e.$watch("chartOptions",u,!0),e.$watch("chartColors",u,!0),e.$watch("chartDatasetOverride",u,!0),e.$watch("chartType",l,!1),e.$on("$destroy",function(){F(e)}),e.$on("$resize",function(){e.chart&&e.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",e).factory("ChartJsFactory",["ChartJs","$timeout",a]).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}); //# sourceMappingURL=angular-chart.min.js.map diff --git a/dist/angular-chart.min.js.map b/dist/angular-chart.min.js.map index 4406fa63..e8454a98 100644 --- a/dist/angular-chart.min.js.map +++ b/dist/angular-chart.min.js.map @@ -1 +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","merge","defaults","$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","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","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,uFACAR,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,GAEAA,EAKAT,EAAAI,GAAAX,EAAAiB,MAAAV,EAAAI,OAAAK,IAJAA,EAAAL,EACAJ,EAAAP,EAAAiB,MAAAV,EAAAS,IAMAhB,EAAAiB,MAAAR,EAAAP,MAAAgB,SAAAX,IAGAO,KAAAK,KAAA,WACA,MAAAV,IAIA,QAAAW,GAAAX,EAAAY,GAsEA,QAAAC,GAAAX,EAAAY,EAAAC,GACA,GAAAjB,GAAAkB,EAAAd,EAAAY,EACA,IAAAG,EAAAH,IAAAI,EAAAhB,EAAAY,EAAAC,EAAAjB,GAAA,CAEA,GAAAqB,GAAAJ,EAAA,GACAK,EAAAD,EAAAE,WAAA,KAE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Ab,EAAAa,MAAA0G,cA5GA5I,EAAAgB,SAAAiD,OAAA4E,qBAAA,6DACA7I,EAAAgB,SAAAiD,OAAA6E,SAAAC,KAAA,QACA/I,EAAAgB,SAAAiD,OAAA+E,SAAAC,KAAAC,YAAA,EACAlJ,EAAAgB,SAAAiD,OAAA+E,SAAAG,UAAAD,YAAA,EACAlJ,EAAAgB,SAAAiD,OAAAmF,OAAAC,SAAA,EACArJ,EAAAgB,SAAAiD,OAAAH,QACA,UACA,UACA,UACA,UACA,UACA,UACA,UAGA,IAAA4B,GAAA,gBAAA6C,QAAAC,oBACA,OAAAD,OAAAC,oBACA,kBAAAD,QAAAC,mBAAAC,WAIA,OAFA/C,KAAA1F,EAAAgB,SAAAiD,OAAAqF,WAAA,GAEAxJ,EAAAD,OAAA,eACA0J,SAAA,UAAAnJ,GACAT,QAAA,kBAAA,UAAA,WAAAuB,IACAsI,UAAA,aAAA,iBAAA,SAAAtI,GAAA,MAAA,IAAAA,MACAsI,UAAA,aAAA,iBAAA,SAAAtI,GAAA,MAAA,IAAAA,GAAA,WACAsI,UAAA,YAAA,iBAAA,SAAAtI,GAAA,MAAA,IAAAA,GAAA,UACAsI,UAAA,sBAAA,iBAAA,SAAAtI,GAAA,MAAA,IAAAA,GAAA,oBACAsI,UAAA,cAAA,iBAAA,SAAAtI,GAAA,MAAA,IAAAA,GAAA,YACAsI,UAAA,iBAAA,iBAAA,SAAAtI,GAAA,MAAA,IAAAA,GAAA,eACAsI,UAAA,YAAA,iBAAA,SAAAtI,GAAA,MAAA,IAAAA,GAAA,UACAsI,UAAA,kBAAA,iBAAA,SAAAtI,GAAA,MAAA,IAAAA,GAAA,gBACAsI,UAAA,eAAA,iBAAA,SAAAtI,GAAA,MAAA,IAAAA,GAAA,aACAuI","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 be 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.merge(options, customOptions);\n } else {\n // Set options for the specific chart\n options[type] = angular.merge(options[type] || {}, customOptions);\n }\n\n angular.merge(ChartJs.Chart.defaults, options);\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 +{"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","merge","defaults","$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","point","points","evt","atEvent","getElementAtEvent","getPointAtEvent","atEvents","getElementsAtEvent","getPointsAtEvent","call","equals","getColors","colors","copy","chartColors","global","notEnoughColors","chartData","push","map","convertColor","color","getColor","rgbStringToRgb","hexToRgb","substr","getRandomColor","getRandomInt","alpha","slice","backgroundColor","rgba","pointBackgroundColor","pointHoverBackgroundColor","borderColor","pointBorderColor","pointHoverBorderColor","min","max","Math","floor","random","useExcanvas","join","concat","hex","bigint","parseInt","r","g","b","match","split","Number","getDataSets","chartLabels","chartSeries","chartDatasetOverride","getData","labels","series","datasetOverride","datasets","item","i","dataset","label","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,SACA,KAAA,IAAAK,OAAA,uEACA,IAAA,mBAAAH,OACA,KAAA,IAAAG,OAAA,uFAEAR,GAAAG,QAAAE,SAEA,SAAAF,EAAAE,GACA,YA8CA,SAAAI,KACA,GAAAC,IAAAC,YAAA,GACAC,GACAP,MAAAA,EACAQ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AAG,UAAAD,YAAA,EACA3J,EAAAgB,SAAAqD,OAAAwF,OAAAC,SAAA,EACA9J,EAAAgB,SAAAqD,OAAAH,QACA,UACA,UACA,UACA,UACA,UACA,UACA,UAGA,IAAA8B,GAAA,gBAAAgD,QAAAC,oBACA,OAAAD,OAAAC,oBACA,kBAAAD,QAAAC,mBAAAC,WAIA,OAFAlD,KAAAhG,EAAAgB,SAAAqD,OAAA0F,WAAA,GAEAjK,EAAAD,OAAA,eACAmK,SAAA,UAAA5J,GACAT,QAAA,kBAAA,UAAA,WAAAuB,IACA+I,UAAA,aAAA,iBAAA,SAAA/I,GAAA,MAAA,IAAAA,MACA+I,UAAA,aAAA,iBAAA,SAAA/I,GAAA,MAAA,IAAAA,GAAA,WACA+I,UAAA,YAAA,iBAAA,SAAA/I,GAAA,MAAA,IAAAA,GAAA,UACA+I,UAAA,sBAAA,iBAAA,SAAA/I,GAAA,MAAA,IAAAA,GAAA,oBACA+I,UAAA,cAAA,iBAAA,SAAA/I,GAAA,MAAA,IAAAA,GAAA,YACA+I,UAAA,iBAAA,iBAAA,SAAA/I,GAAA,MAAA,IAAAA,GAAA,eACA+I,UAAA,YAAA,iBAAA,SAAA/I,GAAA,MAAA,IAAAA,GAAA,UACA+I,UAAA,kBAAA,iBAAA,SAAA/I,GAAA,MAAA,IAAAA,GAAA,gBACA+I,UAAA,eAAA,iBAAA,SAAA/I,GAAA,MAAA,IAAAA,GAAA,aACAgJ","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') {\n throw new Error('AngularJS framework needs to be included, see https://angularjs.org/');\n } else if (typeof Chart === 'undefined') {\n throw new Error('Chart.js library needs to be included, see http://jtblin.github.io/angular-chart.js/');\n }\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.merge(options, customOptions);\n } else {\n // Set options for the specific chart\n options[type] = angular.merge(options[type] || {}, customOptions);\n }\n\n angular.merge(ChartJs.Chart.defaults, options);\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 // 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 = {\n point: void 0,\n points: void 0\n };\n return function (evt) {\n var atEvent = scope.chart.getElementAtEvent || scope.chart.getPointAtEvent;\n var atEvents = scope.chart.getElementsAtEvent || scope.chart.getPointsAtEvent;\n if (atEvents) {\n var points = atEvents.call(scope.chart, evt);\n var point = atEvent ? atEvent.call(scope.chart, evt)[0] : void 0;\n\n if (triggerOnlyOnChange === false ||\n (! angular.equals(lastState.points, points) && ! angular.equals(lastState.point, point))\n ) {\n lastState.point = point;\n lastState.points = points;\n scope[action](points, evt, point);\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 // Allows RGB and RGBA colors to be input as a string: e.g.: \"rgb(159,204,0)\", \"rgba(159,204,0, 0.5)\"\n if (typeof color === 'string' && color[0] === 'r') return getColor(rgbStringToRgb(color));\n // Allows hex colors to be input as a string.\n if (typeof color === 'string' && color[0] === '#') return getColor(hexToRgb(color.substr(1)));\n // Allows colors to be input as an object, bypassing getColor() entirely\n if (typeof color === 'object' && color !== null) return color;\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 var alpha = color[3] || 1;\n color = color.slice(0, 3);\n return {\n backgroundColor: rgba(color, 0.2),\n pointBackgroundColor: rgba(color, alpha),\n pointHoverBackgroundColor: rgba(color, 0.8),\n borderColor: rgba(color, alpha),\n pointBorderColor: '#fff',\n pointHoverBorderColor: rgba(color, alpha)\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 rgbStringToRgb (color) {\n var match = color.match(/^rgba?\\(([\\d,.]+)\\)$/);\n if (! match) throw new Error('Cannot parse rgb value');\n color = match[1].split(',');\n return color.map(Number);\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"]} \ No newline at end of file diff --git a/examples/charts.html b/examples/charts.html index 9be3df67..d737f74c 100644 --- a/examples/charts.html +++ b/examples/charts.html @@ -95,7 +95,7 @@

Code on Github - Download (1.0.3) + Download (1.1.0)

@@ -185,8 +185,8 @@

Directives

<canvas id="line" class="chart chart-line" chart-data="data"
 chart-labels="labels" chart-series="series" chart-options="options"
-chart-dataset-override="datasetOverride" chart-click="onClick"
-</canvas> 
+chart-dataset-override="datasetOverride" chart-click="onClick"> +</canvas>
angular.module("app", ["chart.js"]).controller("LineCtrl", function ($scope) {
diff --git a/package.json b/package.json
index eb3b9ff7..c2ff0205 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "angular-chart.js",
-  "version": "1.0.3",
+  "version": "1.1.0",
   "description": "An angular.js wrapper for Chart.js",
   "homepage": "http://jtblin.github.io/angular-chart.js/",
   "main": "dist/angular-chart.js",