From: Evert Timberg Date: Wed, 6 Jul 2016 00:52:17 +0000 (-0400) Subject: Fix time point lines. Improved logic for using the value in the time scale. Improve... X-Git-Tag: v2.2.0-rc.1~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2918%2Fhead;p=thirdparty%2FChart.js.git Fix time point lines. Improved logic for using the value in the time scale. Improve value passing in the line and bubble controllers/ --- diff --git a/src/controllers/controller.bubble.js b/src/controllers/controller.bubble.js index 9d2d1f2c1..49aa50078 100644 --- a/src/controllers/controller.bubble.js +++ b/src/controllers/controller.bubble.js @@ -73,7 +73,7 @@ module.exports = function(Chart) { // Desired view properties _model: { - x: reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(data, index, dsIndex, me.chart.isCombo), + x: reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(typeof data === 'object' ? data : NaN, index, dsIndex, me.chart.isCombo), y: reset ? yScale.getBasePixel() : yScale.getPixelForValue(data, index, dsIndex), // Appearance radius: reset ? 0 : custom.radius ? custom.radius : me.getRadius(data), diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index f3d7328d4..b5bf20168 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -181,7 +181,7 @@ module.exports = function(Chart) { dataset.pointHitRadius = dataset.hitRadius; } - x = xScale.getPixelForValue(value, index, datasetIndex, me.chart.isCombo); + x = xScale.getPixelForValue(typeof value === 'object' ? value : NaN, index, datasetIndex, me.chart.isCombo); y = reset ? yScale.getBasePixel() : me.calculatePointY(value, index, datasetIndex); // Utility diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index 6affaebe8..c40994778 100755 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -327,7 +327,10 @@ module.exports = function(Chart) { }, getPixelForValue: function(value, index, datasetIndex) { var me = this; - value = moment(value); + if (!value || !value.isValid) { + // not already a moment object + value = moment(me.getRightValue(value)); + } var labelMoment = value && value.isValid && value.isValid() ? value : me.getLabelMoment(datasetIndex, index); if (labelMoment) {