Closed mknj closed 4 months ago
Hi, whether you include a header row, and how it looks is up to you.. if you want the first row to include header titles, then pass it in with the table data array..
As an example, this project uses table-layout adding its own header row.. https://github.com/75lb/gfmt
If we include a showHeader
option, how do you think the header row should look? What should the header titles be? The input array property names or something customisable? Should the header row be formatted? If so, how?
I really like the simple interface with no complicated setup steps. If a user wants more, he can add his customized header to his data.
const data = [{"name":"udp","ms":395,"packets":20000,"rawbytes":1040000,"bytes":600000,"ratio":0.58},{"name":"http","ms":1554,"packets":20052,"rawbytes":3413448,"bytes":2090000,"ratio":0.61},{"name":"https","ms":1859,"packets":20215,"rawbytes":3866296,"bytes":2532090,"ratio":0.65},{"name":"mqtt2","ms":1312,"packets":40071,"rawbytes":3004749,"bytes":360059,"ratio":0.12},{"name":"mqtt1","ms":712,"packets":20216,"rawbytes":1614307,"bytes":280035,"ratio":0.17},{"name":"mqtt0","ms":139,"packets":53,"rawbytes":223549,"bytes":220035,"ratio":0.98}]
console.log(new TableLayout(data,{headers:true}).toString())
name ms packets rawbytes bytes ratio
udp 395 20000 1040000 600000 0.58
http 1554 20052 3413448 2090000 0.61
https 1859 20215 3866296 2532090 0.65
mqtt2 1312 40071 3004749 360059 0.12
mqtt1 712 20216 1614307 280035 0.17
mqtt0 139 53 223549 220035 0.98
Hi.. If you want a header like the one you described above, simply add the header row yourself to the top of the array you pass into table-layout
..
I don't think I will add the headers: true
option you decribed, people will have their own personal preference on how the default header should look.. plus it is easy to simply add the header row manually.
i like this simple table module. i am just missing an option to print the property names as column headers.