Chart.js/Chart.min.js

38 lines
84 KiB
JavaScript
Raw Normal View History

2014-06-29 19:36:25 +02:00
/*!
* Chart.js
* http://chartjs.org/
2015-06-04 03:45:14 +02:00
* Version: 2.0.0-alpha
2014-06-29 19:36:25 +02:00
*
2015-01-07 23:49:33 +01:00
* Copyright 2015 Nick Downie
2014-06-29 19:36:25 +02:00
* Released under the MIT license
* https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
*/
2015-06-16 00:19:56 +02:00
(function(){"use strict";var t=this,e=t.Chart,i=function(t,e){this.config=e,t.length&&t[0].getContext&&(t=t[0]),t.getContext&&(t=t.getContext("2d")),this.canvas=t.canvas,this.ctx=t;var n=function(t,e){return t["offset"+e]?t["offset"+e]:document.defaultView.getComputedStyle(t).getPropertyValue(e)},a=this.width=n(t.canvas,"Width")||t.canvas.width,s=this.height=n(t.canvas,"Height")||t.canvas.height;return t.canvas.width=a,t.canvas.height=s,a=this.width=t.canvas.width,s=this.height=t.canvas.height,this.aspectRatio=this.width/this.height,i.helpers.retinaScale(this),e?(this.controller=new i.Controller(this),this.controller):this};i.defaults={global:{responsive:!0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove","touchend"],hover:{onHover:null,mode:"single",animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",elements:{}}},"undefined"!=typeof amd?define(function(){return i}):"object"==typeof module&&module.exports&&(module.exports=i),t.Chart=i,i.noConflict=function(){return t.Chart=e,i}}).call(this),function(){"use strict";var t=this,e=(t.Chart,Chart.helpers={}),i=e.each=function(t,e,i){var n=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var a;for(a=0;a<t.length;a++)e.apply(i,[t[a],a].concat(n))}else for(var s in t)e.apply(i,[t[s],s].concat(n))},n=e.clone=function(t){var a={};return i(t,function(i,s){t.hasOwnProperty(s)&&(e.isArray(i)?a[s]=i.slice(0):"object"==typeof i&&null!==i?a[s]=n(i):a[s]=i)}),a},a=e.extend=function(t){return i(Array.prototype.slice.call(arguments,1),function(e){i(e,function(i,n){e.hasOwnProperty(n)&&(t[n]=i)})}),t},s=(e.merge=function(t,e){var i=Array.prototype.slice.call(arguments,0);return i.unshift({}),a.apply(null,i)},e.configMerge=function(t){var i=n(t);return e.each(Array.prototype.slice.call(arguments,1),function(t){e.each(t,function(n,a){if(t.hasOwnProperty(a))if("scales"===a)i[a]=e.scaleMerge(i.hasOwnProperty(a)?i[a]:{},n);else if("scale"===a)i[a]=e.configMerge(i.hasOwnProperty(a)?i[a]:{},Chart.scaleService.getScaleDefaults(n.type),n);else if(i.hasOwnProperty(a)&&e.isArray(i[a])&&e.isArray(n)){var s=i[a];e.each(n,function(t,i){i<s.length?s[i]=e.configMerge(s[i],t):s.push(t)})}else i.hasOwnProperty(a)&&"object"==typeof i[a]&&null!==i[a]&&"object"==typeof n?i[a]=e.configMerge(i[a],n):i[a]=n})}),i},e.scaleMerge=function(t,i){var a=n(t);return e.each(i,function(t,n){i.hasOwnProperty(n)&&("xAxes"===n||"yAxes"===n?a.hasOwnProperty(n)?e.each(t,function(t,i){i>=a[n].length||!a[n][i].type?a[n].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t)):t.type!==a[n][i].type?a[n][i]=e.configMerge(a[n][i],t.type?Chart.scaleService.getScaleDefaults(t.type):{},t):a[n][i]=e.configMerge(a[n][i],t)}):(a[n]=[],e.each(t,function(t){a[n].push(e.configMerge(t.type?Chart.scaleService.getScaleDefaults(t.type):{},t))})):a.hasOwnProperty(n)&&"object"==typeof a[n]&&null!==a[n]&&"object"==typeof t?a[n]=e.configMerge(a[n],t):a[n]=t)}),a},e.getValueAtIndexOrDefault=function(t,i,n){return t?e.isArray(t)&&i<t.length?t[i]:t:n},e.indexOf=function(t,e){if(Array.prototype.indexOf)return t.indexOf(e);for(var i=0;i<t.length;i++)if(t[i]===e)return i;return-1},e.where=function(t,i){var n=[];return e.each(t,function(t){i(t)&&n.push(t)}),n},e.findNextWhere=function(t,e,i){i||(i=-1);for(var n=i+1;n<t.length;n++){var a=t[n];if(e(a))return a}},e.findPreviousWhere=function(t,e,i){i||(i=t.length);for(var n=i-1;n>=0;n--){var a=t[n];if(e(a))return a}},e.inherits=function(t){var e=this,i=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},n=function(){this.constructor=i};return n.prototype=e.prototype,i.prototype=new n,i.extend=s,t&&a(i.prototype,t),i.__super__=e.prototype,i}),o=e.noop=function(){},r=(e.uid=function(){var t=0;return function(){return"chart-"+t++}}(),e.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},e.amd="function"==typeof define&&define.amd,e.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)}),h=e.max=function(t){return Math.max.apply(Math,t
t._model.backgroundColor=t.custom&&t.custom.hoverBackgroundColor?t.custom.hoverBackgroundColor:i.getValueAtIndexOrDefault(e.hoverBackgroundColor,n,i.color(t._model.backgroundColor).saturate(.5).darken(.1).rgbString()),t._model.borderColor=t.custom&&t.custom.hoverBorderColor?t.custom.hoverBorderColor:i.getValueAtIndexOrDefault(e.hoverBorderColor,n,i.color(t._model.borderColor).saturate(.5).darken(.1).rgbString()),t._model.borderWidth=t.custom&&t.custom.hoverBorderWidth?t.custom.hoverBorderWidth:i.getValueAtIndexOrDefault(e.borderWidth,n,t._model.borderWidth)},removeHoverStyle:function(t){}})}.call(this),function(){"use strict";return}.call(this),function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.line={hover:{mode:"label"},scales:{xAxes:[{type:"category"}],yAxes:[{type:"linear"}]}},e.controllers.line=function(t,e){this.initialize.call(this,t,e)},i.extend(e.controllers.line.prototype,{initialize:function(t,e){this.chart=t,this.index=e,this.linkScales(),this.addElements()},linkScales:function(){this.getDataset().xAxisID||(this.getDataset().xAxisID=this.chart.options.scales.xAxes[0].id),this.getDataset().yAxisID||(this.getDataset().yAxisID=this.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getScaleForId:function(t){return this.chart.scales[t]},addElements:function(){this.getDataset().metaData=this.getDataset().metaData||[],this.getDataset().metaDataset=this.getDataset().metaDataset||new e.elements.Line({_chart:this.chart.chart,_datasetIndex:this.index,_points:this.getDataset().metaData}),i.each(this.getDataset().data,function(t,i){this.getDataset().metaData[i]=this.getDataset().metaData[i]||new e.elements.Point({_chart:this.chart.chart,_datasetIndex:this.index,_index:i})},this)},reset:function(){this.update(!0)},update:function(t){var e,n=this.getDataset().metaDataset,a=this.getDataset().metaData,s=this.getScaleForId(this.getDataset().yAxisID),o=this.getScaleForId(this.getDataset().xAxisID);e=s.min<0&&s.max<0?s.getPixelForValue(s.max):s.min>0&&s.max>0?s.getPixelForValue(s.min):s.getPixelForValue(0),i.extend(n,{_scale:s,_datasetIndex:this.index,_children:a,_model:{tension:n.custom&&n.custom.tension?n.custom.tension:this.getDataset().tension||this.chart.options.elements.line.tension,backgroundColor:n.custom&&n.custom.backgroundColor?n.custom.backgroundColor:this.getDataset().backgroundColor||this.chart.options.elements.line.backgroundColor,borderWidth:n.custom&&n.custom.borderWidth?n.custom.borderWidth:this.getDataset().borderWidth||this.chart.options.elements.line.borderWidth,borderColor:n.custom&&n.custom.borderColor?n.custom.borderColor:this.getDataset().borderColor||this.chart.options.elements.line.borderColor,fill:n.custom&&n.custom.fill?n.custom.fill:void 0!==this.getDataset().fill?this.getDataset().fill:this.chart.options.elements.line.fill,skipNull:void 0!==this.getDataset().skipNull?this.getDataset().skipNull:this.chart.options.elements.line.skipNull,drawNull:void 0!==this.getDataset().drawNull?this.getDataset().drawNull:this.chart.options.elements.line.drawNull,scaleTop:s.top,scaleBottom:s.bottom,scaleZero:e}}),n.pivot(),i.each(a,function(t,e){i.extend(t,{_chart:this.chart.chart,_xScale:o,_yScale:s,_datasetIndex:this.index,_index:e,_model:{x:o.getPointPixelForValue(this.getDataset().data[e],e,this.index),y:s.getPointPixelForValue(this.getDataset().data[e],e,this.index),tension:t.custom&&t.custom.tension?t.custom.tension:this.chart.options.elements.line.tension,radius:t.custom&&t.custom.radius?t.custom.radius:i.getValueAtIndexOrDefault(this.getDataset().radius,e,this.chart.options.elements.point.radius),backgroundColor:t.custom&&t.custom.backgroundColor?t.custom.backgroundColor:i.getValueAtIndexOrDefault(this.getDataset().pointBackgroundColor,e,this.chart.options.elements.point.backgroundColor),borderColor:t.custom&&t.custom.borderColor?t.custom.borderColor:i.getValueAtIndexOrDefault(this.getDataset().pointBorderColor,e,this.chart.options.elements.point.borderColor),borderWidth:t.custom&&t.custom.borderWidth?t.custom.borderWidth:i.getValueAtIndex
2015-06-12 22:00:48 +02:00
* Chart.js
* http://chartjs.org/
* Version: 2.0.0-alpha
*
* Copyright 2015 Nick Downie
* Released under the MIT license
* https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
*/
2015-06-16 00:19:56 +02:00
function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.arc={backgroundColor:e.defaults.global.defaultColor,borderColor:"#fff",borderWidth:2},e.Arc=e.Element.extend({inLabelRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)<Math.pow(e.radius+e.hoverRadius,2):!1},inRange:function(t,e){var n=this._view,a=i.getAngleFromPoint(n,{x:t,y:e}),s=n.startAngle<-.5*Math.PI?n.startAngle+2*Math.PI:n.startAngle>1.5*Math.PI?n.startAngle-2*Math.PI:n.startAngle,o=n.endAngle<-.5*Math.PI?n.endAngle+2*Math.PI:n.endAngle>1.5*Math.PI?n.endAngle-2*Math.PI:n.endAngle,r=a.angle>=s&&a.angle<=o,h=a.distance>=n.innerRadius&&a.distance<=n.outerRadius;return r&&h},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,e.startAngle,e.endAngle),t.arc(e.x,e.y,e.innerRadius,e.endAngle,e.startAngle,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})}.call(this),/*!
2015-06-12 22:00:48 +02:00
* Chart.js
* http://chartjs.org/
* Version: 2.0.0-alpha
*
* Copyright 2015 Nick Downie
* Released under the MIT license
* https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
*/
2015-06-16 00:19:56 +02:00
function(){"use strict";var t=this,e=t.Chart,i=e.helpers;e.defaults.global.elements.line={tension:.4,backgroundColor:e.defaults.global.defaultColor,borderWidth:3,borderColor:e.defaults.global.defaultColor,fill:!0,skipNull:!0,drawNull:!1},e.elements.Line=e.Element.extend({draw:function(){var t=this._view,n=this._chart.ctx,a=this._children[0],s=this._children[this._children.length-1];i.each(this._children,function(e,a){var s=i.previousItem(this._children,a),o=i.nextItem(this._children,a);return 0===a?void n.moveTo(e._view.x,e._view.y):(e._view.skip&&t.skipNull&&!this._loop?(n.lineTo(s._view.x,e._view.y),n.moveTo(o._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop&&(n.moveTo(e._view.x,s._view.y),n.lineTo(e._view.x,e._view.y)),void(s._view.skip&&t.skipNull?n.moveTo(e._view.x,e._view.y):t.tension>0?n.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):n.lineTo(e._view.x,e._view.y)))},this),this._loop&&(t.tension>0&&!a._view.skip?n.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,a._view.controlPointPreviousX,a._view.controlPointPreviousY,a._view.x,a._view.y):n.lineTo(a._view.x,a._view.y)),this._children.length>0&&t.fill&&(n.lineTo(this._children[this._children.length-1]._view.x,t.scaleZero),n.lineTo(this._children[0]._view.x,t.scaleZero),n.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,n.closePath(),n.fill()),n.lineWidth=t.borderWidth||e.defaults.global.defaultColor,n.strokeStyle=t.borderColor||e.defaults.global.defaultColor,n.beginPath(),i.each(this._children,function(e,a){var s=i.previousItem(this._children,a),o=i.nextItem(this._children,a);return 0===a?void n.moveTo(e._view.x,e._view.y):e._view.skip&&t.skipNull&&!this._loop?(n.moveTo(s._view.x,e._view.y),void n.moveTo(o._view.x,e._view.y)):s._view.skip&&t.skipNull&&!this._loop?(n.moveTo(e._view.x,s._view.y),void n.moveTo(e._view.x,e._view.y)):s._view.skip&&t.skipNull?void n.moveTo(e._view.x,e._view.y):void(t.tension>0?n.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,e._view.controlPointPreviousX,e._view.controlPointPreviousY,e._view.x,e._view.y):n.lineTo(e._view.x,e._view.y))},this),this._loop&&!a._view.skip&&(t.tension>0?n.bezierCurveTo(s._view.controlPointNextX,s._view.controlPointNextY,a._view.controlPointPreviousX,a._view.controlPointPreviousY,a._view.x,a._view.y):n.lineTo(a._view.x,a._view.y)),n.stroke()}})}.call(this),/*!
2015-06-12 22:00:48 +02:00
* Chart.js
* http://chartjs.org/
* Version: 2.0.0-alpha
*
* Copyright 2015 Nick Downie
* Released under the MIT license
* https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
*/
2015-06-16 00:19:56 +02:00
function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.point={radius:3,backgroundColor:e.defaults.global.defaultColor,borderWidth:1,borderColor:e.defaults.global.defaultColor,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},e.elements.Point=e.Element.extend({inRange:function(t,e){var i=this._view,n=i.hitRadius+i.radius;return Math.pow(t-i.x,2)+Math.pow(e-i.y,2)<Math.pow(n,2)},inLabelRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)<Math.pow(e.radius+e.hitRadius,2):!1},tooltipPosition:function(){var t=this._view;return{x:t.x,y:t.y,padding:t.radius+t.borderWidth}},draw:function(){var t=this._view,i=this._chart.ctx;t.skip||(t.radius>0||t.borderWidth>0)&&(i.beginPath(),i.arc(t.x,t.y,t.radius||e.defaults.global.elements.point.radius,0,2*Math.PI),i.closePath(),i.strokeStyle=t.borderColor||e.defaults.global.defaultColor,i.lineWidth=t.borderWidth||e.defaults.global.elements.point.borderWidth,i.fillStyle=t.backgroundColor||e.defaults.global.defaultColor,i.fill(),i.stroke())}})}.call(this),function(){"use strict";var t=this,e=t.Chart;e.helpers;e.defaults.global.elements.rectangle={backgroundColor:e.defaults.global.defaultColor,borderWidth:0,borderColor:e.defaults.global.defaultColor},e.elements.Rectangle=e.Element.extend({draw:function(){var t=this._chart.ctx,e=this._view,i=e.width/2,n=e.x-i,a=e.x+i,s=e.base-(e.base-e.y),o=e.borderWidth/2;e.borderWidth&&(n+=o,a-=o,s+=o),t.beginPath(),t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.moveTo(n,e.base),t.lineTo(n,s),t.lineTo(a,s),t.lineTo(a,e.base),t.fill(),e.borderWidth&&t.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=this._view;return i.y<i.base?t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.y&&e<=i.base:t>=i.x-i.width/2&&t<=i.x+i.width/2&&e>=i.base&&e<=i.y},inLabelRange:function(t){var e=this._view;return t>=e.x-e.width/2&&t<=e.x+e.width/2},tooltipPosition:function(){var t=this._view;return t.y<t.base?{x:t.x,y:t.y}:{x:t.x,y:t.base}}})}.call(this),!function t(e,i,n){function a(o,r){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!r&&h)return h(o,!0);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[o]={exports:{}};e[o][0].call(c.exports,function(t){var i=e[o][1][t];return a(i?i:t)},c,c.exports,t,e,i,n)}return i[o].exports}for(var s="function"==typeof require&&require,o=0;o<n.length;o++)a(n[o]);return a}({1:[function(t,e,i){!function(){var i=t("color-convert"),n=t("color-string"),a=function(t){if(t instanceof a)return t;if(!(this instanceof a))return new a(t);if(this.values={rgb:[0,0,0],hsl:[0,0,0],hsv:[0,0,0],hwb:[0,0,0],cmyk:[0,0,0,0],alpha:1},"string"==typeof t){var e=n.getRgba(t);if(e)this.setValues("rgb",e);else if(e=n.getHsla(t))this.setValues("hsl",e);else{if(!(e=n.getHwb(t)))throw new Error('Unable to parse color from string "'+t+'"');this.setValues("hwb",e)}}else if("object"==typeof t){var e=t;if(void 0!==e.r||void 0!==e.red)this.setValues("rgb",e);else if(void 0!==e.l||void 0!==e.lightness)this.setValues("hsl",e);else if(void 0!==e.v||void 0!==e.value)this.setValues("hsv",e);else if(void 0!==e.w||void 0!==e.whiteness)this.setValues("hwb",e);else{if(void 0===e.c&&void 0===e.cyan)throw new Error("Unable to parse color from object "+JSON.stringify(t));this.setValues("cmyk",e)}}};a.prototype={rgb:function(t){return this.setSpace("rgb",arguments)},hsl:function(t){return this.setSpace("hsl",arguments)},hsv:function(t){return this.setSpace("hsv",arguments)},hwb:function(t){return this.setSpace("hwb",arguments)},cmyk:function(t){return this.setSpace("cmyk",arguments)},rgbArray:function(){return this.values.rgb},hslArray:function(){return this.values.hsl},hsvArray:function(){return this.values.hsv},hwbArray:function(){return 1!==this.values.alpha?this.values.hwb.concat([this.values.alpha]):this.values.hwb},cmykArray:function(){return this.values.cmyk},rgbaArray:function(){var t=this.values.rgb;return t.concat([this.values.alpha])},hslaArray:function(){var t=this.values.hsl;return t.concat([this.va