Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'header' or 'showHeader' option #13

Open
mknj opened this issue Mar 25, 2021 · 4 comments
Open

'header' or 'showHeader' option #13

mknj opened this issue Mar 25, 2021 · 4 comments

Comments

@mknj
Copy link

mknj commented Mar 25, 2021

i like this simple table module. i am just missing an option to print the property names as column headers.

@75lb
Copy link
Owner

75lb commented Mar 25, 2021

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

@75lb
Copy link
Owner

75lb commented Mar 25, 2021

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?

@mknj
Copy link
Author

mknj commented Mar 25, 2021

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  

@75lb
Copy link
Owner

75lb commented Apr 1, 2021

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.

@75lb 75lb closed this as completed Apr 1, 2021
@75lb 75lb reopened this Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants