eldargab/easy-table

Support colorizing?

kenperkins opened this issue · 5 comments

Have you considered any approaches to allow color for the table? either the column headers, footers, or cell values?

I tried a limited test, and it seemed to impact the row length using the colors packges for field values, so I figured I'd ask before doing any more research.

Right now the only reasonable way to do this is something like

// Coloring too big numbers in red
function markTooBigs (val, width) {
    if (width == null) return Table.string(val)
    return val > 100
        ? '\033[31m' + String(val) + '\033[39m'
        : Table.string(val)
}
...
t.cell('foo', 300, markTooBigs)

Probably I'll rewrite this some day...

+1 on this. maybe we could utilize colors / chalk to colors the headers, it would be nice to do that. thanks.

As of 1.0 colors are supported

Is there a way to intercept the drawing for a whole row so that I can colorize the background? If I pass colorized strings into the cell call, it only colorizes the text, and not the empty space for the whole row.

Past that, is there a way to add sub-headings for sections of the table?

No, there is no such options