diff --git a/package.json b/package.json index eef6fca7c3a..dcf394cff4b 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "cibuild": "node tasks/cibundle.js", "watch": "node tasks/watch_plotly.js", "lint": "eslint . || true", + "lint-fix": "eslint . --fix", "test-jasmine": "karma start test/jasmine/karma.conf.js", "citest-jasmine": "karma start test/jasmine/karma.ciconf.js", "test-image": "./tasks/test_image.sh", @@ -55,7 +56,7 @@ "gl-error2d": "^1.0.0", "gl-error3d": "^1.0.0", "gl-heatmap2d": "^1.0.2", - "gl-line2d": "^1.2.1", + "gl-line2d": "^1.3.0", "gl-line3d": "^1.1.0", "gl-mat4": "^1.1.2", "gl-mesh3d": "^1.0.7", @@ -85,7 +86,7 @@ "browserify": "^13.0.0", "browserify-transform-tools": "^1.5.1", "ecstatic": "^1.4.0", - "eslint": "^2.1.0", + "eslint": "^2.8.0", "falafel": "^1.2.0", "fs-extra": "^0.27.0", "fuse.js": "^2.2.0", diff --git a/src/traces/scattergl/attributes.js b/src/traces/scattergl/attributes.js index 31008d79120..7badacf9f8f 100644 --- a/src/traces/scattergl/attributes.js +++ b/src/traces/scattergl/attributes.js @@ -86,6 +86,7 @@ module.exports = { reversescale: scatterMarkerLineAttrs.reversescale } }, + connectgaps: scatterAttrs.connectgaps, fill: extendFlat({}, scatterAttrs.fill, { values: ['none', 'tozeroy', 'tozerox'] }), diff --git a/src/traces/scattergl/convert.js b/src/traces/scattergl/convert.js index 089da9e7fc5..36ef0556dca 100644 --- a/src/traces/scattergl/convert.js +++ b/src/traces/scattergl/convert.js @@ -33,12 +33,15 @@ function LineWithMarkers(scene, uid) { this.scene = scene; this.uid = uid; + this.pickXData = []; + this.pickYData = []; this.xData = []; this.yData = []; this.textLabels = []; this.color = 'rgb(0, 0, 0)'; this.name = ''; this.hoverinfo = 'all'; + this.connectgaps = true; this.idToIndex = []; this.bounds = [0, 0, 0, 0]; @@ -103,14 +106,17 @@ function LineWithMarkers(scene, uid) { var proto = LineWithMarkers.prototype; proto.handlePick = function(pickResult) { - var index = this.idToIndex[pickResult.pointId]; + var index = pickResult.pointId; + if(pickResult.object !== this.line || this.connectgaps) { + index = this.idToIndex[pickResult.pointId]; + } return { trace: this, dataCoord: pickResult.dataCoord, traceCoord: [ - this.xData[index], - this.yData[index] + this.pickXData[index], + this.pickYData[index] ], textLabel: Array.isArray(this.textLabels) ? this.textLabels[index] : @@ -248,6 +254,7 @@ proto.update = function(options) { this.name = options.name; this.hoverinfo = options.hoverinfo; this.bounds = [Infinity, Infinity, -Infinity, -Infinity]; + this.connectgaps = !!options.connectgaps; if(this.isFancy(options)) { this.updateFancy(options); @@ -262,8 +269,8 @@ proto.update = function(options) { }; proto.updateFast = function(options) { - var x = this.xData = options.x; - var y = this.yData = options.y; + var x = this.xData = this.pickXData = options.x; + var y = this.yData = this.pickYData = options.y; var len = x.length, idToIndex = new Array(len), @@ -344,8 +351,11 @@ proto.updateFancy = function(options) { bounds = this.bounds; // makeCalcdata runs d2c (data-to-coordinate) on every point - var x = this.xData = xaxis.makeCalcdata(options, 'x'); - var y = this.yData = yaxis.makeCalcdata(options, 'y'); + var x = this.pickXData = xaxis.makeCalcdata(options, 'x').slice(); + var y = this.pickYData = yaxis.makeCalcdata(options, 'y').slice(); + + this.xData = x.slice(); + this.yData = y.slice(); // get error values var errorVals = ErrorBars.calcFromTrace(options, scene.fullLayout); @@ -370,8 +380,8 @@ proto.updateFancy = function(options) { var i, j, xx, yy, ex0, ex1, ey0, ey1; for(i = 0; i < len; ++i) { - xx = getX(x[i]); - yy = getY(y[i]); + this.xData[i] = xx = getX(x[i]); + this.yData[i] = yy = getY(y[i]); if(isNaN(xx) || isNaN(yy)) continue; @@ -460,8 +470,21 @@ proto.updateFancy = function(options) { }; proto.updateLines = function(options, positions) { + var i; if(this.hasLines) { - this.lineOptions.positions = positions; + var linePositions = positions; + if(!options.connectgaps) { + var p = 0; + var x = this.xData; + var y = this.yData; + linePositions = new Float32Array(2 * x.length); + + for(i=0; i