Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not collapse duplicate end points when line.simplify: false #2814

Merged
merged 1 commit into from
Jul 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/traces/scatter/line_points.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions test/jasmine/tests/scatter_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down