From 25b843f6bbacb1937bdb960777b73acbece64115 Mon Sep 17 00:00:00 2001 From: ziejd2 Date: Wed, 24 Feb 2021 14:36:59 -0600 Subject: GENENET8 update --- sourcecodes/scripts/create_table.js | 84 +++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 sourcecodes/scripts/create_table.js (limited to 'sourcecodes/scripts/create_table.js') diff --git a/sourcecodes/scripts/create_table.js b/sourcecodes/scripts/create_table.js new file mode 100644 index 00000000..6d0cd9b7 --- /dev/null +++ b/sourcecodes/scripts/create_table.js @@ -0,0 +1,84 @@ +function tabulate_caption(container,data,caption_text) { + var table = d3.select(container).append('table'); + var caption = table.append("caption").text(caption_text); + //var titles = d3.keys(data[0]); + var titles = data.columns; + var headers = table.append('thead').append('tr') + .selectAll('th') + .data(titles).enter() + .append('th') + .text(function (d) { + return d; + }); + + var rows = table.append('tbody').selectAll('tr') + .data(data).enter() + .append('tr'); + rows.selectAll('td') + .data(function (d) { + return titles.map(function (k) { + return { 'value': d[k], 'name': k}; + }); + }).enter() + .append('td') + .attr('data-th', function (d) { + return d.name; + }) + .text(function (d) { + return d.value; + }); + return table; +} + +function tabulate_header_row(container,data,caption_text) { + var table = d3.select(container).append('table'); + var caption = table.append("caption").text(caption_text); + //var titles = d3.keys(data[0]); + var titles = data.columns; + for (var i=0; i