From 07e32712feec1e3afc023a1a402ef7ee904ee751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 12 Jul 2018 17:20:49 -0400 Subject: [PATCH] do not collaspe duplicate end points when line.simplify:false ... so that such lines can transition smoothly --- src/traces/scatter/line_points.js | 7 +------ test/jasmine/tests/scatter_test.js | 6 ++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/traces/scatter/line_points.js b/src/traces/scatter/line_points.js index a198ba450be..ef84cb0cdaa 100644 --- a/src/traces/scatter/line_points.js +++ b/src/traces/scatter/line_points.js @@ -19,7 +19,6 @@ var constants = require('./constants'); module.exports = function linePoints(d, opts) { var xa = opts.xaxis; var ya = opts.yaxis; - var simplify = opts.simplify; var connectGaps = opts.connectGaps; var baseTolerance = opts.baseTolerance; var shape = opts.shape; @@ -54,10 +53,6 @@ module.exports = function linePoints(d, opts) { // deviation variables are (signed) pixel distances normal to the cluster vector var clusterMinDeviation, clusterMaxDeviation, thisDeviation; - if(!simplify) { - baseTolerance = minTolerance = -1; - } - // turn one calcdata point into pixel coordinates function getPt(index) { var di = d[index]; @@ -357,7 +352,7 @@ module.exports = function linePoints(d, opts) { // can't decimate if nonlinear line shape // TODO: we *could* decimate [hv]{2,3} shapes if we restricted clusters to horz or vert again // but spline would be verrry awkward to decimate - if(!linear) { + if(!linear || !opts.simplify) { addPt(clusterHighPt); continue; } diff --git a/test/jasmine/tests/scatter_test.js b/test/jasmine/tests/scatter_test.js index 3a837b9dfde..3f247532f81 100644 --- a/test/jasmine/tests/scatter_test.js +++ b/test/jasmine/tests/scatter_test.js @@ -345,6 +345,12 @@ describe('Test scatter', function() { }); it('should not collapse straight lines if simplify is false', function() { + var ptsIn = [[0, 0], [5, 10], [13, 26], [15, 30], [15, 30], [15, 30], [15, 30]]; + var ptsOut = callLinePoints(ptsIn, {simplify: false}); + expect(ptsOut).toEqual([ptsIn]); + }); + + it('should not collapse duplicate end points if simplify is false', function() { var ptsIn = [[0, 0], [5, 10], [13, 26], [15, 30], [22, 16], [28, 4], [30, 0]]; var ptsOut = callLinePoints(ptsIn, {simplify: false}); expect(ptsOut).toEqual([ptsIn]);