diff --git a/package.json b/package.json index f6fbf22bc..73e4ae1b4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "react-chart-editor", "description": "plotly.js chart editor react component UI", - "version": "0.17.0", + "version": "0.17.1", "author": "Plotly, Inc.", "bugs": { "url": "https://github.com/plotly/react-chart-editor/issues" diff --git a/src/lib/__tests__/transpose-test.js b/src/lib/__tests__/transpose-test.js index 46ed03447..6686dc542 100644 --- a/src/lib/__tests__/transpose-test.js +++ b/src/lib/__tests__/transpose-test.js @@ -18,7 +18,7 @@ describe('transpose', () => { }); it('correctly transposes 2d arrays', () => { - const originalArray = [[1, 2, 3], [9, 8, 7]]; + const originalArray = [[1, 2, 3], [9, 8, 0]]; const transposedArray = transpose(originalArray); expect(transposedArray.length).toBe(3); @@ -32,7 +32,7 @@ describe('transpose', () => { expect(transposedArray[1][0]).toBe(2); expect(transposedArray[1][1]).toBe(8); expect(transposedArray[2][0]).toBe(3); - expect(transposedArray[2][1]).toBe(7); + expect(transposedArray[2][1]).toBe(0); }); it('correctly fills non symmetrical 2d arrays', () => { diff --git a/src/lib/index.js b/src/lib/index.js index 17489aea8..619ae35ef 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -95,9 +95,10 @@ function transpose(originalArray) { newArray[innerIndex] = []; } - const value = originalArray[outerIndex][innerIndex] - ? originalArray[outerIndex][innerIndex] - : null; + const value = + typeof originalArray[outerIndex][innerIndex] !== 'undefined' + ? originalArray[outerIndex][innerIndex] + : null; newArray[innerIndex].push(value); } }