MCPcopy
hub / github.com/tensorflow/tfjs / table

Function table

tfjs-vis/src/render/table.ts:48–130  ·  view source on GitHub ↗
(
    container: Drawable,
    // tslint:disable-next-line:no-any
    data: TableData, opts: {fontSize?: number} = {})

Source from the content-addressed store, hash-verified

46 * @doc {heading: 'Charts', namespace: 'render'}
47 */
48export function table(
49 container: Drawable,
50 // tslint:disable-next-line:no-any
51 data: TableData, opts: {fontSize?: number} = {}) {
52 if (data && data.headers == null) {
53 throw new Error('Data to render must have a "headers" property');
54 }
55
56 if (data && data.values == null) {
57 throw new Error('Data to render must have a "values" property');
58 }
59
60 const drawArea = getDrawArea(container);
61
62 const options = Object.assign({}, defaultOpts, opts);
63
64 let table = d3Select(drawArea).select('table.tf-table');
65
66 const tableStyle = css({
67 fontSize: options.fontSize || '.875rem',
68 width: '100%',
69 maxWidth: '64rem',
70 marginRight: 'auto',
71 marginLeft: 'auto',
72 });
73
74 // If a table is not already present on this element add one
75 if (table.size() === 0) {
76 table = d3Select(drawArea).append('table');
77
78 table.attr('class', ` ${tableStyle} tf-table`);
79
80 table.append('thead').append('tr');
81 table.append('tbody');
82 }
83
84 if (table.size() !== 1) {
85 throw new Error('Error inserting table');
86 }
87
88 //
89 // Add the reader row
90 //
91 const headerRowStyle = css({
92 fontWeight: '600',
93 borderBottomStyle: 'solid',
94 borderBottomWidth: '1px',
95 borderColor: 'rgba( 0, 0, 0, .2 )',
96 textAlign: 'left',
97 paddingBottom: '1rem',
98 paddingRight: '1rem',
99 backgroundColor: '#fff',
100 });
101 const headers =
102 table.select('thead').select('tr').selectAll('th').data(data.headers);
103 const headersEnter =
104 headers.enter().append('th').attr('class', `${headerRowStyle}`);
105 headers.merge(headersEnter).html(d => d);

Callers 5

perClassAccuracyFunction · 0.90
modelSummaryFunction · 0.90
layerFunction · 0.90
renderStatsFunction · 0.90
table_test.tsFile · 0.90

Calls 6

getDrawAreaFunction · 0.90
formatFunction · 0.85
assignMethod · 0.80
appendMethod · 0.80
dataMethod · 0.65
sizeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…