Skip to content

Commit cd75f69

Browse files
authoredJul 16, 2018
Merge pull request #2814 from plotly/simplify-no-duplicate-pts
Do not collapse duplicate end points when `line.simplify: false`
2 parents f9e90c4 + 07e3271 commit cd75f69

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed
 

‎src/traces/scatter/line_points.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ var constants = require('./constants');
1919
module.exports = function linePoints(d, opts) {
2020
var xa = opts.xaxis;
2121
var ya = opts.yaxis;
22-
var simplify = opts.simplify;
2322
var connectGaps = opts.connectGaps;
2423
var baseTolerance = opts.baseTolerance;
2524
var shape = opts.shape;
@@ -54,10 +53,6 @@ module.exports = function linePoints(d, opts) {
5453
// deviation variables are (signed) pixel distances normal to the cluster vector
5554
var clusterMinDeviation, clusterMaxDeviation, thisDeviation;
5655

57-
if(!simplify) {
58-
baseTolerance = minTolerance = -1;
59-
}
60-
6156
// turn one calcdata point into pixel coordinates
6257
function getPt(index) {
6358
var di = d[index];
@@ -357,7 +352,7 @@ module.exports = function linePoints(d, opts) {
357352
// can't decimate if nonlinear line shape
358353
// TODO: we *could* decimate [hv]{2,3} shapes if we restricted clusters to horz or vert again
359354
// but spline would be verrry awkward to decimate
360-
if(!linear) {
355+
if(!linear || !opts.simplify) {
361356
addPt(clusterHighPt);
362357
continue;
363358
}

‎test/jasmine/tests/scatter_test.js

+6
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,12 @@ describe('Test scatter', function() {
345345
});
346346

347347
it('should not collapse straight lines if simplify is false', function() {
348+
var ptsIn = [[0, 0], [5, 10], [13, 26], [15, 30], [15, 30], [15, 30], [15, 30]];
349+
var ptsOut = callLinePoints(ptsIn, {simplify: false});
350+
expect(ptsOut).toEqual([ptsIn]);
351+
});
352+
353+
it('should not collapse duplicate end points if simplify is false', function() {
348354
var ptsIn = [[0, 0], [5, 10], [13, 26], [15, 30], [22, 16], [28, 4], [30, 0]];
349355
var ptsOut = callLinePoints(ptsIn, {simplify: false});
350356
expect(ptsOut).toEqual([ptsIn]);

0 commit comments

Comments
 (0)