8000 Add config to disable line simplification · timelyportfolio/plotly.js@2fb95a7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2fb95a7

Browse files
committed
Add config to disable line simplification
1 parent cef8bd5 commit 2fb95a7

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

src/traces/scatter/attributes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,16 @@ module.exports = {
156156
'Sets the style of the lines. Set to a dash string type',
157157
'or a dash length in px.'
158158
].join(' ')
159+
},
160+
simplify: {
161+
valType: 'boolean',
162+
dflt: true,
163+
role: 'info',
164+
description: [
165+
'Simplifies lines by removing nearly-collinear points. When transitioning',
166+
'lines, it may be desirable to disable this so that the number of points',
167+
'along the resulting SVG path is unaffected.'
168+
].join(' ')
159169
}
160170
},
161171
connectgaps: {

src/traces/scatter/line_defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout,
3131

3232
coerce('line.width');
3333
coerce('line.dash');
34+
coerce('line.simplify');
3435
};

src/traces/scatter/line_points.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var Axes = require('../../plots/cartesian/axes');
1515
module.exports = function linePoints(d, opts) {
1616
var xa = opts.xaxis,
1717
ya = opts.yaxis,
18+
simplify = opts.simplify,
1819
connectGaps = opts.connectGaps,
1920
baseTolerance = opts.baseTolerance,
2021
linear = opts.linear,
@@ -48,6 +49,10 @@ module.exports = function linePoints(d, opts) {
4849
clusterMaxDeviation,
4950
thisDeviation;
5051

52+
if(!simplify) {
53+
baseTolerance = minTolerance = -1;
54+
}
55+
5156
// turn one calcdata point into pixel coordinates
5257
function getPt(index) {
5358
var x = xa.c2p(d[index].x),

src/traces/scatter/plot.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition
223223
yaxis: ya,
224224
connectGaps: trace.connectgaps,
225225
baseTolerance: Math.max(line.width || 1, 3) / 4,
226-
linear: line.shape === 'linear'
226+
linear: line.shape === 'linear',
227+
simplify: line.simplify
227228
});
228229

229230
// since we already have the pixel segments here, use them to make

0 commit comments

Comments
 (0)
0