Comments (3)
You could also use:
IColumn[] headers = new[]
{
new Column(""),
new Column("QoiCi"),
new ColumnBuilder("QoiCore")
.RowsFormat()
.HasInnerFormatting()
.GetColumn(),
new Column("QoiFileTypeNet"),
new Column("QoiNetStandard"),
new Column("QoiShark"),
};
And continue coloring it as you currently are. I parse out the ANSI codes when this flag is active, but it has a performance cost (small).
from betterconsoletables.
This is expected as the color formatting is occurring outside of the table. This adds ANSI codes to the string that the console renders as formatting. This also means that the string essentially contains a bunch of invisible characters. The header will be sized to the expected column width, but the invisible characters are not actually rendered by the console/terminal. Resulting in the effects seen here.
If you wish for a column or a value be formatted you must use the table API for that, which will calculate the correct column widths and apply formatting after.
To apply column formatting you need to configure the columns in your table:
IColumn[] headers = new[]
{
new Column(""),
new Column("QoiCi"),
new ColumnBuilder("QoiCore")
.RowsFormat()
.ForegroundColor(System.Drawing.Color.DarkGreen)
.GetColumn(),
new Column("QoiFileTypeNet"),
new Column("QoiNetStandard"),
new Column("QoiShark"),
};
var decodingtable = new BetterConsoles.Tables.Table(headers);
Unfortunately I cannot run your example as I don't have an example decodingHeaders
or decodingValues
to use. But the above should do what you are aiming for if my memory serves me right.
That said, you can find full examples of this and similar APIs in the examples project & file here: (Including the tables in the image on the repo's readme)
- https://github.com/douglasg14b/BetterConsoleTables/blob/master/BetterConsoles.Tables.Examples/Examples.cs
- https://github.com/douglasg14b/BetterConsoleTables/blob/master/BetterConsoles.Tables.Examples/Program.cs
Admittedly this API isn't as good as it could be, it's high up on my list of things to make better when I have the time to invest in it.
from betterconsoletables.
Thanks for the above. Although I had to tweak the code a bit, it now displays correctly.
The new code
var columnsWithMin = new List<int>();
var decodingTableRows = new List<string[]>();
foreach (var file in decodingValues.Keys)
{
var indexMin = decodingValues[file].IndexOf(decodingValues[file].Min());
if (!columnsWithMin.Contains(indexMin))
{
columnsWithMin.Add(indexMin);
}
var benchmarkValues = decodingValues[file]
.ConvertAll(v => v.ToString(@"ss\.ffffff"));
benchmarkValues[indexMin] = benchmarkValues[indexMin]
.ForegroundColor(System.Drawing.Color.DarkGreen);
decodingTableRows.Add(Array.Empty<string>()
.Append(file)
.Concat(benchmarkValues).ToArray());
}
var decodingTableHeaders = new List<BetterConsoles.Tables.Models.IColumn>();
decodingTableHeaders.Add(new BetterConsoles.Tables.Models.Column(string.Empty));
for (var i = 0; i < decodingHeaders.Count; i++)
{
decodingTableHeaders.Add(columnsWithMin.Contains(i)
? new BetterConsoles.Tables.Builders.ColumnBuilder(decodingHeaders[i])
.RowsFormat().HasInnerFormatting().GetColumn()
: new BetterConsoles.Tables.Models.Column(decodingHeaders[i]));
}
var decodingtable = new BetterConsoles.Tables.Table(decodingTableHeaders.ToArray());
decodingtable.Config = new BetterConsoles.Tables.Configuration.TableConfig(BetterConsoles.Tables.Style.Unicode);
decodingtable.AddRows(decodingTableRows);
Console.Write(decodingtable.ToString());
from betterconsoletables.
Related Issues (20)
- Buffer size to be too large. HOT 6
- Html output HOT 4
- IndexOutOfRangeException when no rows were given HOT 4
- Version 2 default table text color HOT 10
- Exception when piping to file HOT 6
- Live table updates HOT 5
- [Bug] [Hard] Inner/Custom formatting in cells can reset that cells general formatting
- [Enhancement] Add pseudo-bold & dim for RGB colors
- Error no rows HOT 5
- [BUG] RPI 4 ARM Linux System.PlatformNotSupportedException "Popcnt.PopCount" HOT 2
- Print tables side-by-side. HOT 3
- Multiline support in a Cell HOT 5
- ForegroundColor seems to break the table. HOT 3
- [Enhancement] Make formatting for Table.From() path easier
- Cant find ns for Column HOT 4
- Weird quirck HOT 10
- [Feature Request] Add rendering to image HOT 1
- Chinese is not supported HOT 2
- Issue with Unicode support? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from betterconsoletables.