diff --git a/draftlog/6682_add.md b/draftlog/6682_add.md new file mode 100644 index 00000000000..e7163bb0d77 --- /dev/null +++ b/draftlog/6682_add.md @@ -0,0 +1 @@ +Add optional redrawMinimumInterval parameter to config for use with extendTraces/prependTraces [[#6682](https://github.com/plotly/plotly.js/pull/6682)] diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index e069252767f..1bd4c82e778 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -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) { @@ -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); @@ -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); diff --git a/src/plot_api/plot_config.js b/src/plot_api/plot_config.js index 577710ac3ac..1e2cf5aa5d9 100644 --- a/src/plot_api/plot_config.js +++ b/src/plot_api/plot_config.js @@ -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',