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 c69aeb1

Browse filesBrowse files
authored
Merge pull request #2107 from plotly/table-restyle-squashed
Improvements to table: `restyle` fix, 0 row/column and misc. fixes; jasmine tests
2 parents f991039 + 37dd8ba commit c69aeb1
Copy full SHA for c69aeb1

File tree

Expand file treeCollapse file tree

6 files changed

+363
-29
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+363
-29
lines changed

‎src/traces/table/attributes.js

Copy file name to clipboardExpand all lines: src/traces/table/attributes.js
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ module.exports = overrideAll({
4848
arrayOk: true,
4949
dflt: null,
5050
role: 'style',
51-
description: 'The width of cells.'
51+
description: [
52+
'The width of columns expressed as a ratio. Columns fill the available width',
53+
'in proportion of their specified column widths.'
54+
].join(' ')
5255
},
5356

5457
columnorder: {

‎src/traces/table/data_preparation_helper.js

Copy file name to clipboardExpand all lines: src/traces/table/data_preparation_helper.js
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ module.exports = function calc(gd, trace) {
1616
var headerValues = trace.header.values.map(function(c) {
1717
return Array.isArray(c) ? c : [c];
1818
});
19+
var cellsValues = trace.cells.values;
1920
var domain = trace.domain;
2021
var groupWidth = Math.floor(gd._fullLayout._size.w * (domain.x[1] - domain.x[0]));
2122
var groupHeight = Math.floor(gd._fullLayout._size.h * (domain.y[1] - domain.y[0]));
22-
var headerRowHeights = headerValues[0].map(function() {return trace.header.height;});
23-
var rowHeights = trace.cells.values[0].map(function() {return trace.cells.height;});
23+
var headerRowHeights = headerValues.length ? headerValues[0].map(function() {return trace.header.height;}) : [];
24+
var rowHeights = cellsValues.length ? cellsValues[0].map(function() {return trace.cells.height;}) : [];
2425
var headerHeight = headerRowHeights.reduce(function(a, b) {return a + b;}, 0);
2526
var scrollHeight = groupHeight - headerHeight;
2627
var minimumFillHeight = scrollHeight + c.uplift;

‎src/traces/table/defaults.js

Copy file name to clipboardExpand all lines: src/traces/table/defaults.js
+17-22Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
var Lib = require('../../lib');
1212
var attributes = require('./attributes');
1313

14-
function defaultColumnOrder(traceIn, coerce) {
15-
var specifiedColumnOrder = traceIn.columnorder || [];
16-
var commonLength = traceIn.header.values.length;
14+
function defaultColumnOrder(traceOut, coerce) {
15+
var specifiedColumnOrder = traceOut.columnorder || [];
16+
var commonLength = traceOut.header.values.length;
1717
var truncated = specifiedColumnOrder.slice(0, commonLength);
1818
var sorted = truncated.slice().sort(function(a, b) {return a - b;});
1919
var oneStepped = truncated.map(function(d) {return sorted.indexOf(d);});
@@ -28,28 +28,10 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
2828
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
2929
}
3030

31-
var fontDflt = {
32-
family: layout.font.family,
33-
size: layout.font.size,
34-
color: layout.font.color
35-
};
36-
3731
coerce('domain.x');
3832
coerce('domain.y');
3933

4034
coerce('columnwidth');
41-
defaultColumnOrder(traceIn, coerce);
42-
43-
coerce('cells.values');
44-
coerce('cells.format');
45-
coerce('cells.align');
46-
coerce('cells.prefix');
47-
coerce('cells.suffix');
48-
coerce('cells.height');
49-
coerce('cells.line.width');
50-
coerce('cells.line.color');
51-
coerce('cells.fill.color');
52-
Lib.coerceFont(coerce, 'cells.font', fontDflt);
5335

5436
coerce('header.values');
5537
coerce('header.format');
@@ -61,5 +43,18 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
6143
coerce('header.line.width');
6244
coerce('header.line.color');
6345
coerce('header.fill.color');
64-
Lib.coerceFont(coerce, 'header.font', fontDflt);
46+
Lib.coerceFont(coerce, 'header.font', Lib.extendFlat({}, layout.font));
47+
48+
defaultColumnOrder(traceOut, coerce);
49+
50+
coerce('cells.values');
51+
coerce('cells.format');
52+
coerce('cells.align');
53+
coerce('cells.prefix');
54+
coerce('cells.suffix');
55+
coerce('cells.height');
56+
coerce('cells.line.width');
57+
coerce('cells.line.color');
58+
coerce('cells.fill.color');
59+
Lib.coerceFont(coerce, 'cells.font', Lib.extendFlat({}, layout.font));
6560
};

‎src/traces/table/index.js

Copy file name to clipboardExpand all lines: src/traces/table/index.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Table.plot = require('./plot');
1818
Table.moduleType = 'trace';
1919
Table.name = 'table';
2020
Table.basePlotModule = require('./base_plot');
21-
Table.categories = [];
21+
Table.categories = ['noOpacity'];
2222
Table.meta = {
2323
description: [
2424
'Table view for detailed data viewing.',

‎src/traces/table/plot.js

Copy file name to clipboardExpand all lines: src/traces/table/plot.js
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ module.exports = function plot(gd, wrappedTraceHolders) {
9393
.append('g')
9494
.classed(c.cn.yColumn, true);
9595

96+
yColumn.exit().remove();
97+
9698
yColumn
9799
.attr('transform', function(d) {return 'translate(' + d.x + ' 0)';})
98100
.call(d3.behavior.drag()
@@ -242,7 +244,7 @@ function renderScrollbarKit(tableControlView, gd, bypassVisibleBar) {
242244

243245
function calcTotalHeight(d) {
244246
var blocks = d.rowBlocks;
245-
return firstRowAnchor(blocks, blocks.length - 1) + rowsHeight(blocks[blocks.length - 1], Infinity);
247+
return firstRowAnchor(blocks, blocks.length - 1) + (blocks.length ? rowsHeight(blocks[blocks.length - 1], Infinity) : 1);
246248
}
247249

248250
var scrollbarKit = tableControlView.selectAll('.' + c.cn.scrollbarKit)
@@ -288,7 +290,7 @@ function renderScrollbarKit(tableControlView, gd, bypassVisibleBar) {
288290

289291
scrollbarSlider
290292
.attr('transform', function(d) {
291-
return 'translate(0 ' + d.scrollbarState.topY + ')';
293+
return 'translate(0 ' + (d.scrollbarState.topY || 0) + ')';
292294
});
293295

294296
var scrollbarGlyph = scrollbarSlider.selectAll('.' + c.cn.scrollbarGlyph)
@@ -603,7 +605,7 @@ function headerBlock(d) {return d.type === 'header';}
603605
*/
604606

605607
function headerHeight(d) {
606-
var headerBlocks = d.rowBlocks[0].auxiliaryBlocks;
608+
var headerBlocks = d.rowBlocks.length ? d.rowBlocks[0].auxiliaryBlocks : [];
607609
return headerBlocks.reduce(function(p, n) {return p + rowsHeight(n, Infinity);}, 0);
608610
}
609611

@@ -643,6 +645,7 @@ function findPagesAndCacheHeights(blocks, scrollY, scrollHeight) {
643645

644646
function updateBlockYPosition(gd, cellsColumnBlock, tableControlView) {
645647
var d = flatData(cellsColumnBlock)[0];
648+
if(d === undefined) return;
646649
var blocks = d.rowBlocks;
647650
var calcdata = d.calcdata;
648651

0 commit comments

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