Skip to content

Commit

Permalink
option to remove point without redraw for performance, see phetsims/e…
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Feb 25, 2020
1 parent 290bea9 commit 3da2980
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/DynamicSeries.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,17 @@ define( require => {
* Remove a point in the data series with the provided x value. Does not remove duplicates, only the first
* occurrence of the value starting at the beginning of the xPoints list.
* @param {number} x
* @param {boolean} withRedraw - if false, points can be removed without emitting to redraw (for performance)
* @public
*/
removePointAtX( x ) {
removePointAtX( x, withRedraw = true ) {
for ( let i = 0; i < this.data.length; i++ ) {
const point = this.data[ i ];
if ( point.x === x ) {
this.data.splice( i, 1 );
this.emitter.emit();
if ( withRedraw ) {
this.emitter.emit();
}
break;
}
}
Expand Down

0 comments on commit 3da2980

Please sign in to comment.