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

Add optional redraw parameter to extendTraces/prependTraces #6682

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions draftlog/6682_add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add optional redrawMinimumInterval parameter to config for use with extendTraces/prependTraces [[#6682](https://github.com/plotly/plotly.js/pull/6682)]
24 changes: 21 additions & 3 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ function concatTypedArray(arr0, arr1) {
* @param {Object|HTMLDivElement} gd The graph div
* @param {Object} update The key:array map of target attributes to extend
* @param {Number|Number[]} indices The locations of traces to be extended
* @param {Number|Object} [maxPoints] Number of points for trace window after lengthening.
* @param {Number|Object} [maxPoints] Number of points for trace window after lengthening
*
*/
function extendTraces(gd, update, indices, maxPoints) {
Expand Down Expand Up @@ -937,7 +937,16 @@ function extendTraces(gd, update, indices, maxPoints) {
}

var undo = spliceTraces(gd, update, indices, maxPoints, updateArray);
var promise = exports.redraw(gd);
var promise = gd;
if (gd._context.redrawMinimumInterval > 0) {
Lib.throttle(
gd._fullLayout._uid + '-redraw',
gd._context.redrawMinimumInterval,
function() { promise = exports.redraw(gd); }
);
} else {
promise = exports.redraw(gd);
}
var undoArgs = [gd, undo.update, indices, undo.maxPoints];
Queue.add(gd, exports.prependTraces, undoArgs, extendTraces, arguments);

Expand Down Expand Up @@ -994,7 +1003,16 @@ function prependTraces(gd, update, indices, maxPoints) {
}

var undo = spliceTraces(gd, update, indices, maxPoints, updateArray);
var promise = exports.redraw(gd);
var promise = gd;
if (gd._context.redrawMinimumInterval > 0) {
Lib.throttle(
gd._fullLayout._uid + '-redraw',
gd._context.redrawMinimumInterval,
function() { promise = exports.redraw(gd); }
);
} else {
promise = exports.redraw(gd);
}
var undoArgs = [gd, undo.update, indices, undo.maxPoints];
Queue.add(gd, exports.extendTraces, undoArgs, prependTraces, arguments);

Expand Down
7 changes: 7 additions & 0 deletions src/plot_api/plot_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,13 @@ var configAttributes = {
].join(' ')
},

redrawMinimumInterval: {
valType: 'integer',
min: 0,
dflt: 0,
description: 'Sets the minimum redraw interval in ms for use with extendTraces/prependTraces.'
},

locale: {
valType: 'string',
dflt: 'en-US',
Expand Down