Skip to content

Commit 48f558a

Browse files
authored
Merge pull request #477 from plotly/transpose-adjustment
Adjust transpose function not to eat '0' s
2 parents 277ff9a + 075f965 commit 48f558a

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-chart-editor",
33
"description": "plotly.js chart editor react component UI",
4-
"version": "0.17.0",
4+
"version": "0.17.1",
55
"author": "Plotly, Inc.",
66
"bugs": {
77
"url": "https://github.com/plotly/react-chart-editor/issues"

src/lib/__tests__/transpose-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('transpose', () => {
1818
});
1919

2020
it('correctly transposes 2d arrays', () => {
21-
const originalArray = [[1, 2, 3], [9, 8, 7]];
21+
const originalArray = [[1, 2, 3], [9, 8, 0]];
2222
const transposedArray = transpose(originalArray);
2323

2424
expect(transposedArray.length).toBe(3);
@@ -32,7 +32,7 @@ describe('transpose', () => {
3232
expect(transposedArray[1][0]).toBe(2);
3333
expect(transposedArray[1][1]).toBe(8);
3434
expect(transposedArray[2][0]).toBe(3);
35-
expect(transposedArray[2][1]).toBe(7);
35+
expect(transposedArray[2][1]).toBe(0);
3636
});
3737

3838
it('correctly fills non symmetrical 2d arrays', () => {

src/lib/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ function transpose(originalArray) {
9595
newArray[innerIndex] = [];
9696
}
9797

98-
const value = originalArray[outerIndex][innerIndex]
99-
? originalArray[outerIndex][innerIndex]
100-
: null;
98+
const value =
99+
typeof originalArray[outerIndex][innerIndex] !== 'undefined'
100+
? originalArray[outerIndex][innerIndex]
101+
: null;
101102
newArray[innerIndex].push(value);
102103
}
103104
}

0 commit comments

Comments
 (0)