/*! * Chart.js * http://chartjs.org/ * Version: {{ version }} * * Copyright 2014 Nick Downie * Released under the MIT license * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md */ (function(){"use strict";var t=this,s=t.Chart,e=s.helpers,a={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,barShowStroke:!0,barStrokeWidth:2,barValueSpacing:5,barDatasetSpacing:1,legendTemplate:''};s.Type.extend({name:"Bar",defaults:a,initialize:function(t){var a=this.options;this.ScaleClass=s.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,s,e){var i=this.calculateBaseWidth(),l=this.calculateX(e)-i/2,o=this.calculateBarWidth(t);return l+o*s+s*a.barDatasetSpacing+o/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*a.barValueSpacing},calculateBarWidth:function(t){var s=this.calculateBaseWidth()-(t-1)*a.barDatasetSpacing;return s/t}}),this.datasets=[],this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var s="mouseout"!==t.type?this.getBarsAtEvent(t):[];this.eachBars(function(t){t.restore(["fillColor","strokeColor"])}),e.each(s,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(s)}),this.BarClass=s.Rectangle.extend({strokeWidth:this.options.barStrokeWidth,showStroke:this.options.barShowStroke,ctx:this.chart.ctx}),e.each(t.datasets,function(s){var a={label:s.label||null,fillColor:s.fillColor,strokeColor:s.strokeColor,bars:[]};this.datasets.push(a),e.each(s.data,function(e,i){a.bars.push(new this.BarClass({value:e,label:t.labels[i],datasetLabel:s.label,strokeColor:s.strokeColor,fillColor:s.fillColor,highlightFill:s.highlightFill||s.fillColor,highlightStroke:s.highlightStroke||s.strokeColor}))},this)},this),this.buildScale(t.labels),this.BarClass.prototype.base=this.scale.endPoint,this.eachBars(function(t,s,a){e.extend(t,{width:this.scale.calculateBarWidth(this.datasets.length),x:this.scale.calculateBarX(this.datasets.length,a,s),y:this.scale.endPoint}),t.save()},this),this.render()},update:function(){this.scale.update(),e.each(this.activeElements,function(t){t.restore(["fillColor","strokeColor"])}),this.eachBars(function(t){t.save()}),this.render()},eachBars:function(t){e.each(this.datasets,function(s,a){e.each(s.bars,t,this,a)},this)},getBarsAtEvent:function(t){for(var s,a=[],i=e.getRelativePosition(t),l=function(t){a.push(t.bars[s])},o=0;o