Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 37ba12a

Browse filesBrowse files
committed
downstream unification of cell data structures
1 parent 7807449 commit 37ba12a
Copy full SHA for 37ba12a

File tree

Expand file treeCollapse file tree

2 files changed

+9
-12
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-12
lines changed

‎src/traces/table/data_preparation_helper.js

Copy file name to clipboardExpand all lines: src/traces/table/data_preparation_helper.js
+9-6Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ var extendFlat = require('../../lib/extend').extendFlat;
1313

1414
// pure functions, don't alter but passes on `gd` and parts of `trace` without deep copying
1515
module.exports = function calc(gd, trace) {
16+
var headerValues = trace.header.values.map(function(c) {
17+
return Array.isArray(c) ? c : [c];
18+
});
1619
var domain = trace.domain;
1720
var groupWidth = Math.floor(gd._fullLayout._size.w * (domain.x[1] - domain.x[0]));
1821
var groupHeight = Math.floor(gd._fullLayout._size.h * (domain.y[1] - domain.y[0]));
19-
var headerRowHeights = trace.header.values[0].map(function() {return trace.header.height;});
22+
var headerRowHeights = headerValues[0].map(function() {return trace.header.height;});
2023
var rowHeights = trace.cells.values[0].map(function() {return trace.cells.height;});
2124
var headerHeight = headerRowHeights.reduce(function(a, b) {return a + b;}, 0);
2225
var scrollHeight = groupHeight - headerHeight;
@@ -27,7 +30,7 @@ module.exports = function calc(gd, trace) {
2730
var rowBlocks = makeRowBlock(anchorToRowBlock, headerRowBlocks);
2831
var uniqueKeys = {};
2932
var columnOrder = trace._fullInput.columnorder;
30-
var columnWidths = trace.header.values.map(function(d, i) {
33+
var columnWidths = headerValues.map(function(d, i) {
3134
return Array.isArray(trace.columnwidth) ?
3235
trace.columnwidth[Math.min(i, trace.columnwidth.length - 1)] :
3336
isFinite(trace.columnwidth) && trace.columnwidth !== null ? trace.columnwidth : 1;
@@ -50,12 +53,12 @@ module.exports = function calc(gd, trace) {
5053
headerRowBlocks: headerRowBlocks,
5154
scrollY: 0, // will be mutated on scroll
5255
cells: trace.cells,
53-
headerCells: trace.header,
54-
gdColumns: trace.header.values.map(function(d) {return d[0];}),
55-
gdColumnsOriginalOrder: trace.header.values.map(function(d) {return d[0];}),
56+
headerCells: extendFlat({}, trace.header, {values: headerValues}),
57+
gdColumns: headerValues.map(function(d) {return d[0];}),
58+
gdColumnsOriginalOrder: headerValues.map(function(d) {return d[0];}),
5659
prevPages: [0, 0],
5760
scrollbarState: {scrollbarScrollInProgress: false},
58-
columns: trace.header.values.map(function(label, i) {
61+
columns: headerValues.map(function(label, i) {
5962
var foundKey = uniqueKeys[label];
6063
uniqueKeys[label] = (foundKey || 0) + 1;
6164
var key = label + '__' + uniqueKeys[label];

‎src/traces/table/defaults.js

Copy file name to clipboardExpand all lines: src/traces/table/defaults.js
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
5252
Lib.coerceFont(coerce, 'cells.font', fontDflt);
5353

5454
coerce('header.values');
55-
for(var i = 0; i < traceOut.header.values.length; i++) {
56-
if(!Array.isArray(traceOut.header.values[i])) {
57-
traceOut.header.values[i] = [traceOut.header.values[i]];
58-
}
59-
}
60-
6155
coerce('header.format');
6256
coerce('header.align');
6357

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.