Business intelligence made simple
Updated chartjs
Andrew Kaneff4639822c9b
diff --git a/app/assets/javascripts/blazer/Chart.js b/app/assets/javascripts/blazer/Chart.jsold mode 100755new mode 100644index e1215f9f..86105804--- a/app/assets/javascripts/blazer/Chart.js+++ b/app/assets/javascripts/blazer/Chart.js@@ -1,3 +1,12 @@+/*!+ * Chart.js+ * http://chartjs.org/+ * Version: 2.0.2+ *+ * Copyright 2016 Nick Downie+ * Released under the MIT license+ * https://github.com/chartjs/Chart.js/blob/master/LICENSE.md+ */(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){},{}],2:[function(require,module,exports){@@ -1587,17 +1596,6 @@ Color.prototype.setChannel = function(space, index, val) {window.Color = module.exports = Color},{"color-convert":3,"color-string":4}],7:[function(require,module,exports){-/*!- * Chart.js- * http://chartjs.org/- * Version: 2.0.2- *- * Copyright 2015 Nick Downie- * Released under the MIT license- * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md- */--var Chart = require('./core/core.js')();require('./core/core.helpers')(Chart);@@ -1607,6 +1605,7 @@ require('./core/core.controller')(Chart);require('./core/core.datasetController')(Chart);require('./core/core.layoutService')(Chart);require('./core/core.legend')(Chart);+require('./core/core.plugin.js')(Chart);require('./core/core.scale')(Chart);require('./core/core.scaleService')(Chart);require('./core/core.title')(Chart);@@ -1640,7 +1639,7 @@ require('./charts/Chart.Scatter')(Chart);window.Chart = module.exports = Chart;-},{"./charts/Chart.Bar":8,"./charts/Chart.Bubble":9,"./charts/Chart.Doughnut":10,"./charts/Chart.Line":11,"./charts/Chart.PolarArea":12,"./charts/Chart.Radar":13,"./charts/Chart.Scatter":14,"./controllers/controller.bar":15,"./controllers/controller.bubble":16,"./controllers/controller.doughnut":17,"./controllers/controller.line":18,"./controllers/controller.polarArea":19,"./controllers/controller.radar":20,"./core/core.animation":21,"./core/core.controller":22,"./core/core.datasetController":23,"./core/core.element":24,"./core/core.helpers":25,"./core/core.js":26,"./core/core.layoutService":27,"./core/core.legend":28,"./core/core.scale":29,"./core/core.scaleService":30,"./core/core.title":31,"./core/core.tooltip":32,"./elements/element.arc":33,"./elements/element.line":34,"./elements/element.point":35,"./elements/element.rectangle":36,"./scales/scale.category":37,"./scales/scale.linear":38,"./scales/scale.logarithmic":39,"./scales/scale.radialLinear":40,"./scales/scale.time":41}],8:[function(require,module,exports){+},{"./charts/Chart.Bar":8,"./charts/Chart.Bubble":9,"./charts/Chart.Doughnut":10,"./charts/Chart.Line":11,"./charts/Chart.PolarArea":12,"./charts/Chart.Radar":13,"./charts/Chart.Scatter":14,"./controllers/controller.bar":15,"./controllers/controller.bubble":16,"./controllers/controller.doughnut":17,"./controllers/controller.line":18,"./controllers/controller.polarArea":19,"./controllers/controller.radar":20,"./core/core.animation":21,"./core/core.controller":22,"./core/core.datasetController":23,"./core/core.element":24,"./core/core.helpers":25,"./core/core.js":26,"./core/core.layoutService":27,"./core/core.legend":28,"./core/core.plugin.js":29,"./core/core.scale":30,"./core/core.scaleService":31,"./core/core.title":32,"./core/core.tooltip":33,"./elements/element.arc":34,"./elements/element.line":35,"./elements/element.point":36,"./elements/element.rectangle":37,"./scales/scale.category":38,"./scales/scale.linear":39,"./scales/scale.logarithmic":40,"./scales/scale.radialLinear":41,"./scales/scale.time":42}],8:[function(require,module,exports){"use strict";module.exports = function(Chart) {@@ -1803,31 +1802,32 @@ module.exports = function(Chart) {Chart.DatasetController.prototype.initialize.call(this, chart, datasetIndex);// Use this to indicate that this is a bar dataset.- this.getDataset().bar = true;+ this.getMeta().bar = true;},// Get the number of datasets that display bars. We use this to correctly calculate the bar widthgetBarCount: function getBarCount() {var barCount = 0;- helpers.each(this.chart.data.datasets, function(dataset) {- if (helpers.isDatasetVisible(dataset) && dataset.bar) {+ helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) {+ var meta = this.chart.getDatasetMeta(datasetIndex);+ if (meta.bar && this.chart.isDatasetVisible(datasetIndex)) {++barCount;}- });+ }, this);return barCount;},addElements: function() {- this.getDataset().metaData = this.getDataset().metaData || [];+ var meta = this.getMeta();helpers.each(this.getDataset().data, function(value, index) {- this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Rectangle({+ meta.data[index] = meta.data[index] || new Chart.elements.Rectangle({_chart: this.chart.chart,_datasetIndex: this.index,_index: index});}, this);},+addElementAndReset: function(index) {- this.getDataset().metaData = this.getDataset().metaData || [];var rectangle = new Chart.elements.Rectangle({_chart: this.chart.chart,_datasetIndex: this.index,@@ -1836,22 +1836,23 @@ module.exports = function(Chart) {var numBars = this.getBarCount();+ // Add to the points array and reset it+ this.getMeta().data.splice(index, 0, rectangle);this.updateElement(rectangle, index, true, numBars);- this.getDataset().metaData.splice(index, 0, rectangle);},update: function update(reset) {var numBars = this.getBarCount();- helpers.each(this.getDataset().metaData, function(rectangle, index) {+ helpers.each(this.getMeta().data, function(rectangle, index) {this.updateElement(rectangle, index, reset, numBars);}, this);},updateElement: function updateElement(rectangle, index, reset, numBars) {-- var xScale = this.getScaleForId(this.getDataset().xAxisID);- var yScale = this.getScaleForId(this.getDataset().yAxisID);+ var meta = this.getMeta();+ var xScale = this.getScaleForId(meta.xAxisID);+ var yScale = this.getScaleForId(meta.yAxisID);var yScalePoint;@@ -1895,9 +1896,9 @@ module.exports = function(Chart) {},calculateBarBase: function(datasetIndex, index) {-- var xScale = this.getScaleForId(this.getDataset().xAxisID);- var yScale = this.getScaleForId(this.getDataset().yAxisID);+ var meta = this.getMeta();+ var xScale = this.getScaleForId(meta.xAxisID);+ var yScale = this.getScaleForId(meta.yAxisID);var base = 0;@@ -1908,14 +1909,16 @@ module.exports = function(Chart) {if (value < 0) {for (var i = 0; i < datasetIndex; i++) {var negDS = this.chart.data.datasets[i];- if (helpers.isDatasetVisible(negDS) && negDS.yAxisID === yScale.id && negDS.bar) {+ var negDSMeta = this.chart.getDatasetMeta(i);+ if (negDSMeta.bar && negDSMeta.yAxisID === yScale.id && this.chart.isDatasetVisible(i)) {base += negDS.data[index] < 0 ? negDS.data[index] : 0;}}} else {for (var j = 0; j < datasetIndex; j++) {var posDS = this.chart.data.datasets[j];- if (helpers.isDatasetVisible(posDS) && posDS.yAxisID === yScale.id && posDS.bar) {+ var posDSMeta = this.chart.getDatasetMeta(j);+ if (posDSMeta.bar && posDSMeta.yAxisID === yScale.id && this.chart.isDatasetVisible(j)) {base += posDS.data[index] > 0 ? posDS.data[index] : 0;}}@@ -1939,9 +1942,9 @@ module.exports = function(Chart) {},getRuler: function() {-- var xScale = this.getScaleForId(this.getDataset().xAxisID);- var yScale = this.getScaleForId(this.getDataset().yAxisID);+ var meta = this.getMeta();+ var xScale = this.getScaleForId(meta.xAxisID);+ var yScale = this.getScaleForId(meta.yAxisID);var datasetCount = this.getBarCount();var tickWidth = (function() {@@ -1954,6 +1957,12 @@ module.exports = function(Chart) {var categoryWidth = tickWidth * xScale.options.categoryPercentage;var categorySpacing = (tickWidth - (tickWidth * xScale.options.categoryPercentage)) / 2;var fullBarWidth = categoryWidth / datasetCount;++ if (xScale.ticks.length !== this.chart.data.labels.length) {+ var perc = xScale.ticks.length / this.chart.data.labels.length;+ fullBarWidth = fullBarWidth * perc;+ }+var barWidth = fullBarWidth * xScale.options.barPercentage;var barSpacing = fullBarWidth - (fullBarWidth * xScale.options.barPercentage);@@ -1969,7 +1978,7 @@ module.exports = function(Chart) {},calculateBarWidth: function() {- var xScale = this.getScaleForId(this.getDataset().xAxisID);+ var xScale = this.getScaleForId(this.getMeta().xAxisID);var ruler = this.getRuler();return xScale.options.stacked ? ruler.categoryWidth : ruler.barWidth;},@@ -1977,9 +1986,11 @@ module.exports = function(Chart) {// Get bar index from the given dataset index accounting for the fact that not all bars are visiblegetBarIndex: function(datasetIndex) {var barIndex = 0;+ var meta, j;- for (var j = 0; j < datasetIndex; ++j) {- if (helpers.isDatasetVisible(this.chart.data.datasets[j]) && this.chart.data.datasets[j].bar) {+ for (j = 0; j < datasetIndex; ++j) {+ meta = this.chart.getDatasetMeta(j);+ if (meta.bar && this.chart.isDatasetVisible(j)) {++barIndex;}}@@ -1988,9 +1999,9 @@ module.exports = function(Chart) {},calculateBarX: function(index, datasetIndex) {-- var yScale = this.getScaleForId(this.getDataset().yAxisID);- var xScale = this.getScaleForId(this.getDataset().xAxisID);+ var meta = this.getMeta();+ var yScale = this.getScaleForId(meta.yAxisID);+ var xScale = this.getScaleForId(meta.xAxisID);var barIndex = this.getBarIndex(datasetIndex);var ruler = this.getRuler();@@ -2010,9 +2021,9 @@ module.exports = function(Chart) {},calculateBarY: function(index, datasetIndex) {-- var xScale = this.getScaleForId(this.getDataset().xAxisID);- var yScale = this.getScaleForId(this.getDataset().yAxisID);+ var meta = this.getMeta();+ var xScale = this.getScaleForId(meta.xAxisID);+ var yScale = this.getScaleForId(meta.yAxisID);var value = this.getDataset().data[index];@@ -2023,7 +2034,8 @@ module.exports = function(Chart) {for (var i = 0; i < datasetIndex; i++) {var ds = this.chart.data.datasets[i];- if (helpers.isDatasetVisible(ds) && ds.bar && ds.yAxisID === yScale.id) {+ var dsMeta = this.chart.getDatasetMeta(i);+ if (dsMeta.bar && dsMeta.yAxisID === yScale.id && this.chart.isDatasetVisible(i)) {if (ds.data[index] < 0) {sumNeg += ds.data[index] || 0;} else {@@ -2037,8 +2049,6 @@ module.exports = function(Chart) {} else {return yScale.getPixelForValue(sumPos + value);}-- return yScale.getPixelForValue(value);}return yScale.getPixelForValue(value);@@ -2046,7 +2056,7 @@ module.exports = function(Chart) {draw: function(ease) {var easingDecimal = ease || 1;- helpers.each(this.getDataset().metaData, function(rectangle, index) {+ helpers.each(this.getMeta().data, function(rectangle, index) {var d = this.getDataset().data[index];if (d !== null && d !== undefined && !isNaN(d)) {rectangle.transition(easingDecimal).draw();@@ -2073,6 +2083,296 @@ module.exports = function(Chart) {}});+++ // including horizontalBar in the bar file, instead of a file of its own+ // it extends bar (like pie extends doughnut)+ Chart.defaults.horizontalBar = {+ hover: {+ mode: "label"+ },++ scales: {+ xAxes: [{+ type: "linear",+ position: "bottom"+ }],+ yAxes: [{+ position: "left",+ type: "category",++ // Specific to Horizontal Bar Controller+ categoryPercentage: 0.8,+ barPercentage: 0.9,++ // grid line settings+ gridLines: {+ offsetGridLines: true+ }+ }]+ },+ };++ Chart.controllers.horizontalBar = Chart.controllers.bar.extend({+ updateElement: function updateElement(rectangle, index, reset, numBars) {+ var meta = this.getMeta();+ var xScale = this.getScaleForId(meta.xAxisID);+ var yScale = this.getScaleForId(meta.yAxisID);++ var xScalePoint;++ if (xScale.min < 0 && xScale.max < 0) {+ // all less than 0. use the right+ xScalePoint = xScale.getPixelForValue(xScale.max);+ } else if (xScale.min > 0 && xScale.max > 0) {+ xScalePoint = xScale.getPixelForValue(xScale.min);+ } else {+ xScalePoint = xScale.getPixelForValue(0);+ }++ helpers.extend(rectangle, {+ // Utility+ _chart: this.chart.chart,+ _xScale: xScale,+ _yScale: yScale,+ _datasetIndex: this.index,+ _index: index,++ // Desired view properties+ _model: {+ x: reset ? xScalePoint : this.calculateBarX(index, this.index),+ y: this.calculateBarY(index, this.index),++ // Tooltip+ label: this.chart.data.labels[index],+ datasetLabel: this.getDataset().label,++ // Appearance+ base: reset ? xScalePoint : this.calculateBarBase(this.index, index),+ height: this.calculateBarHeight(numBars),+ backgroundColor: rectangle.custom && rectangle.custom.backgroundColor ? rectangle.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.rectangle.backgroundColor),+ borderSkipped: rectangle.custom && rectangle.custom.borderSkipped ? rectangle.custom.borderSkipped : this.chart.options.elements.rectangle.borderSkipped,+ borderColor: rectangle.custom && rectangle.custom.borderColor ? rectangle.custom.borderColor : helpers.getValueAtIndexOrDefault(this.getDataset().borderColor, index, this.chart.options.elements.rectangle.borderColor),+ borderWidth: rectangle.custom && rectangle.custom.borderWidth ? rectangle.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.rectangle.borderWidth)+ },++ draw: function () {++ var ctx = this._chart.ctx;+ var vm = this._view;++ var halfHeight = vm.height / 2,+ topY = vm.y - halfHeight,+ bottomY = vm.y + halfHeight,+ right = vm.base - (vm.base - vm.x),+ halfStroke = vm.borderWidth / 2;++ // Canvas doesn't allow us to stroke inside the width so we can+ // adjust the sizes to fit if we're setting a stroke on the line+ if (vm.borderWidth) {+ topY += halfStroke;+ bottomY -= halfStroke;+ right += halfStroke;+ }++ ctx.beginPath();++ ctx.fillStyle = vm.backgroundColor;+ ctx.strokeStyle = vm.borderColor;+ ctx.lineWidth = vm.borderWidth;++ // Corner points, from bottom-left to bottom-right clockwise+ // | 1 2 |+ // | 0 3 |+ var corners = [+ [vm.base, bottomY],+ [vm.base, topY],+ [right, topY],+ [right, bottomY]+ ];++ // Find first (starting) corner with fallback to 'bottom'+ var borders = ['bottom', 'left', 'top', 'right'];+ var startCorner = borders.indexOf(vm.borderSkipped, 0);+ if (startCorner === -1)+ startCorner = 0;++ function cornerAt(index) {+ return corners[(startCorner + index) % 4];+ }++ // Draw rectangle from 'startCorner'+ ctx.moveTo.apply(ctx, cornerAt(0));+ for (var i = 1; i < 4; i++)+ ctx.lineTo.apply(ctx, cornerAt(i));++ ctx.fill();+ if (vm.borderWidth) {+ ctx.stroke();+ }+ },++ inRange: function (mouseX, mouseY) {+ var vm = this._view;+ var inRange = false;++ if (vm) {+ if (vm.x < vm.base) {+ inRange = (mouseY >= vm.y - vm.height / 2 && mouseY <= vm.y + vm.height / 2) && (mouseX >= vm.x && mouseX <= vm.base);+ } else {+ inRange = (mouseY >= vm.y - vm.height / 2 && mouseY <= vm.y + vm.height / 2) && (mouseX >= vm.base && mouseX <= vm.x);+ }+ }++ return inRange;+ }+ });++ rectangle.pivot();+ },++ calculateBarBase: function (datasetIndex, index) {+ var meta = this.getMeta();+ var xScale = this.getScaleForId(meta.xAxisID);+ var yScale = this.getScaleForId(meta.yAxisID);++ var base = 0;++ if (xScale.options.stacked) {++ var value = this.chart.data.datasets[datasetIndex].data[index];++ if (value < 0) {+ for (var i = 0; i < datasetIndex; i++) {+ var negDS = this.chart.data.datasets[i];+ var negDSMeta = this.chart.getDatasetMeta(i);+ if (negDSMeta.bar && negDSMeta.xAxisID === xScale.id && this.chart.isDatasetVisible(i)) {+ base += negDS.data[index] < 0 ? negDS.data[index] : 0;+ }+ }+ } else {+ for (var j = 0; j < datasetIndex; j++) {+ var posDS = this.chart.data.datasets[j];+ var posDSMeta = this.chart.getDatasetMeta(j);+ if (posDSMeta.bar && posDSMeta.xAxisID === xScale.id && this.chart.isDatasetVisible(j)) {+ base += posDS.data[index] > 0 ? posDS.data[index] : 0;+ }+ }+ }++ return xScale.getPixelForValue(base);+ }++ base = xScale.getPixelForValue(xScale.min);++ if (xScale.beginAtZero || ((xScale.min <= 0 && xScale.max >= 0) || (xScale.min >= 0 && xScale.max <= 0))) {+ base = xScale.getPixelForValue(0, 0);+ } else if (xScale.min < 0 && xScale.max < 0) {+ // All values are negative. Use the right as the base+ base = xScale.getPixelForValue(xScale.max);+ }++ return base;+ },++ getRuler: function () {+ var meta = this.getMeta();+ var xScale = this.getScaleForId(meta.xAxisID);+ var yScale = this.getScaleForId(meta.yAxisID);+ var datasetCount = this.getBarCount();++ var tickHeight = (function () {+ var min = yScale.getPixelForTick(1) - yScale.getPixelForTick(0);+ for (var i = 2; i < this.getDataset().data.length; i++) {+ min = Math.min(yScale.getPixelForTick(i) - yScale.getPixelForTick(i - 1), min);+ }+ return min;+ }).call(this);+ var categoryHeight = tickHeight * yScale.options.categoryPercentage;+ var categorySpacing = (tickHeight - (tickHeight * yScale.options.categoryPercentage)) / 2;+ var fullBarHeight = categoryHeight / datasetCount;++ if (yScale.ticks.length !== this.chart.data.labels.length) {+ var perc = yScale.ticks.length / this.chart.data.labels.length;+ fullBarHeight = fullBarHeight * perc;+ }++ var barHeight = fullBarHeight * yScale.options.barPercentage;+ var barSpacing = fullBarHeight - (fullBarHeight * yScale.options.barPercentage);++ return {+ datasetCount: datasetCount,+ tickHeight: tickHeight,+ categoryHeight: categoryHeight,+ categorySpacing: categorySpacing,+ fullBarHeight: fullBarHeight,+ barHeight: barHeight,+ barSpacing: barSpacing,+ };+ },++ calculateBarHeight: function () {+ var yScale = this.getScaleForId(this.getMeta().yAxisID);+ var ruler = this.getRuler();+ return yScale.options.stacked ? ruler.categoryHeight : ruler.barHeight;+ },++ calculateBarX: function (index, datasetIndex) {+ var meta = this.getMeta();+ var xScale = this.getScaleForId(meta.xAxisID);+ var yScale = this.getScaleForId(meta.yAxisID);++ var value = this.getDataset().data[index];++ if (xScale.options.stacked) {++ var sumPos = 0,+ sumNeg = 0;++ for (var i = 0; i < datasetIndex; i++) {+ var ds = this.chart.data.datasets[i];+ var dsMeta = this.chart.getDatasetMeta(i);+ if (dsMeta.bar && dsMeta.xAxisID === xScale.id && this.chart.isDatasetVisible(i)) {+ if (ds.data[index] < 0) {+ sumNeg += ds.data[index] || 0;+ } else {+ sumPos += ds.data[index] || 0;+ }+ }+ }++ if (value < 0) {+ return xScale.getPixelForValue(sumNeg + value);+ } else {+ return xScale.getPixelForValue(sumPos + value);+ }+ }++ return xScale.getPixelForValue(value);+ },++ calculateBarY: function (index, datasetIndex) {+ var meta = this.getMeta();+ var yScale = this.getScaleForId(meta.yAxisID);+ var xScale = this.getScaleForId(meta.xAxisID);+ var barIndex = this.getBarIndex(datasetIndex);++ var ruler = this.getRuler();+ var topTick = yScale.getPixelForValue(null, index, datasetIndex, this.chart.isCombo);+ topTick -= this.chart.isCombo ? (ruler.tickHeight / 2) : 0;++ if (yScale.options.stacked) {+ return topTick + (ruler.categoryHeight / 2) + ruler.categorySpacing;+ }++ return topTick ++ (ruler.barHeight / 2) ++ ruler.categorySpacing ++ (ruler.barHeight * barIndex) ++ (ruler.barSpacing / 2) ++ (ruler.barSpacing * barIndex);+ }+ });};},{}],16:[function(require,module,exports){@@ -2118,11 +2418,9 @@ module.exports = function(Chart) {Chart.controllers.bubble = Chart.DatasetController.extend({addElements: function() {-- this.getDataset().metaData = this.getDataset().metaData || [];-+ var meta = this.getMeta();helpers.each(this.getDataset().data, function(value, index) {- this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Point({+ meta.data[index] = meta.data[index] || new Chart.elements.Point({_chart: this.chart.chart,_datasetIndex: this.index,_index: index@@ -2130,25 +2428,22 @@ module.exports = function(Chart) {}, this);},addElementAndReset: function(index) {- this.getDataset().metaData = this.getDataset().metaData || [];var point = new Chart.elements.Point({_chart: this.chart.chart,_datasetIndex: this.index,_index: index});- // Reset the point+ // Add to the points array and reset it+ this.getMeta().data.splice(index, 0, point);this.updateElement(point, index, true);-- // Add to the points array- this.getDataset().metaData.splice(index, 0, point);},update: function update(reset) {- var points = this.getDataset().metaData;-- var yScale = this.getScaleForId(this.getDataset().yAxisID);- var xScale = this.getScaleForId(this.getDataset().xAxisID);+ var meta = this.getMeta();+ var points = meta.data;+ var yScale = this.getScaleForId(meta.yAxisID);+ var xScale = this.getScaleForId(meta.xAxisID);var scaleBase;if (yScale.min < 0 && yScale.max < 0) {@@ -2167,8 +2462,9 @@ module.exports = function(Chart) {},updateElement: function(point, index, reset) {- var yScale = this.getScaleForId(this.getDataset().yAxisID);- var xScale = this.getScaleForId(this.getDataset().xAxisID);+ var meta = this.getMeta();+ var yScale = this.getScaleForId(meta.yAxisID);+ var xScale = this.getScaleForId(meta.xAxisID);var scaleBase;if (yScale.min < 0 && yScale.max < 0) {@@ -2215,7 +2511,7 @@ module.exports = function(Chart) {var easingDecimal = ease || 1;// Transition and Draw the Points- helpers.each(this.getDataset().metaData, function(point, index) {+ helpers.each(this.getMeta().data, function(point, index) {point.transition(easingDecimal);point.draw();});@@ -2268,11 +2564,11 @@ module.exports = function(Chart) {if (chart.data.datasets.length) {for (var i = 0; i < chart.data.datasets[0].data.length; ++i) {- text.push('<li><span style="background-color:' + chart.data.datasets[0].backgroundColor[i] + '">');+ text.push('<li><span style="background-color:' + chart.data.datasets[0].backgroundColor[i] + '"></span>');if (chart.data.labels[i]) {text.push(chart.data.labels[i]);}- text.push('</span></li>');+ text.push('</li>');}}@@ -2281,37 +2577,45 @@ module.exports = function(Chart) {},legend: {labels: {- generateLabels: function(data) {+ generateLabels: function(chart) {+ var data = chart.data;if (data.labels.length && data.datasets.length) {return data.labels.map(function(label, i) {+ var meta = chart.getDatasetMeta(0);+ var ds = data.datasets[0];+ var arc = meta.data[i];+ var fill = arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(ds.backgroundColor, i, this.chart.options.elements.arc.backgroundColor);+ var stroke = arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(ds.borderColor, i, this.chart.options.elements.arc.borderColor);+ var bw = arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(ds.borderWidth, i, this.chart.options.elements.arc.borderWidth);+return {text: label,- fillStyle: data.datasets[0].backgroundColor[i],- hidden: isNaN(data.datasets[0].data[i]),+ fillStyle: fill,+ strokeStyle: stroke,+ lineWidth: bw,+ hidden: isNaN(ds.data[i]) || meta.data[i].hidden,// Extra data used for toggling the correct itemindex: i};- });+ }, this);} else {return [];}}},+onClick: function(e, legendItem) {- helpers.each(this.chart.data.datasets, function(dataset) {- dataset.metaHiddenData = dataset.metaHiddenData || [];- var idx = legendItem.index;-- if (!isNaN(dataset.data[idx])) {- dataset.metaHiddenData[idx] = dataset.data[idx];- dataset.data[idx] = NaN;- } else if (!isNaN(dataset.metaHiddenData[idx])) {- dataset.data[idx] = dataset.metaHiddenData[idx];- }- });+ var index = legendItem.index;+ var chart = this.chart;+ var i, ilen, meta;- this.chart.update();+ for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) {+ meta = chart.getDatasetMeta(i);+ meta.data[index].hidden = !meta.data[index].hidden;+ }++ chart.update();}},@@ -2349,17 +2653,17 @@ module.exports = function(Chart) {},addElements: function() {- this.getDataset().metaData = this.getDataset().metaData || [];+ var meta = this.getMeta();helpers.each(this.getDataset().data, function(value, index) {- this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Arc({+ meta.data[index] = meta.data[index] || new Chart.elements.Arc({_chart: this.chart.chart,_datasetIndex: this.index,_index: index});}, this);},+addElementAndReset: function(index, colorForNewElement) {- this.getDataset().metaData = this.getDataset().metaData || [];var arc = new Chart.elements.Arc({_chart: this.chart.chart,_datasetIndex: this.index,@@ -2370,17 +2674,9 @@ module.exports = function(Chart) {this.getDataset().backgroundColor.splice(index, 0, colorForNewElement);}- // Reset the point+ // Add to the points array and reset it+ this.getMeta().data.splice(index, 0, arc);this.updateElement(arc, index, true);-- // Add to the points array- this.getDataset().metaData.splice(index, 0, arc);- },-- getVisibleDatasetCount: function getVisibleDatasetCount() {- return helpers.where(this.chart.data.datasets, function(ds) {- return helpers.isDatasetVisible(ds);- }).length;},// Get index of the dataset in relation to the visible datasets. This allows determining the inner and outer radius correctly@@ -2388,7 +2684,7 @@ module.exports = function(Chart) {var ringIndex = 0;for (var j = 0; j < datasetIndex; ++j) {- if (helpers.isDatasetVisible(this.chart.data.datasets[j])) {+ if (this.chart.isDatasetVisible(j)) {++ringIndex;}}@@ -2403,7 +2699,7 @@ module.exports = function(Chart) {var offset = {x: 0, y: 0};// If the chart's circumference isn't a full circle, calculate minSize as a ratio of the width/height of the arc- if (this.chart.options.circumference && this.chart.options.circumference < Math.PI * 2.0) {+ if (this.chart.options.circumference < Math.PI * 2.0) {var startAngle = this.chart.options.rotation % (Math.PI * 2.0);startAngle += Math.PI * 2.0 * (startAngle >= Math.PI ? -1 : startAngle < -Math.PI ? 1 : 0);var endAngle = startAngle + this.chart.options.circumference;@@ -2423,30 +2719,26 @@ module.exports = function(Chart) {this.chart.outerRadius = Math.max(minSize / 2, 0);this.chart.innerRadius = Math.max(this.chart.options.cutoutPercentage ? (this.chart.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1, 0);- this.chart.radiusLength = (this.chart.outerRadius - this.chart.innerRadius) / this.getVisibleDatasetCount();+ this.chart.radiusLength = (this.chart.outerRadius - this.chart.innerRadius) / this.chart.getVisibleDatasetCount();this.chart.offsetX = offset.x * this.chart.outerRadius;this.chart.offsetY = offset.y * this.chart.outerRadius;- this.getDataset().total = 0;- helpers.each(this.getDataset().data, function(value) {- if (!isNaN(value)) {- this.getDataset().total += Math.abs(value);- }- }, this);+ this.getMeta().total = this.calculateTotal();this.outerRadius = this.chart.outerRadius - (this.chart.radiusLength * this.getRingIndex(this.index));this.innerRadius = this.outerRadius - this.chart.radiusLength;- helpers.each(this.getDataset().metaData, function(arc, index) {+ helpers.each(this.getMeta().data, function(arc, index) {this.updateElement(arc, index, reset);}, this);},+updateElement: function(arc, index, reset) {var centerX = (this.chart.chartArea.left + this.chart.chartArea.right) / 2;var centerY = (this.chart.chartArea.top + this.chart.chartArea.bottom) / 2;- var startAngle = this.chart.options.rotation || (Math.PI * -0.5); // non reset case handled later- var endAngle = this.chart.options.rotation || (Math.PI * -0.5); // non reset case handled later- var circumference = reset && this.chart.options.animation.animateRotate ? 0 : this.calculateCircumference(this.getDataset().data[index]) * ((this.chart.options.circumference || (2.0 * Math.PI)) / (2.0 * Math.PI));+ var startAngle = this.chart.options.rotation; // non reset case handled later+ var endAngle = this.chart.options.rotation; // non reset case handled later+ var circumference = reset && this.chart.options.animation.animateRotate ? 0 : arc.hidden? 0 : this.calculateCircumference(this.getDataset().data[index]) * (this.chart.options.circumference / (2.0 * Math.PI));var innerRadius = reset && this.chart.options.animation.animateScale ? 0 : this.innerRadius;var outerRadius = reset && this.chart.options.animation.animateScale ? 0 : this.outerRadius;@@ -2476,12 +2768,12 @@ module.exports = function(Chart) {});// Set correct angles if not resetting- if (!reset) {+ if (!reset || !this.chart.options.animation.animateRotate) {if (index === 0) {- arc._model.startAngle = this.chart.options.rotation || (Math.PI * -0.5);+ arc._model.startAngle = this.chart.options.rotation;} else {- arc._model.startAngle = this.getDataset().metaData[index - 1]._model.endAngle;+ arc._model.startAngle = this.getMeta().data[index - 1]._model.endAngle;}arc._model.endAngle = arc._model.startAngle + arc._model.circumference;@@ -2492,7 +2784,7 @@ module.exports = function(Chart) {draw: function(ease) {var easingDecimal = ease || 1;- helpers.each(this.getDataset().metaData, function(arc, index) {+ helpers.each(this.getMeta().data, function(arc, index) {arc.transition(easingDecimal).draw();});},@@ -2515,15 +2807,33 @@ module.exports = function(Chart) {arc._model.borderWidth = arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth);},+ calculateTotal: function() {+ var dataset = this.getDataset();+ var meta = this.getMeta();+ var total = 0;+ var value;++ helpers.each(meta.data, function(element, index) {+ value = dataset.data[index];+ if (!isNaN(value) && !element.hidden) {+ total += Math.abs(value);+ }+ });++ return total;+ },+calculateCircumference: function(value) {- if (this.getDataset().total > 0 && !isNaN(value)) {- return (Math.PI * 1.999999) * (value / this.getDataset().total);+ var total = this.getMeta().total;+ if (total > 0 && !isNaN(value)) {+ return (Math.PI * 2.0) * (value / total);} else {return 0;}}});};+},{}],18:[function(require,module,exports){"use strict";@@ -2553,48 +2863,45 @@ module.exports = function(Chart) {Chart.controllers.line = Chart.DatasetController.extend({addElements: function() {-- this.getDataset().metaData = this.getDataset().metaData || [];-- this.getDataset().metaDataset = this.getDataset().metaDataset || new Chart.elements.Line({+ var meta = this.getMeta();+ meta.dataset = meta.dataset || new Chart.elements.Line({_chart: this.chart.chart,_datasetIndex: this.index,- _points: this.getDataset().metaData+ _points: meta.data});helpers.each(this.getDataset().data, function(value, index) {- this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Point({+ meta.data[index] = meta.data[index] || new Chart.elements.Point({_chart: this.chart.chart,_datasetIndex: this.index,_index: index});}, this);},+addElementAndReset: function(index) {- this.getDataset().metaData = this.getDataset().metaData || [];var point = new Chart.elements.Point({_chart: this.chart.chart,_datasetIndex: this.index,_index: index});- // Reset the point+ // Add to the points array and reset it+ this.getMeta().data.splice(index, 0, point);this.updateElement(point, index, true);- // Add to the points array- this.getDataset().metaData.splice(index, 0, point);-// Make sure bezier control points are updatedif (this.chart.options.showLines && this.chart.options.elements.line.tension !== 0)this.updateBezierControlPoints();},update: function update(reset) {- var line = this.getDataset().metaDataset;- var points = this.getDataset().metaData;+ var meta = this.getMeta();+ var line = meta.dataset;+ var points = meta.data;- var yScale = this.getScaleForId(this.getDataset().yAxisID);- var xScale = this.getScaleForId(this.getDataset().xAxisID);+ var yScale = this.getScaleForId(meta.yAxisID);+ var xScale = this.getScaleForId(meta.xAxisID);var scaleBase;if (yScale.min < 0 && yScale.max < 0) {@@ -2613,9 +2920,16 @@ module.exports = function(Chart) {// Dataline._children = points;// Model++ // Compatibility: If the properties are defined with only the old name, use those values+ if ((this.getDataset().tension !== undefined) && (this.getDataset().lineTension === undefined))+ {+ this.getDataset().lineTension = this.getDataset().tension;+ }+line._model = {// Appearance- tension: line.custom && line.custom.tension ? line.custom.tension : helpers.getValueOrDefault(this.getDataset().tension, this.chart.options.elements.line.tension),+ tension: line.custom && line.custom.tension ? line.custom.tension : helpers.getValueOrDefault(this.getDataset().lineTension, this.chart.options.elements.line.tension),backgroundColor: line.custom && line.custom.backgroundColor ? line.custom.backgroundColor : (this.getDataset().backgroundColor || this.chart.options.elements.line.backgroundColor),borderWidth: line.custom && line.custom.borderWidth ? line.custom.borderWidth : (this.getDataset().borderWidth || this.chart.options.elements.line.borderWidth),borderColor: line.custom && line.custom.borderColor ? line.custom.borderColor : (this.getDataset().borderColor || this.chart.options.elements.line.borderColor),@@ -2685,8 +2999,9 @@ module.exports = function(Chart) {},updateElement: function(point, index, reset) {- var yScale = this.getScaleForId(this.getDataset().yAxisID);- var xScale = this.getScaleForId(this.getDataset().xAxisID);+ var meta = this.getMeta();+ var yScale = this.getScaleForId(meta.yAxisID);+ var xScale = this.getScaleForId(meta.xAxisID);var scaleBase;if (yScale.min < 0 && yScale.max < 0) {@@ -2705,27 +3020,37 @@ module.exports = function(Chart) {point._index = index;// Desired view properties++ // Compatibility: If the properties are defined with only the old name, use those values+ if ((this.getDataset().radius !== undefined) && (this.getDataset().pointRadius === undefined))+ {+ this.getDataset().pointRadius = this.getDataset().radius;+ }+ if ((this.getDataset().hitRadius !== undefined) && (this.getDataset().pointHitRadius === undefined))+ {+ this.getDataset().pointHitRadius = this.getDataset().hitRadius;+ }+point._model = {x: xScale.getPixelForValue(this.getDataset().data[index], index, this.index, this.chart.isCombo),y: reset ? scaleBase : this.calculatePointY(this.getDataset().data[index], index, this.index, this.chart.isCombo),// Appearance- tension: point.custom && point.custom.tension ? point.custom.tension : helpers.getValueOrDefault(this.getDataset().tension, this.chart.options.elements.line.tension),- radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius),+ radius: point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().pointRadius, index, this.chart.options.elements.point.radius),pointStyle: point.custom && point.custom.pointStyle ? point.custom.pointStyle : helpers.getValueAtIndexOrDefault(this.getDataset().pointStyle, index, this.chart.options.elements.point.pointStyle),backgroundColor: this.getPointBackgroundColor(point, index),borderColor: this.getPointBorderColor(point, index),borderWidth: this.getPointBorderWidth(point, index),// Tooltip- hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().hitRadius, index, this.chart.options.elements.point.hitRadius)+ hitRadius: point.custom && point.custom.hitRadius ? point.custom.hitRadius : helpers.getValueAtIndexOrDefault(this.getDataset().pointHitRadius, index, this.chart.options.elements.point.hitRadius)};point._model.skip = point.custom && point.custom.skip ? point.custom.skip : (isNaN(point._model.x) || isNaN(point._model.y));},calculatePointY: function(value, index, datasetIndex, isCombo) {-- var xScale = this.getScaleForId(this.getDataset().xAxisID);- var yScale = this.getScaleForId(this.getDataset().yAxisID);+ var meta = this.getMeta();+ var xScale = this.getScaleForId(meta.xAxisID);+ var yScale = this.getScaleForId(meta.yAxisID);if (yScale.options.stacked) {@@ -2734,7 +3059,8 @@ module.exports = function(Chart) {for (var i = 0; i < datasetIndex; i++) {var ds = this.chart.data.datasets[i];- if (ds.type === 'line' && helpers.isDatasetVisible(ds)) {+ var dsMeta = this.chart.getDatasetMeta(i);+ if (dsMeta.type === 'line' && this.chart.isDatasetVisible(i)) {if (ds.data[index] < 0) {sumNeg += ds.data[index] || 0;} else {@@ -2755,12 +3081,13 @@ module.exports = function(Chart) {updateBezierControlPoints: function() {// Update bezier control points- helpers.each(this.getDataset().metaData, function(point, index) {+ var meta = this.getMeta();+ helpers.each(meta.data, function(point, index) {var controlPoints = helpers.splineCurve(- helpers.previousItem(this.getDataset().metaData, index)._model,+ helpers.previousItem(meta.data, index)._model,point._model,- helpers.nextItem(this.getDataset().metaData, index)._model,- point._model.tension+ helpers.nextItem(meta.data, index)._model,+ meta.dataset._model.tension);// Prevent the bezier going outside of the bounds of the graph@@ -2776,19 +3103,20 @@ module.exports = function(Chart) {},draw: function(ease) {+ var meta = this.getMeta();var easingDecimal = ease || 1;// Transition Point Locations- helpers.each(this.getDataset().metaData, function(point) {+ helpers.each(meta.data, function(point) {point.transition(easingDecimal);});// Transition and Draw the lineif (this.chart.options.showLines)- this.getDataset().metaDataset.transition(easingDecimal).draw();+ meta.dataset.transition(easingDecimal).draw();// Draw the points- helpers.each(this.getDataset().metaData, function(point) {+ helpers.each(meta.data, function(point) {point.draw();});},@@ -2808,7 +3136,13 @@ module.exports = function(Chart) {var dataset = this.chart.data.datasets[point._datasetIndex];var index = point._index;- point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().radius, index, this.chart.options.elements.point.radius);+ // Compatibility: If the properties are defined with only the old name, use those values+ if ((this.getDataset().radius !== undefined) && (this.getDataset().pointRadius === undefined))+ {+ this.getDataset().pointRadius = this.getDataset().radius;+ }++ point._model.radius = point.custom && point.custom.radius ? point.custom.radius : helpers.getValueAtIndexOrDefault(this.getDataset().pointRadius, index, this.chart.options.elements.point.radius);point._model.backgroundColor = this.getPointBackgroundColor(point, index);point._model.borderColor = this.getPointBorderColor(point, index);point._model.borderWidth = this.getPointBorderWidth(point, index);@@ -2831,8 +3165,10 @@ module.exports = function(Chart) {},//Boolean - Whether to animate the rotation of the chart- animateRotate: true,- animateScale: true,+ animation: {+ animateRotate: true,+ animateScale: true+ },aspectRatio: 1,legendCallback: function(chart) {@@ -2854,37 +3190,45 @@ module.exports = function(Chart) {},legend: {labels: {- generateLabels: function(data) {+ generateLabels: function(chart) {+ var data = chart.data;if (data.labels.length && data.datasets.length) {return data.labels.map(function(label, i) {+ var meta = chart.getDatasetMeta(0);+ var ds = data.datasets[0];+ var arc = meta.data[i];+ var fill = arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(ds.backgroundColor, i, this.chart.options.elements.arc.backgroundColor);+ var stroke = arc.custom && arc.custom.borderColor ? arc.custom.borderColor : helpers.getValueAtIndexOrDefault(ds.borderColor, i, this.chart.options.elements.arc.borderColor);+ var bw = arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(ds.borderWidth, i, this.chart.options.elements.arc.borderWidth);+return {text: label,- fillStyle: data.datasets[0].backgroundColor[i],- hidden: isNaN(data.datasets[0].data[i]),+ fillStyle: fill,+ strokeStyle: stroke,+ lineWidth: bw,+ hidden: isNaN(ds.data[i]) || meta.data[i].hidden,// Extra data used for toggling the correct itemindex: i};- });+ }, this);} else {return [];}}},+onClick: function(e, legendItem) {- helpers.each(this.chart.data.datasets, function(dataset) {- dataset.metaHiddenData = dataset.metaHiddenData || [];- var idx = legendItem.index;-- if (!isNaN(dataset.data[idx])) {- dataset.metaHiddenData[idx] = dataset.data[idx];- dataset.data[idx] = NaN;- } else if (!isNaN(dataset.metaHiddenData[idx])) {- dataset.data[idx] = dataset.metaHiddenData[idx];- }- });+ var index = legendItem.index;+ var chart = this.chart;+ var i, ilen, meta;- this.chart.update();+ for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) {+ meta = chart.getDatasetMeta(i);+ meta.data[index].hidden = !meta.data[index].hidden;+ }++ chart.update();}},@@ -2905,51 +3249,43 @@ module.exports = function(Chart) {linkScales: function() {// no scales for doughnut},+addElements: function() {- this.getDataset().metaData = this.getDataset().metaData || [];+ var meta = this.getMeta();helpers.each(this.getDataset().data, function(value, index) {- this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Arc({+ meta.data[index] = meta.data[index] || new Chart.elements.Arc({_chart: this.chart.chart,_datasetIndex: this.index,_index: index});}, this);},+addElementAndReset: function(index) {- this.getDataset().metaData = this.getDataset().metaData || [];var arc = new Chart.elements.Arc({_chart: this.chart.chart,_datasetIndex: this.index,_index: index});- // Reset the point+ // Add to the points array and reset it+ this.getMeta().data.splice(index, 0, arc);this.updateElement(arc, index, true);-- // Add to the points array- this.getDataset().metaData.splice(index, 0, arc);- },- getVisibleDatasetCount: function getVisibleDatasetCount() {- return helpers.where(this.chart.data.datasets, function(ds) {- return helpers.isDatasetVisible(ds);- }).length;},update: function update(reset) {+ var meta = this.getMeta();var minSize = Math.min(this.chart.chartArea.right - this.chart.chartArea.left, this.chart.chartArea.bottom - this.chart.chartArea.top);this.chart.outerRadius = Math.max((minSize - this.chart.options.elements.arc.borderWidth / 2) / 2, 0);this.chart.innerRadius = Math.max(this.chart.options.cutoutPercentage ? (this.chart.outerRadius / 100) * (this.chart.options.cutoutPercentage) : 1, 0);- this.chart.radiusLength = (this.chart.outerRadius - this.chart.innerRadius) / this.getVisibleDatasetCount();-- this.getDataset().total = 0;- helpers.each(this.getDataset().data, function(value) {- this.getDataset().total += Math.abs(value);- }, this);+ this.chart.radiusLength = (this.chart.outerRadius - this.chart.innerRadius) / this.chart.getVisibleDatasetCount();this.outerRadius = this.chart.outerRadius - (this.chart.radiusLength * this.index);this.innerRadius = this.outerRadius - this.chart.radiusLength;- helpers.each(this.getDataset().metaData, function(arc, index) {+ meta.count = this.countVisibleElements();++ helpers.each(meta.data, function(arc, index) {this.updateElement(arc, index, reset);}, this);},@@ -2961,23 +3297,25 @@ module.exports = function(Chart) {// If there is NaN data before us, we need to calculate the starting angle correctly.// We could be way more efficient here, but its unlikely that the polar area chart will have a lot of data- var notNullIndex = 0;+ var visibleCount = 0;+ var meta = this.getMeta();for (var i = 0; i < index; ++i) {- if (!isNaN(this.getDataset().data[i])) {- ++notNullIndex;+ if (!isNaN(this.getDataset().data[i]) && !meta.data[i].hidden) {+ ++visibleCount;}}- var startAngle = (-0.5 * Math.PI) + (circumference * notNullIndex);- var endAngle = startAngle + circumference;+ var distance = arc.hidden? 0 : this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]);+ var startAngle = (-0.5 * Math.PI) + (circumference * visibleCount);+ var endAngle = startAngle + (arc.hidden? 0 : circumference);var resetModel = {x: centerX,y: centerY,innerRadius: 0,- outerRadius: this.chart.options.animateScale ? 0 : this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]),- startAngle: this.chart.options.animateRotate ? Math.PI * -0.5 : startAngle,- endAngle: this.chart.options.animateRotate ? Math.PI * -0.5 : endAngle,+ outerRadius: this.chart.options.animation.animateScale ? 0 : this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]),+ startAngle: this.chart.options.animation.animateRotate ? Math.PI * -0.5 : startAngle,+ endAngle: this.chart.options.animation.animateRotate ? Math.PI * -0.5 : endAngle,backgroundColor: arc.custom && arc.custom.backgroundColor ? arc.custom.backgroundColor : helpers.getValueAtIndexOrDefault(this.getDataset().backgroundColor, index, this.chart.options.elements.arc.backgroundColor),borderWidth: arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth),@@ -2998,7 +3336,7 @@ module.exports = function(Chart) {x: centerX,y: centerY,innerRadius: 0,- outerRadius: this.chart.scale.getDistanceFromCenterForValue(this.getDataset().data[index]),+ outerRadius: distance,startAngle: startAngle,endAngle: endAngle,@@ -3015,7 +3353,7 @@ module.exports = function(Chart) {draw: function(ease) {var easingDecimal = ease || 1;- helpers.each(this.getDataset().metaData, function(arc, index) {+ helpers.each(this.getMeta().data, function(arc, index) {arc.transition(easingDecimal).draw();});},@@ -3038,21 +3376,31 @@ module.exports = function(Chart) {arc._model.borderWidth = arc.custom && arc.custom.borderWidth ? arc.custom.borderWidth : helpers.getValueAtIndexOrDefault(this.getDataset().borderWidth, index, this.chart.options.elements.arc.borderWidth);},+ countVisibleElements: function() {+ var dataset = this.getDataset();+ var meta = this.getMeta();+ var count = 0;++ helpers.each(meta.data, function(element, index) {+ if (!isNaN(dataset.data[index]) && !element.hidden) {+ count++;+ }+ });++ return count;+ },+calculateCircumference: function(value) {- if (isNaN(value)) {- return 0;+ var count = this.getMeta().count;+ if (count > 0 && !isNaN(value)) {+ return (2 * Math.PI) / count;} else {- // Count the number of NaN values- var numNaN = helpers.where(this.getDataset().data, function(data) {- return isNaN(data);- }).length;-- return (2 * Math.PI) / (this.getDataset().data.length - numNaN);+ return 0;}}});-};+},{}],20:[function(require,module,exports){"use strict";@@ -3078,18 +3426,17 @@ module.exports = function(Chart) {},addElements: function() {+ var meta = this.getMeta();- this.getDataset().metaData = this.getDataset().metaData || [];-- this.getDataset().metaDataset = this.getDataset().metaDataset || new Chart.elements.Line({+ meta.dataset = meta.dataset || new Chart.elements.Line({_chart: this.chart.chart,_datasetIndex: this.index,- _points: this.getDataset().metaData,+ _points: meta.data,_loop: true});helpers.each(this.getDataset().data, function(value, index) {- this.getDataset().metaData[index] = this.getDataset().metaData[index] || new Chart.elements.Point({+ meta.data[index] = meta.data[index] || new Chart.elements.Point({_chart: this.chart.chart,_datasetIndex: this.index,_index: index,@@ -3101,27 +3448,24 @@ module.exports = function(Chart) {}, this);},addElementAndReset: function(index) {- this.getDataset().metaData = this.getDataset().metaData || [];var point = new Chart.elements.Point({_chart: this.chart.chart,_datasetIndex: this.index,_index: index});- // Reset the point+ // Add to the points array and reset it+ this.getMeta().data.splice(index, 0, point);this.updateElement(point, index, true);- // Add to the points array- this.getDataset().metaData.splice(index, 0, point);-// Make sure bezier control points are updatedthis.updateBezierControlPoints();},update: function update(reset) {-- var line = this.getDataset().metaDataset;- var points = this.getDataset().metaData;+ var meta = this.getMeta();+ var line = meta.dataset;+ var points = meta.data;var scale = this.chart.scale;var scaleBase;@@ -3134,15 +3478,21 @@ module.exports = function(Chart) {scaleBase = scale.getPointPositionForValue(0, 0);}- helpers.extend(this.getDataset().metaDataset, {+ // Compatibility: If the properties are defined with only the old name, use those values+ if ((this.getDataset().tension !== undefined) && (this.getDataset().lineTension === undefined))+ {+ this.getDataset().lineTension = this.getDataset().tension;+ }++ helpers.extend(meta.dataset, {// Utility_datasetIndex: this.index,// Data- _children: this.getDataset().metaData,+ _children: points,// Model_model: {// Appearance- tension: line.custom && line.custom.tension ? line.custom.tension : helpers.getValueOrDefault(this.getDataset().tension, this.chart.options.elements.line.tension),+ tension: line.custom && line.custom.tension ? line.custom.tension : helpers.getValueOrDefault(this.getDataset().lineTension, this.chart.options.elements.line.tension),backgroundColor: line.custom && line.custom.backgroundColor ? line.custom.backgroundColor : (this.getDataset().backgroundColor || this.chart.options.elements.line.backgroundColor),borderWidth: line.custom && line.custom.borderWidth ? line.custom.borderWidth : (this.getDataset().borderWidth || this.chart.options.elements.line.borderWidth),borderColor: line.custom && line.custom.borderColor ? line.custom.borderColor : (this.getDataset().borderColor || this.chart.options.elements.line.borderColor),@@ -3159,7 +3509,7 @@ module.exports = function(Chart) {}});- this.getDataset().metaDataset.pivot();+ meta.dataset.pivot();// Update Pointshelpers.each(points, function(point, index) {@@ -3200,11 +3550,12 @@ module.exports = function(Chart) {point._model.skip = point.custom && point.custom.skip ? point.custom.skip : (isNaN(point._model.x) || isNaN(point._model.y));},updateBezierControlPoints: function() {- helpers.each(this.getDataset().metaData, function(point, index) {+ var meta = this.getMeta();+ helpers.each(meta.data, function(point, index) {var controlPoints = helpers.splineCurve(- helpers.previousItem(this.getDataset().metaData, index, true)._model,+ helpers.previousItem(meta.data, index, true)._model,point._model,- helpers.nextItem(this.getDataset().metaData, index, true)._model,+ helpers.nextItem(meta.data, index, true)._model,point._model.tension);@@ -3221,18 +3572,19 @@ module.exports = function(Chart) {},draw: function(ease) {+ var meta = this.getMeta();var easingDecimal = ease || 1;// Transition Point Locations- helpers.each(this.getDataset().metaData, function(point, index) {+ helpers.each(meta.data, function(point, index) {point.transition(easingDecimal);});// Transition and Draw the line- this.getDataset().metaDataset.transition(easingDecimal).draw();+ meta.dataset.transition(easingDecimal).draw();// Draw the points- helpers.each(this.getDataset().metaData, function(point) {+ helpers.each(meta.data, function(point) {point.draw();});},@@ -3435,9 +3787,8 @@ module.exports = function(Chart) {helpers.extend(Chart.Controller.prototype, {initialize: function initialize() {-- // TODO- // If BeforeInit(this) doesn't return false, proceed+ // Before init plugin notification+ Chart.pluginService.notifyPlugins('beforeInit', [this]);this.bindEvents();@@ -3452,8 +3803,8 @@ module.exports = function(Chart) {this.initToolTip();this.update();- // TODO- // If AfterInit(this) doesn't return false, proceed+ // After init plugin notification+ Chart.pluginService.notifyPlugins('afterInit', [this]);return this;},@@ -3601,18 +3952,18 @@ module.exports = function(Chart) {var newControllers = [];helpers.each(this.data.datasets, function(dataset, datasetIndex) {- if (!dataset.type) {- dataset.type = this.config.type;+ var meta = this.getDatasetMeta(datasetIndex);+ if (!meta.type) {+ meta.type = dataset.type || this.config.type;}- var type = dataset.type;- types.push(type);+ types.push(meta.type);- if (dataset.controller) {- dataset.controller.updateIndex(datasetIndex);+ if (meta.controller) {+ meta.controller.updateIndex(datasetIndex);} else {- dataset.controller = new Chart.controllers[type](this, datasetIndex);- newControllers.push(dataset.controller);+ meta.controller = new Chart.controllers[meta.type](this, datasetIndex);+ newControllers.push(meta.controller);}}, this);@@ -3630,17 +3981,24 @@ module.exports = function(Chart) {resetElements: function resetElements() {helpers.each(this.data.datasets, function(dataset, datasetIndex) {- dataset.controller.reset();- });+ this.getDatasetMeta(datasetIndex).controller.reset();+ }, this);},update: function update(animationDuration, lazy) {+ Chart.pluginService.notifyPlugins('beforeUpdate', [this]);+// In case the entire data object changedthis.tooltip._data = this.data;// Make sure dataset controllers are updated and new controllers are resetvar newControllers = this.buildOrUpdateControllers();+ // Make sure all dataset controllers have correct meta data counts+ helpers.each(this.data.datasets, function(dataset, datasetIndex) {+ this.getDatasetMeta(datasetIndex).controller.buildOrUpdateElements();+ }, this);+Chart.layoutService.update(this, this.chart.width, this.chart.height);// Can only reset the new controllers after the scales have been updated@@ -3648,19 +4006,18 @@ module.exports = function(Chart) {controller.reset();});- // Make sure all dataset controllers have correct meta data counts- helpers.each(this.data.datasets, function(dataset, datasetIndex) {- dataset.controller.buildOrUpdateElements();- });-// This will loop through any data and do the appropriate element update for the typehelpers.each(this.data.datasets, function(dataset, datasetIndex) {- dataset.controller.update();- });+ this.getDatasetMeta(datasetIndex).controller.update();+ }, this);+this.render(animationDuration, lazy);++ Chart.pluginService.notifyPlugins('afterUpdate', [this]);},render: function render(duration, lazy) {+ Chart.pluginService.notifyPlugins('beforeRender', [this]);if (this.options.animation && ((typeof duration !== 'undefined' && duration !== 0) || (typeof duration === 'undefined' && this.options.animation.duration !== 0))) {var animation = new Chart.Animation();@@ -3694,6 +4051,8 @@ module.exports = function(Chart) {var easingDecimal = ease || 1;this.clear();+ Chart.pluginService.notifyPlugins('beforeDraw', [this, easingDecimal]);+// Draw all the scaleshelpers.each(this.boxes, function(box) {box.draw(this.chartArea);@@ -3710,35 +4069,37 @@ module.exports = function(Chart) {// Draw each dataset via its respective controller (reversed to support proper line stacking)helpers.each(this.data.datasets, function(dataset, datasetIndex) {- if (helpers.isDatasetVisible(dataset)) {- dataset.controller.draw(ease);+ if (this.isDatasetVisible(datasetIndex)) {+ this.getDatasetMeta(datasetIndex).controller.draw(ease);}- }, null, true);+ }, this, true);// Restore from the clipping operationthis.chart.ctx.restore();// Finally draw the tooltipthis.tooltip.transition(easingDecimal).draw();++ Chart.pluginService.notifyPlugins('afterDraw', [this, easingDecimal]);},// Get the single element that was clicked on// @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was drawgetElementAtEvent: function(e) {-var eventPosition = helpers.getRelativePosition(e, this.chart);var elementsArray = [];helpers.each(this.data.datasets, function(dataset, datasetIndex) {- if (helpers.isDatasetVisible(dataset)) {- helpers.each(dataset.metaData, function(element, index) {+ if (this.isDatasetVisible(datasetIndex)) {+ var meta = this.getDatasetMeta(datasetIndex);+ helpers.each(meta.data, function(element, index) {if (element.inRange(eventPosition.x, eventPosition.y)) {elementsArray.push(element);return elementsArray;}});}- });+ }, this);return elementsArray;},@@ -3750,10 +4111,11 @@ module.exports = function(Chart) {var found = (function() {if (this.data.datasets) {for (var i = 0; i < this.data.datasets.length; i++) {- if (helpers.isDatasetVisible(this.data.datasets[i])) {- for (var j = 0; j < this.data.datasets[i].metaData.length; j++) {- if (this.data.datasets[i].metaData[j].inRange(eventPosition.x, eventPosition.y)) {- return this.data.datasets[i].metaData[j];+ var meta = this.getDatasetMeta(i);+ if (this.isDatasetVisible(i)) {+ for (var j = 0; j < meta.data.length; j++) {+ if (meta.data[j].inRange(eventPosition.x, eventPosition.y)) {+ return meta.data[j];}}}@@ -3765,11 +4127,12 @@ module.exports = function(Chart) {return elementsArray;}- helpers.each(this.data.datasets, function(dataset, dsIndex) {- if (helpers.isDatasetVisible(dataset)) {- elementsArray.push(dataset.metaData[found._index]);+ helpers.each(this.data.datasets, function(dataset, datasetIndex) {+ if (this.isDatasetVisible(datasetIndex)) {+ var meta = this.getDatasetMeta(datasetIndex);+ elementsArray.push(meta.data[found._index]);}- });+ }, this);return elementsArray;},@@ -3778,12 +4141,52 @@ module.exports = function(Chart) {var elementsArray = this.getElementAtEvent(e);if (elementsArray.length > 0) {- elementsArray = this.data.datasets[elementsArray[0]._datasetIndex].metaData;+ elementsArray = this.getDatasetMeta(elementsArray[0]._datasetIndex).data;}return elementsArray;},+ getDatasetMeta: function(datasetIndex) {+ var dataset = this.data.datasets[datasetIndex];+ if (!dataset._meta) {+ dataset._meta = {};+ }++ var meta = dataset._meta[this.id];+ if (!meta) {+ meta = dataset._meta[this.id] = {+ type: null,+ data: [],+ dataset: null,+ controller: null,+ hidden: null, // See isDatasetVisible() comment+ xAxisID: null,+ yAxisID: null+ };+ }++ return meta;+ },++ getVisibleDatasetCount: function() {+ var count = 0;+ for (var i = 0, ilen = this.data.datasets.length; i<ilen; ++i) {+ if (this.isDatasetVisible(i)) {+ count++;+ }+ }+ return count;+ },++ isDatasetVisible: function(datasetIndex) {+ var meta = this.getDatasetMeta(datasetIndex);++ // meta.hidden is a per chart dataset hidden flag override with 3 states: if true or false,+ // the dataset.hidden value is ignored, else if null, the dataset hidden state is returned.+ return typeof meta.hidden === 'boolean'? !meta.hidden : !this.data.datasets[datasetIndex].hidden;+ },+generateLegend: function generateLegend() {return this.options.legendCallback(this);},@@ -3807,6 +4210,8 @@ module.exports = function(Chart) {canvas.style.width = this.chart.originalCanvasStyleWidth;canvas.style.height = this.chart.originalCanvasStyleHeight;+ Chart.pluginService.notifyPlugins('destroy', [this]);+delete Chart.instances[this.id];},@@ -3871,20 +4276,17 @@ module.exports = function(Chart) {}}- var dataset;- var index;-// Remove styling for last active (even if it may still be active)if (this.lastActive.length) {switch (this.options.hover.mode) {case 'single':- this.data.datasets[this.lastActive[0]._datasetIndex].controller.removeHoverStyle(this.lastActive[0], this.lastActive[0]._datasetIndex, this.lastActive[0]._index);+ this.getDatasetMeta(this.lastActive[0]._datasetIndex).controller.removeHoverStyle(this.lastActive[0], this.lastActive[0]._datasetIndex, this.lastActive[0]._index);break;case 'label':case 'dataset':for (var i = 0; i < this.lastActive.length; i++) {if (this.lastActive[i])- this.data.datasets[this.lastActive[i]._datasetIndex].controller.removeHoverStyle(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index);+ this.getDatasetMeta(this.lastActive[i]._datasetIndex).controller.removeHoverStyle(this.lastActive[i], this.lastActive[i]._datasetIndex, this.lastActive[i]._index);}break;default:@@ -3896,13 +4298,13 @@ module.exports = function(Chart) {if (this.active.length && this.options.hover.mode) {switch (this.options.hover.mode) {case 'single':- this.data.datasets[this.active[0]._datasetIndex].controller.setHoverStyle(this.active[0]);+ this.getDatasetMeta(this.active[0]._datasetIndex).controller.setHoverStyle(this.active[0]);break;case 'label':case 'dataset':for (var j = 0; j < this.active.length; j++) {if (this.active[j])- this.data.datasets[this.active[j]._datasetIndex].controller.setHoverStyle(this.active[j]);+ this.getDatasetMeta(this.active[j]._datasetIndex).controller.setHoverStyle(this.active[j]);}break;default:@@ -3987,12 +4389,14 @@ module.exports = function(Chart) {},linkScales: function() {- if (!this.getDataset().xAxisID) {- this.getDataset().xAxisID = this.chart.options.scales.xAxes[0].id;- }+ var meta = this.getMeta();+ var dataset = this.getDataset();- if (!this.getDataset().yAxisID) {- this.getDataset().yAxisID = this.chart.options.scales.yAxes[0].id;+ if (meta.xAxisID === null) {+ meta.xAxisID = dataset.xAxisID || this.chart.options.scales.xAxes[0].id;+ }+ if (meta.yAxisID === null) {+ meta.yAxisID = dataset.yAxisID || this.chart.options.scales.yAxes[0].id;}},@@ -4000,6 +4404,10 @@ module.exports = function(Chart) {return this.chart.data.datasets[this.index];},+ getMeta: function() {+ return this.chart.getDatasetMeta(this.index);+ },+getScaleForId: function(scaleID) {return this.chart.scales[scaleID];},@@ -4010,13 +4418,14 @@ module.exports = function(Chart) {buildOrUpdateElements: function buildOrUpdateElements() {// Handle the number of data points changing+ var meta = this.getMeta();var numData = this.getDataset().data.length;- var numMetaData = this.getDataset().metaData.length;+ var numMetaData = meta.data.length;// Make sure that we handle number of datapoints changingif (numData < numMetaData) {// Remove excess bars for data points that have been removed- this.getDataset().metaData.splice(numData, numMetaData - numData);+ meta.data.splice(numData, numMetaData - numData);} else if (numData > numMetaData) {// Add new elementsfor (var index = numMetaData; index < numData; ++index) {@@ -4051,7 +4460,9 @@ module.exports = function(Chart) {this.initialize.apply(this, arguments);};helpers.extend(Chart.Element.prototype, {- initialize: function() {},+ initialize: function() {+ this.hidden = false;+ },pivot: function() {if (!this._view) {this._view = helpers.clone(this._model);@@ -4407,7 +4818,7 @@ module.exports = function(Chart) {helpers.uid = (function() {var id = 0;return function() {- return "chart-" + id++;+ return id++;};})();helpers.warn = function(str) {@@ -5073,9 +5484,6 @@ module.exports = function(Chart) {array.push(element);}};- helpers.isDatasetVisible = function(dataset) {- return !dataset.hidden;- };helpers.callCallback = function(fn, args, _tArg) {if (fn && typeof fn.call === 'function') {fn.apply(_tArg, args);@@ -5246,10 +5654,6 @@ module.exports = function(Chart) {return box.options.position === "chartArea";});- function fullWidthSorter(a, b) {-- }-// Ensure that full width boxes are at the very top / bottomtopBoxes.sort(function(a, b) {return (b.options.fullWidth ? 1 : 0) - (a.options.fullWidth ? 1 : 0);@@ -5446,11 +5850,15 @@ module.exports = function(Chart) {});helpers.each(topBoxes, function(box) {- box.width = newMaxChartAreaWidth;+ if (!box.options.fullWidth) {+ box.width = newMaxChartAreaWidth;+ }});helpers.each(bottomBoxes, function(box) {- box.width = newMaxChartAreaWidth;+ if (!box.options.fullWidth) {+ box.width = newMaxChartAreaWidth;+ }});maxChartAreaHeight = newMaxChartAreaHeight;@@ -5531,8 +5939,11 @@ module.exports = function(Chart) {// a callback that will handleonClick: function(e, legendItem) {- var dataset = this.chart.data.datasets[legendItem.datasetIndex];- dataset.hidden = !dataset.hidden;+ var index = legendItem.datasetIndex;+ var meta = this.chart.getDatasetMeta(index);++ // See controller.isDatasetVisible comment+ meta.hidden = meta.hidden === null? !this.chart.data.datasets[index].hidden : null;// We hid a dataset ... rerender the chartthis.chart.update();@@ -5552,12 +5963,13 @@ module.exports = function(Chart) {// lineDashOffset :// lineJoin :// lineWidth :- generateLabels: function(data) {+ generateLabels: function(chart) {+ var data = chart.data;return helpers.isArray(data.datasets) ? data.datasets.map(function(dataset, i) {return {text: dataset.label,fillStyle: dataset.backgroundColor,- hidden: dataset.hidden,+ hidden: !chart.isDatasetVisible(i),lineCap: dataset.borderCapStyle,lineDash: dataset.borderDash,lineDashOffset: dataset.borderDashOffset,@@ -5617,7 +6029,6 @@ module.exports = function(Chart) {this.afterUpdate();return this.minSize;-},afterUpdate: helpers.noop,@@ -5657,7 +6068,7 @@ module.exports = function(Chart) {beforeBuildLabels: helpers.noop,buildLabels: function() {- this.legendItems = this.options.labels.generateLabels.call(this, this.chart.data);+ this.legendItems = this.options.labels.generateLabels.call(this, this.chart);if(this.options.reverse){this.legendItems.reverse();}@@ -5851,12 +6262,73 @@ module.exports = function(Chart) {},{}],29:[function(require,module,exports){"use strict";+module.exports = function(Chart) {+ var helpers = Chart.helpers;++ // Plugins are stored here+ Chart.plugins = [];+ Chart.pluginService = {+ // Register a new plugin+ register: function(plugin) {+ if (Chart.plugins.indexOf(plugin) === -1) {+ Chart.plugins.push(plugin);+ }+ },++ // Remove a registered plugin+ remove: function(plugin) {+ var idx = Chart.plugins.indexOf(plugin);+ if (idx !== -1) {+ Chart.plugins.splice(idx, 1);+ }+ },++ // Iterate over all plugins+ notifyPlugins: function(method, args, scope) {+ helpers.each(Chart.plugins, function(plugin) {+ if (plugin[method] && typeof plugin[method] === 'function') {+ plugin[method].apply(scope, args);+ }+ }, scope);+ }+ };++ Chart.PluginBase = Chart.Element.extend({+ // Plugin methods. All functions are passed the chart instance++ // Called at start of chart init+ beforeInit: helpers.noop,++ // Called at end of chart init+ afterInit: helpers.noop,++ // Called at start of update+ beforeUpdate: helpers.noop,++ // Called at end of update+ afterUpdate: helpers.noop,++ // Called at start of draw+ beforeDraw: helpers.noop,++ // Called at end of draw+ afterDraw: helpers.noop,++ // Called during destroy+ destroy: helpers.noop,+ });+};++},{}],30:[function(require,module,exports){+"use strict";+module.exports = function(Chart) {var helpers = Chart.helpers;Chart.defaults.scale = {display: true,+ position: "left",// grid line settingsgridLines: {@@ -5865,6 +6337,7 @@ module.exports = function(Chart) {lineWidth: 1,drawOnChartArea: true,drawTicks: true,+ tickMarkLength: 10,zeroLineWidth: 1,zeroLineColor: "rgba(0,0,0,0.25)",offsetGridLines: false@@ -6122,12 +6595,12 @@ module.exports = function(Chart) {// subtract the margins to line up with the chartArea if we are a full width scalethis.minSize.width = this.isFullWidth() ? this.maxWidth - this.margins.left - this.margins.right : this.maxWidth;} else {- this.minSize.width = this.options.gridLines.display && this.options.display ? 10 : 0;+ this.minSize.width = this.options.gridLines.tickMarkLength;}// heightif (this.isHorizontal()) {- this.minSize.height = this.options.gridLines.display && this.options.display ? 10 : 0;+ this.minSize.height = this.options.gridLines.tickMarkLength;} else {this.minSize.height = this.maxHeight; // fill all the height}@@ -6243,6 +6716,9 @@ module.exports = function(Chart) {// Used to get data value locations. Value can either be an index or a numerical valuegetPixelForValue: helpers.noop,+ // Used to get the data value from a given pixel. This is the inverse of getPixelForValue+ getValueForPixel: helpers.noop,+// Used for tick location, shouldgetPixelForTick: function(index, includeOffset) {if (this.isHorizontal()) {@@ -6302,6 +6778,7 @@ module.exports = function(Chart) {var tickFontStyle = helpers.getValueOrDefault(this.options.ticks.fontStyle, Chart.defaults.global.defaultFontStyle);var tickFontFamily = helpers.getValueOrDefault(this.options.ticks.fontFamily, Chart.defaults.global.defaultFontFamily);var tickLabelFont = helpers.fontString(tickFontSize, tickFontStyle, tickFontFamily);+ var tl = this.options.gridLines.tickMarkLength;var scaleLabelFontColor = helpers.getValueOrDefault(this.options.scaleLabel.fontColor, Chart.defaults.global.defaultFontColor);var scaleLabelFontSize = helpers.getValueOrDefault(this.options.scaleLabel.fontSize, Chart.defaults.global.defaultFontSize);@@ -6319,8 +6796,8 @@ module.exports = function(Chart) {if (this.isHorizontal()) {setContextLineSettings = true;- var yTickStart = this.options.position === "bottom" ? this.top : this.bottom - 10;- var yTickEnd = this.options.position === "bottom" ? this.top + 10 : this.bottom;+ var yTickStart = this.options.position === "bottom" ? this.top : this.bottom - tl;+ var yTickEnd = this.options.position === "bottom" ? this.top + tl : this.bottom;skipRatio = false;if (((longestRotatedLabel / 2) + this.options.ticks.autoSkipPadding) * this.ticks.length > (this.width - (this.paddingLeft + this.paddingRight))) {@@ -6388,7 +6865,7 @@ module.exports = function(Chart) {if (this.options.ticks.display) {this.ctx.save();- this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.options.position === "top" ? this.bottom - 10 : this.top + 10);+ this.ctx.translate(xLabelValue, (isRotated) ? this.top + 12 : this.options.position === "top" ? this.bottom - tl : this.top + tl);this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1);this.ctx.font = tickLabelFont;this.ctx.textAlign = (isRotated) ? "right" : "center";@@ -6535,7 +7012,7 @@ module.exports = function(Chart) {});};-},{}],30:[function(require,module,exports){+},{}],31:[function(require,module,exports){"use strict";module.exports = function(Chart) {@@ -6570,7 +7047,7 @@ module.exports = function(Chart) {}};};-},{}],31:[function(require,module,exports){+},{}],32:[function(require,module,exports){"use strict";module.exports = function(Chart) {@@ -6764,7 +7241,7 @@ module.exports = function(Chart) {}});};-},{}],32:[function(require,module,exports){+},{}],33:[function(require,module,exports){"use strict";module.exports = function(Chart) {@@ -7003,10 +7480,12 @@ module.exports = function(Chart) {tooltipPosition = this.getAveragePosition(this._active);} else {helpers.each(this._data.datasets, function(dataset, datasetIndex) {- if (!helpers.isDatasetVisible(dataset)) {+ if (!this._chartInstance.isDatasetVisible(datasetIndex)) {return;}- var currentElement = dataset.metaData[element._index];++ var meta = this._chartInstance.getDatasetMeta(datasetIndex);+ var currentElement = meta.data[element._index];if (currentElement) {var yScale = element._yScale || element._scale; // handle radar || polarArea charts@@ -7017,7 +7496,7 @@ module.exports = function(Chart) {datasetIndex: datasetIndex});}- }, null, element._yScale.options.stacked);+ }, this);helpers.each(this._active, function(active) {if (active) {@@ -7026,10 +7505,9 @@ module.exports = function(Chart) {backgroundColor: active._view.backgroundColor});}- }, null, element._yScale.options.stacked);+ }, null);tooltipPosition = this.getAveragePosition(this._active);- tooltipPosition.y = this._active[0]._yScale.getPixelForDecimal(0.5);}// Build the Text Lines@@ -7258,7 +7736,7 @@ module.exports = function(Chart) {if (vm.title.length) {ctx.textAlign = vm._titleAlign;ctx.textBaseline = "top";-+var titleColor = helpers.color(vm.titleColor);ctx.fillStyle = titleColor.alpha(opacity * titleColor.alpha()).rgbString();ctx.font = helpers.fontString(vm.titleFontSize, vm._titleFontStyle, vm._titleFontFamily);@@ -7325,7 +7803,7 @@ module.exports = function(Chart) {ctx.textAlign = vm._footerAlign;ctx.textBaseline = "top";-+var footerColor = helpers.color(vm.footerColor);ctx.fillStyle = footerColor.alpha(opacity * footerColor.alpha()).rgbString();ctx.font = helpers.fontString(vm.footerFontSize, vm._footerFontStyle, vm._footerFontFamily);@@ -7381,7 +7859,7 @@ module.exports = function(Chart) {});};-},{}],33:[function(require,module,exports){+},{}],34:[function(require,module,exports){"use strict";module.exports = function(Chart, moment) {@@ -7473,7 +7951,7 @@ module.exports = function(Chart, moment) {});};-},{}],34:[function(require,module,exports){+},{}],35:[function(require,module,exports){"use strict";module.exports = function(Chart) {@@ -7635,7 +8113,7 @@ module.exports = function(Chart) {}});};-},{}],35:[function(require,module,exports){+},{}],36:[function(require,module,exports){"use strict";module.exports = function(Chart) {@@ -7789,7 +8267,7 @@ module.exports = function(Chart) {}});};-},{}],36:[function(require,module,exports){+},{}],37:[function(require,module,exports){"use strict";module.exports = function(Chart) {@@ -7896,7 +8374,7 @@ module.exports = function(Chart) {});};-},{}],37:[function(require,module,exports){+},{}],38:[function(require,module,exports){"use strict";module.exports = function(Chart) {@@ -7908,25 +8386,31 @@ module.exports = function(Chart) {};var DatasetScale = Chart.Scale.extend({- buildTicks: function(index) {- this.startIndex = 0;- this.endIndex = this.chart.data.labels.length;+ // Implement this so that+ determineDataLimits: function() {+ this.minIndex = 0;+ this.maxIndex = this.chart.data.labels.length - 1;var findIndex;if (this.options.ticks.min !== undefined) {// user specified min valuefindIndex = helpers.indexOf(this.chart.data.labels, this.options.ticks.min);- this.startIndex = findIndex !== -1 ? findIndex : this.startIndex;+ this.minIndex = findIndex !== -1 ? findIndex : this.minIndex;}if (this.options.ticks.max !== undefined) {// user specified max valuefindIndex = helpers.indexOf(this.chart.data.labels, this.options.ticks.max);- this.endIndex = findIndex !== -1 ? findIndex : this.endIndex;+ this.maxIndex = findIndex !== -1 ? findIndex : this.maxIndex;}+ this.min = this.chart.data.labels[this.minIndex];+ this.max = this.chart.data.labels[this.maxIndex];+ },++ buildTicks: function(index) {// If we are viewing some subset of labels, slice the original array- this.ticks = (this.startIndex === 0 && this.endIndex === this.chart.data.labels.length) ? this.chart.data.labels : this.chart.data.labels.slice(this.startIndex, this.endIndex + 1);+ this.ticks = (this.minIndex === 0 && this.maxIndex === this.chart.data.labels.length - 1) ? this.chart.data.labels : this.chart.data.labels.slice(this.minIndex, this.maxIndex + 1);},getLabelForIndex: function(index, datasetIndex) {@@ -7936,12 +8420,12 @@ module.exports = function(Chart) {// Used to get data value locations. Value can either be an index or a numerical valuegetPixelForValue: function(value, index, datasetIndex, includeOffset) {// 1 is added because we need the length but we have the indexes- var offsetAmt = Math.max((this.ticks.length - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1);+ var offsetAmt = Math.max((this.maxIndex + 1 - this.minIndex - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1);if (this.isHorizontal()) {var innerWidth = this.width - (this.paddingLeft + this.paddingRight);var valueWidth = innerWidth / offsetAmt;- var widthOffset = (valueWidth * (index - this.startIndex)) + this.paddingLeft;+ var widthOffset = (valueWidth * (index - this.minIndex)) + this.paddingLeft;if (this.options.gridLines.offsetGridLines && includeOffset) {widthOffset += (valueWidth / 2);@@ -7951,7 +8435,7 @@ module.exports = function(Chart) {} else {var innerHeight = this.height - (this.paddingTop + this.paddingBottom);var valueHeight = innerHeight / offsetAmt;- var heightOffset = (valueHeight * (index - this.startIndex)) + this.paddingTop;+ var heightOffset = (valueHeight * (index - this.minIndex)) + this.paddingTop;if (this.options.gridLines.offsetGridLines && includeOffset) {heightOffset += (valueHeight / 2);@@ -7961,14 +8445,34 @@ module.exports = function(Chart) {}},getPixelForTick: function(index, includeOffset) {- return this.getPixelForValue(this.ticks[index], index + this.startIndex, null, includeOffset);+ return this.getPixelForValue(this.ticks[index], index + this.minIndex, null, includeOffset);+ },+ getValueForPixel: function(pixel) {+ var value+; var offsetAmt = Math.max((this.ticks.length - ((this.options.gridLines.offsetGridLines) ? 0 : 1)), 1);+ var horz = this.isHorizontal();+ var innerDimension = horz ? this.width - (this.paddingLeft + this.paddingRight) : this.height - (this.paddingTop + this.paddingBottom);+ var valueDimension = innerDimension / offsetAmt;++ if (this.options.gridLines.offsetGridLines) {+ pixel -= (valueDimension / 2);+ }+ pixel -= horz ? this.paddingLeft : this.paddingTop;++ if (pixel <= 0) {+ value = 0;+ } else {+ value = Math.round(pixel / valueDimension);+ }++ return value;}});Chart.scaleService.registerScaleType("category", DatasetScale, defaultConfig);};-},{}],38:[function(require,module,exports){+},{}],39:[function(require,module,exports){"use strict";module.exports = function(Chart) {@@ -7979,7 +8483,8 @@ module.exports = function(Chart) {position: "left",ticks: {callback: function(tickValue, index, ticks) {- var delta = ticks[1] - ticks[0];+ // If we have lots of ticks, don't use the ones+ var delta = ticks.length > 3 ? ticks[2] - ticks[1] : ticks[1] - ticks[0];// If we have a number like 2.5 as the delta, figure out how many decimal places we needif (Math.abs(delta) > 1) {@@ -8016,23 +8521,23 @@ module.exports = function(Chart) {var hasPositiveValues = false;var hasNegativeValues = false;- helpers.each(this.chart.data.datasets, function(dataset) {- if (valuesPerType[dataset.type] === undefined) {- valuesPerType[dataset.type] = {+ helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) {+ var meta = this.chart.getDatasetMeta(datasetIndex);+ if (valuesPerType[meta.type] === undefined) {+ valuesPerType[meta.type] = {positiveValues: [],negativeValues: []};}// Store these per type- var positiveValues = valuesPerType[dataset.type].positiveValues;- var negativeValues = valuesPerType[dataset.type].negativeValues;+ var positiveValues = valuesPerType[meta.type].positiveValues;+ var negativeValues = valuesPerType[meta.type].negativeValues;- if (helpers.isDatasetVisible(dataset) && (this.isHorizontal() ? dataset.xAxisID === this.id : dataset.yAxisID === this.id)) {+ if (this.chart.isDatasetVisible(datasetIndex) && (this.isHorizontal() ? meta.xAxisID === this.id : meta.yAxisID === this.id)) {helpers.each(dataset.data, function(rawValue, index) {-var value = +this.getRightValue(rawValue);- if (isNaN(value)) {+ if (isNaN(value) || meta.data[index].hidden) {return;}@@ -8063,11 +8568,12 @@ module.exports = function(Chart) {}, this);} else {- helpers.each(this.chart.data.datasets, function(dataset) {- if (helpers.isDatasetVisible(dataset) && (this.isHorizontal() ? dataset.xAxisID === this.id : dataset.yAxisID === this.id)) {+ helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) {+ var meta = this.chart.getDatasetMeta(datasetIndex);+ if (this.chart.isDatasetVisible(datasetIndex) && (this.isHorizontal() ? meta.xAxisID === this.id : meta.yAxisID === this.id)) {helpers.each(dataset.data, function(rawValue, index) {var value = +this.getRightValue(rawValue);- if (isNaN(value)) {+ if (isNaN(value) || meta.data[index].hidden) {return;}@@ -8220,6 +8726,19 @@ module.exports = function(Chart) {return Math.round(pixel);}},+ getValueForPixel: function(pixel) {+ var offset;++ if (this.isHorizontal()) {+ var innerWidth = this.width - (this.paddingLeft + this.paddingRight);+ offset = (pixel - this.left - this.paddingLeft) / innerWidth;+ } else {+ var innerHeight = this.height - (this.paddingTop + this.paddingBottom);+ offset = (this.bottom - this.paddingBottom - pixel) / innerHeight;+ }++ return this.start + ((this.end - this.start) * offset);+ },getPixelForTick: function(index, includeOffset) {return this.getPixelForValue(this.ticksAsNumbers[index], null, null, includeOffset);}@@ -8227,7 +8746,7 @@ module.exports = function(Chart) {Chart.scaleService.registerScaleType("linear", LinearScale, defaultConfig);};-},{}],39:[function(require,module,exports){+},{}],40:[function(require,module,exports){"use strict";module.exports = function(Chart) {@@ -8260,16 +8779,17 @@ module.exports = function(Chart) {if (this.options.stacked) {var valuesPerType = {};- helpers.each(this.chart.data.datasets, function(dataset) {- if (helpers.isDatasetVisible(dataset) && (this.isHorizontal() ? dataset.xAxisID === this.id : dataset.yAxisID === this.id)) {- if (valuesPerType[dataset.type] === undefined) {- valuesPerType[dataset.type] = [];+ helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) {+ var meta = this.chart.getDatasetMeta(datasetIndex);+ if (this.chart.isDatasetVisible(datasetIndex) && (this.isHorizontal() ? meta.xAxisID === this.id : meta.yAxisID === this.id)) {+ if (valuesPerType[meta.type] === undefined) {+ valuesPerType[meta.type] = [];}helpers.each(dataset.data, function(rawValue, index) {- var values = valuesPerType[dataset.type];+ var values = valuesPerType[meta.type];var value = +this.getRightValue(rawValue);- if (isNaN(value)) {+ if (isNaN(value) || meta.data[index].hidden) {return;}@@ -8293,11 +8813,12 @@ module.exports = function(Chart) {}, this);} else {- helpers.each(this.chart.data.datasets, function(dataset) {- if (helpers.isDatasetVisible(dataset) && (this.isHorizontal() ? dataset.xAxisID === this.id : dataset.yAxisID === this.id)) {+ helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) {+ var meta = this.chart.getDatasetMeta(datasetIndex);+ if (this.chart.isDatasetVisible(datasetIndex) && (this.isHorizontal() ? meta.xAxisID === this.id : meta.yAxisID === this.id)) {helpers.each(dataset.data, function(rawValue, index) {var value = +this.getRightValue(rawValue);- if (isNaN(value)) {+ if (isNaN(value) || meta.data[index].hidden) {return;}@@ -8394,8 +8915,8 @@ module.exports = function(Chart) {getPixelForValue: function(value, index, datasetIndex, includeOffset) {var pixel;- var newVal = +this.getRightValue(value);- var range = helpers.log10(this.end) - helpers.log10(this.start);+ var newVal = +this.getRightValue(value)+; var range = helpers.log10(this.end) - helpers.log10(this.start);if (this.isHorizontal()) {@@ -8417,13 +8938,28 @@ module.exports = function(Chart) {}return pixel;+ },+ getValueForPixel: function(pixel) {+ var offset;+ var range = helpers.log10(this.end) - helpers.log10(this.start);+ var value;++ if (this.isHorizontal()) {+ var innerWidth = this.width - (this.paddingLeft + this.paddingRight);+ value = this.start * Math.pow(10, (pixel - this.left - this.paddingLeft) * range / innerWidth);+ } else {+ var innerHeight = this.height - (this.paddingTop + this.paddingBottom);+ value = Math.pow(10, (this.bottom - this.paddingBottom - pixel) * range / innerHeight) / this.start;+ }++ return value;}});Chart.scaleService.registerScaleType("logarithmic", LogarithmicScale, defaultConfig);};-},{}],40:[function(require,module,exports){+},{}],41:[function(require,module,exports){"use strict";module.exports = function(Chart) {@@ -8489,11 +9025,12 @@ module.exports = function(Chart) {this.min = null;this.max = null;- helpers.each(this.chart.data.datasets, function(dataset) {- if (helpers.isDatasetVisible(dataset)) {+ helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) {+ if (this.chart.isDatasetVisible(datasetIndex)) {+ var meta = this.chart.getDatasetMeta(datasetIndex);helpers.each(dataset.data, function(rawValue, index) {var value = +this.getRightValue(rawValue);- if (isNaN(value)) {+ if (isNaN(value) || meta.data[index].hidden) {return;}@@ -8821,7 +9358,7 @@ module.exports = function(Chart) {}// Extra 3px out for some label spacingvar pointLabelPosition = this.getPointPosition(i, this.getDistanceFromCenterForValue(this.options.reverse ? this.min : this.max) + 5);-+var pointLabelFontColor = helpers.getValueOrDefault(this.options.pointLabels.fontColor, Chart.defaults.global.defaultFontColor);var pointLabelFontSize = helpers.getValueOrDefault(this.options.pointLabels.fontSize, Chart.defaults.global.defaultFontSize);var pointLabeFontStyle = helpers.getValueOrDefault(this.options.pointLabels.fontStyle, Chart.defaults.global.defaultFontStyle);@@ -8864,7 +9401,7 @@ module.exports = function(Chart) {Chart.scaleService.registerScaleType("radialLinear", LinearRadialScale, defaultConfig);};-},{}],41:[function(require,module,exports){+},{}],42:[function(require,module,exports){/*global window: false */"use strict";@@ -8953,10 +9490,13 @@ module.exports = function(Chart) {if (this.chart.data.labels && this.chart.data.labels.length > 0) {helpers.each(this.chart.data.labels, function(label, index) {var labelMoment = this.parseTime(label);- if (this.options.time.round) {- labelMoment.startOf(this.options.time.round);++ if (labelMoment.isValid()) {+ if (this.options.time.round) {+ labelMoment.startOf(this.options.time.round);+ }+ scaleLabelMoments.push(labelMoment);}- scaleLabelMoments.push(labelMoment);}, this);this.firstTick = moment.min.call(this, scaleLabelMoments);@@ -8968,18 +9508,24 @@ module.exports = function(Chart) {helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) {var momentsForDataset = [];+ var datasetVisible = this.chart.isDatasetVisible(datasetIndex);if (typeof dataset.data[0] === 'object') {helpers.each(dataset.data, function(value, index) {var labelMoment = this.parseTime(this.getRightValue(value));- if (this.options.time.round) {- labelMoment.startOf(this.options.time.round);- }- momentsForDataset.push(labelMoment);- // May have gone outside the scale ranges, make sure we keep the first and last ticks updated- this.firstTick = this.firstTick !== null ? moment.min(this.firstTick, labelMoment) : labelMoment;- this.lastTick = this.lastTick !== null ? moment.max(this.lastTick, labelMoment) : labelMoment;+ if (labelMoment.isValid()) {+ if (this.options.time.round) {+ labelMoment.startOf(this.options.time.round);+ }+ momentsForDataset.push(labelMoment);++ if (datasetVisible) {+ // May have gone outside the scale ranges, make sure we keep the first and last ticks updated+ this.firstTick = this.firstTick !== null ? moment.min(this.firstTick, labelMoment) : labelMoment;+ this.lastTick = this.lastTick !== null ? moment.max(this.lastTick, labelMoment) : labelMoment;+ }+ }}, this);} else {// We have no labels. Use the ones from the scale@@ -9066,7 +9612,9 @@ module.exports = function(Chart) {unitDefinition = time.units[unitDefinitionIndex];this.tickUnit = unitDefinition.name;- this.scaleSizeInUnits = this.lastTick.diff(this.firstTick, this.tickUnit, true);+ var leadingUnitBuffer = this.firstTick.diff(this.firstTick.clone().startOf(this.tickUnit), this.tickUnit, true);+ var trailingUnitBuffer = this.lastTick.clone().add(1, this.tickUnit).startOf(this.tickUnit).diff(this.lastTick, this.tickUnit, true);+ this.scaleSizeInUnits = this.lastTick.diff(this.firstTick, this.tickUnit, true) + leadingUnitBuffer + trailingUnitBuffer;this.displayFormat = this.options.time.displayFormats[unitDefinition.name];}}@@ -9084,7 +9632,11 @@ module.exports = function(Chart) {// Only round the last tick if we have no hard maximumif (!this.options.time.max) {- this.lastTick.endOf(this.tickUnit);+ var roundedEnd = this.lastTick.clone().startOf(this.tickUnit);+ if (roundedEnd.diff(this.lastTick, this.tickUnit, true) !== 0) {+ // Do not use end of because we need this to be in the next time unit+ this.lastTick.add(1, this.tickUnit).startOf(this.tickUnit);+ }}this.smallestLabelSeparation = this.width;@@ -9104,7 +9656,7 @@ module.exports = function(Chart) {this.ticks.push(this.firstTick.clone());// For every unit in between the first and last moment, create a moment and add it to the ticks tick- for (var i = 1; i < this.scaleSizeInUnits; ++i) {+ for (var i = 1; i <= this.scaleSizeInUnits; ++i) {var newTick = roundedStart.clone().add(i, this.tickUnit);// Are we greater than the max time@@ -9118,18 +9670,19 @@ module.exports = function(Chart) {}// Always show the right tick- if (this.ticks[this.ticks.length - 1].diff(this.lastTick, this.tickUnit) !== 0 || this.scaleSizeInUnits === 0) {- // this is a weird case. If the <max> option is the same as the end option, we can't just diff the times because the tick was created from the roundedStart- // but the last tick was not rounded.+ var diff = this.ticks[this.ticks.length - 1].diff(this.lastTick, this.tickUnit);+ if (diff !== 0 || this.scaleSizeInUnits === 0) {+ // this is a weird case. If the <max> option is the same as the end option, we can't just diff the times because the tick was created from the roundedStart+ // but the last tick was not rounded.if (this.options.time.max) {this.ticks.push(this.lastTick.clone());this.scaleSizeInUnits = this.lastTick.diff(this.ticks[0], this.tickUnit, true);} else {- this.scaleSizeInUnits = Math.ceil(this.scaleSizeInUnits / this.unitScale) * this.unitScale;- this.ticks.push(this.firstTick.clone().add(this.scaleSizeInUnits, this.tickUnit));- this.lastTick = this.ticks[this.ticks.length - 1].clone();+ this.ticks.push(this.lastTick.clone());+ this.scaleSizeInUnits = this.lastTick.diff(this.firstTick, this.tickUnit, true);}}+this.ctx.restore();},// Get tooltip label@@ -9161,7 +9714,7 @@ module.exports = function(Chart) {this.ticks = this.ticks.map(this.tickFormatFunction, this);},getPixelForValue: function(value, index, datasetIndex, includeOffset) {- var labelMoment = this.getLabelMoment(datasetIndex, index);+ var labelMoment = value && value.isValid && value.isValid() ? value : this.getLabelMoment(datasetIndex, index);if (labelMoment) {var offset = labelMoment.diff(this.firstTick, this.tickUnit, true);@@ -9183,6 +9736,12 @@ module.exports = function(Chart) {}}},+ getValueForPixel: function(pixel) {+ var innerDimension = this.isHorizontal() ? this.width - (this.paddingLeft + this.paddingRight) : this.height - (this.paddingTop + this.paddingBottom);+ var offset = (pixel - (this.isHorizontal() ? this.left + this.paddingLeft : this.top + this.paddingTop)) / innerDimension;+ offset *= this.scaleSizeInUnits;+ return this.firstTick.clone().add(moment.duration(offset, this.tickUnit).asSeconds(), 'seconds');+ },parseTime: function(label) {if (typeof this.options.time.parser === 'string') {return moment(label, this.options.time.parser);diff --git a/app/assets/javascripts/blazer/chartkick.js b/app/assets/javascripts/blazer/chartkick.jsindex 0c14f51b..913f5a53 100644--- a/app/assets/javascripts/blazer/chartkick.js+++ b/app/assets/javascripts/blazer/chartkick.js@@ -2,7 +2,7 @@* Chartkick.js* Create beautiful JavaScript charts with minimal code* https://github.com/ankane/chartkick.js- * v1.5.0+ * v1.5.1* MIT License*/@@ -1052,11 +1052,11 @@drawChart(chart, "pie", data, options);}- this.renderColumnChart = function (chart) {+ this.renderColumnChart = function (chart, chartType) {var options = jsOptions(chart.data, chart.options);var data = createDataTable(chart, options, "column");setLabelSize(chart, data, options);- drawChart(chart, "bar", data, options);+ drawChart(chart, (chartType === "bar" ? "horizontalBar" : "bar"), data, options);}var self = this;@@ -1064,6 +1064,10 @@this.renderAreaChart = function (chart) {self.renderLineChart(chart, "area");};++ this.renderBarChart = function (chart) {+ self.renderColumnChart(chart, "bar")+ }}adapters.push(ChartjsAdapter);diff --git a/app/controllers/blazer/queries_controller.rb b/app/controllers/blazer/queries_controller.rbindex 855ce0aa..26a3ac67 100644--- a/app/controllers/blazer/queries_controller.rb+++ b/app/controllers/blazer/queries_controller.rb@@ -8,7 +8,7 @@ module BlazerBlazer::Dashboard.order(:name).map do |d|{name: "<strong>#{view_context.link_to(d.name, d)}</strong>",- creator: d.respond_to?(:creator) && d.creator == blazer_user ? "You" : d.try(:creator).try(Blazer.user_name),+ creator: blazer_user && d.try(:creator) == blazer_user ? "You" : d.try(:creator).try(Blazer.user_name),hide: d.name.gsub(/\s+/, ""),vars: nil}@@ -209,7 +209,7 @@ module Blazer{id: q.id,name: view_context.link_to(q.name, q),- creator: q.respond_to?(:creator) && q.creator == blazer_user ? "You" : q.try(:creator).try(Blazer.user_name),+ creator: blazer_user && q.try(:creator) == blazer_user ? "You" : q.try(:creator).try(Blazer.user_name),hide: q.name.gsub(/\s+/, ""),vars: extract_vars(q.statement).join(", ")}