From 6551e9212db7408d65fb90b9624beddbfe12c06a Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 17 Apr 2015 12:13:17 -0700 Subject: [PATCH] [Plot] Fix insertion in PlotLineBuffer WTD-806. --- platform/features/plot/src/elements/PlotLineBuffer.js | 4 ++-- .../features/plot/test/elements/PlotLineBufferSpec.js | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/platform/features/plot/src/elements/PlotLineBuffer.js b/platform/features/plot/src/elements/PlotLineBuffer.js index d875c9bc06..307abae666 100644 --- a/platform/features/plot/src/elements/PlotLineBuffer.js +++ b/platform/features/plot/src/elements/PlotLineBuffer.js @@ -131,8 +131,8 @@ define( // Shift data over if necessary if (index < length) { buffer.set( - buffer.subarray(index, length - index), - index + sz + buffer.subarray(index * 2, length * 2), + (index + sz) * 2 ); } diff --git a/platform/features/plot/test/elements/PlotLineBufferSpec.js b/platform/features/plot/test/elements/PlotLineBufferSpec.js index 7838d3bbd4..5d6b294da8 100644 --- a/platform/features/plot/test/elements/PlotLineBufferSpec.js +++ b/platform/features/plot/test/elements/PlotLineBufferSpec.js @@ -66,6 +66,14 @@ define( expect(buffer.findInsertionIndex(9)).toEqual(-1); }); + it("allows insertion in the middle", function () { + var head = [ -41, 8, -39, 0, -35, 3 ], + tail = [ -33, 9, -28, 8, -27, 11]; + buffer.insert(mockSeries, 3); + expect( + Array.prototype.slice.call(buffer.getBuffer()).slice(0, 24) + ).toEqual(head.concat(head).concat(tail).concat(tail)); + }); }); }