Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 725845d

Browse files
committed
columnwidth to accept strings
1 parent 2f8da23 commit 725845d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/traces/table/data_preparation_helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ module.exports = function calc(gd, trace) {
3333
var columnOrder = trace._fullInput.columnorder;
3434
var columnWidths = headerValues.map(function(d, i) {
3535
return Array.isArray(trace.columnwidth) ?
36-
trace.columnwidth[Math.min(i, trace.columnwidth.length - 1)] :
37-
isFinite(trace.columnwidth) && trace.columnwidth !== null ? trace.columnwidth : 1;
36+
Number(trace.columnwidth[Math.min(i, trace.columnwidth.length - 1)]) :
37+
trace.columnwidth !== null && isFinite(Number(trace.columnwidth)) ? Number(trace.columnwidth) : 1;
3838
});
3939
var totalColumnWidths = columnWidths.reduce(function(p, n) {return p + n;}, 0);
4040

test/jasmine/tests/table_test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ describe('table initialization tests', function() {
9292
expect(fullTrace.cells.values).toEqual([]);
9393
});
9494

95+
it('\'columnwidth\' specification should accept a numerical array', function() {
96+
var fullTrace = _supply({
97+
columnwidth: [1, 2, 3]
98+
});
99+
expect(fullTrace.columnwidth).toEqual([1, 2, 3]);
100+
});
101+
102+
it('\'columnwidth\' specification should accept a string array (converted downstream)', function() {
103+
var fullTrace = _supply({
104+
columnwidth: ['1', '2', '3']
105+
});
106+
expect(fullTrace.columnwidth).toEqual(['1', '2', '3']);
107+
});
108+
95109
it('\'header\' should be used with default values where attributes are not provided', function() {
96110
var fullTrace = _supply({
97111
header: {

0 commit comments

Comments
 (0)