My name is Tom Wright, you may remember me from:
โ Tom Wright's Code (my blog)
๐ฆ Stackoverflow
๐ค Twitter
๐ง Last.fm
๐ผ LinkedIn
Simple yet flexible tables for console apps.
License: MIT License
My name is Tom Wright, you may remember me from:
โ Tom Wright's Code (my blog)
๐ฆ Stackoverflow
๐ค Twitter
๐ง Last.fm
๐ผ LinkedIn
ConTabs looks a bit drab in NuGet. Can we sauce it up with a snazzy logo?
For numeric columns, it would be cool to be able to visualize these as a simple bar chart in a new column.
For instance:
โญโโโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ โ โ
โ Name โ Radius โ Radius chart โ
โ โ โ โ
โโโโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ โ โ
โ Mercury โ 2439 โ ## โ
โ โ โ โ
โ Venus โ 6052 โ ##### โ
โ โ โ โ
โ Earth โ 6371 โ ##### โ
โ โ โ โ
โ Mars โ 3389 โ ## โ
โ โ โ โ
โ Jupiter โ 69911 โ ########################################################## โ
โ โ โ โ
โ Saturn โ 58232 โ ################################################ โ
โ โ โ โ
โ Uranus โ 25362 โ ##################### โ
โ โ โ โ
โ Neptune โ 24622 โ #################### โ
โ โ โ โ
โฐโโโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
This gives a nice quick visual representation of the data in the column. The above example can be achieved with existing functionality by doing something like:
table.Columns.AddGeneratedColumn<int, string>(
d => {
var normalized = d / 2400;
return new string('#', normalized);
},
"Radius chart",
table.Columns["Diameter"]
);
But, since the scope of the lambda here is limited to data from individual rows, we have no way of automagically scaling the chart to an appropriate scale. In the above example, I've hard coded the fact that each unit of width of the bars corresponds to 2400km, but this is not ideal.
In a proper implementation, there would be a quick way of adding a chart column that didn't need the lambda writing out, nor any prior knowledge of the correct scale.
In terms of API design, I imagine users would want the ability to:
NB: 1 and 3 may not be compatible - what's the most intuitive way of handling this?
Rather than hypens, pipes and pluses, we should be able to switch to other "themes" for tables.
The default might looks like this:
+-------+--------+
| Apple | Orange |
+-------+--------+
| 12 | ABC |
| 123 | AB |
+-------+--------+
And we may want (for instance) to be able to use hashes and equals signs:
#=======#========#
# Apple # Orange #
#=======#========#
# 12 # ABC #
# 123 # AB #
#=======#========#
Hi @tdwright,
I was just going though the process of setup and trying to get a familiarity with contabs before I start work on Issue 54. I noticed two potential errors/typos in the wiki pages.
I tried to edit them myself and submit a change request, but it's not obvious how github lets you fork wiki pages since they aren't part of the repo itself. After a bit of searching on stack overflow, I not sure it's even possible in any easy way. Weird. If you do know how to do that easily, I'd be happy to know for the future.
Anyways, I thought I'd just list the two things I found as an issue:
First, on page 2, styling, I believe the correct order for the three symbols in custom styles should be wall, floor, corner not floor, wall, corner.
Second, on page 6, generating columns, after the example in "Basic usage" on step 2 it says input twice. I believe this should say "input type is float
and the output type is int
".
Hope that's helpful, let me know if I'm misunderstanding.
Best,
Maxwell
The default cell padding is one character left and right. This can look cramped for some data sets.
Can we add a table-level property to allow the padding on the left and right side of the heading/data to be set?
I would imagine we would keep the padding symmetrical and apply one value to all columns.
I think at this stage we would ignore vertical spacing between rows, although this could be addressed in a separate issue.
We have a few old methods & properties that are marked as Obsolete
.
These are all to do with the way we used to handle styling the grid. The new methods have been in place for a long time now.
As we're looking to move to a new major version of ConTabs (version 2.0), it seems like a prudent time to cull these from the codebase.
An obvious example would be for numbers with decimal places:
+--------+--------+
| Apple | Orange |
+--------+--------+
| 12.50 | ABC |
| 123.21 | AB |
+--------+--------+
20 unit tests are failing when using comma as a decimal separator in system locale, for example test CurrencyFieldCanBeFormatted fails with:
val should be "ยฃ1.91" but was "ยฃ1,91"
The tests should be rewritten to be compatible with different locales (for example, using CurrentCulture.NumberFormat.NumberDecimalSeparator, or switching to different locale before testing), or columns should have support for CultureInfo in addition to string formatting.
I'd be happy to help with this issue if you decide which way you would like to have this fixed.
Possibly by using delegates?
E.g. turning a date and end date into days relative to today, or multiplying a rate by a quantity to get a subtotal.
For certain data types, we want to be able to pass a format string to control how the data is formatted.
Data types include:
Do we still need all our dependencies?
Are they all up to date?
Following on from #55, do we ever want to be able to explicitly specify the formatting culture a table (or column) should use when rendering values?
Approaches:
CultureInfo.CurrentCulture
, though not sure this works in .NET Core?)Keen to get some feedback on this. Anyone got any thoughts?
Currently a class fields printed as columns, I like to print them as rows, any idea how to do that. # @
Using contabs
I find myself forced mapping some POCO to some smaller object which only contains a subset of the properties - those I want to show in console.
It would be so much DRYer if I could just use the original POCO.
Thus I would require some way to specify which properties to print and which not.
A common library face with a similiar issue uses data annotation:
https://www.newtonsoft.com/json/help/html/SerializationAttributes.htm
Here an object can be declared "OptIn" and only those properties with such an "OptIn" annotation will actually be serialized.
Transferred to contabs
such may look like:
[ConTabsObject(MemberInclusion.OptIn)]
public class MyPoco {
[ConTabsProperty] // will be included
public string PrintMe { get; set; }
// not opted-in: will not show up in table
public string HideMe { get; set; }
...
}
Of course the such annotations could be used for other purposes as well, like string formatting or column alignment - essentially every option the current configuration offers
AFAIK - there is no style which uses just
(space) as the delimiter.
I feel such style, which is the most minimal style possible, is painfully missing from the defaults.
It is great to enhance readability of the data printed.
Currently the title of each column is taken from the name of the underlying field.
There may be times when the underlying field has a very long, or unfriendly name. In these cases we may want to change the column header to some other string that we specify.
(NB: How does this interact with #24?)
Currently if you try to make a table from a class without any public properties, you get a wonky table without any headers or content, although the correct numbers of (empty) rows do get printed.
When creating a table, we should check to see how many valid columns are present. The either throw an exception, or handle the "no column" case like we do the "no data" case.
Related: what happens if there are valid columns, but they're all set to "hide"?
.NET 5 was released on XXX and signifies the reunification of the .NET landscape.
Contabs was born at a time when .NET Standard was new(ish) and was in some ways a showcase of writing modern, portable, multi-platform C# code.
Since .NET 5 doesn't replace .NET Standard, I won't be changing witch TFM is targetted by Contabs itself. I will, however, create a demo app that shows that it can be consumed (as is) from a .NET 5 console app.
I think we could simplify our targeting by moving to .Net Standard 2.0.
This would have some implications for backwards compatibility. As per the table of implementation support, calling projects would need to be at least .Net Core 2.0 or .Net Framework 4.6.1.
.Net Standard 2.0 was released in August 2017, so isn't all that new in the grand scheme of things, but I'd be curious to hear if this will be a deal breaker for anyone?
The payoff is that we can drop the explicit targeting of .Net Framework from the core library. This opens up development to users who aren't on Windows or using Visual Studio.
Like I said, keen to hear thoughts on this.
As well as the default style and the alternative styles proposed in #3, users should be able to override each of the three elements (walls, floors, corners).
Currently we have four classes in the ConTabsTestData project that exist solely for the purposes of testing and demoing:
DemoDataType
TestDataType
MinimalDataType
InvalidTestDataType
This seems like too many. (And we're proposing another called DemoAnimals
in #21)
It seems to me that at most we'd need one for testing, one for demoing and one that's invalid. We may even be able to collapse testing and demoing into a single class.
Can we make a list of things that would be useful in each scenario? Once we've done that, we may be able to rationalise this list into a smaller one, which will be more lightweight and easier to maintain.
Doubled walled
โโโโฅโโโ
โ โ โ
โโโโซโโโข
โ โ โ
โโโโจโโโ
Double floored
โโโโคโโโ
โ โ โ
โโโโชโโโก
โ โ โ
โโโโงโโโ
Expanding on #5, there may be a range of things we want to happen when our data contains a long string:
I suggest we add an enum field to the column type so that these behaviours can be selected. We would also need a width column for options 2 and 3, so that we would know when to wrap/truncate the string.
Question: What's a sensible default behaviour?
In some use cases it might be helpful to allow a table to be redrawn with new data. For instance, I may want to grab new data every 5 seconds, clear the console and redraw the table with this new data.
It would be great if a we had a method like table<T>.Refresh(IEnumerable<T> NewData)
.
For this to work well, we would need to preserve everything except the data. I can think of two areas where this may be problematic:
So it'd be a fair chunk of work, but I think this would be a really interesting addition.
Any thoughts?
It seems to me that the expected behaviour for null values should be an empty string, not a NullReferenceException
as is currently the case.
var Data = DemoDataProvider.ListOfDemoData();
Data[0].StringCol = null;
var table = Table<DemoDataType>.Create(Data);
Console.WriteLine(table.ToString());
This should be rendered like:
+-----------+--------+
| StringCol | IntCol |
+-----------+--------+
| | 2 |
| Dogs | 1 |
| Chickens | 3 |
+-----------+--------+
This will help if/when we start to tackle anonymous objects (e.g. #35).
As showcased in #21, being able to identify and act on columns by their names (inherited from the underlying field names) is a great feature.
E.g. instead of
table.Columns[1];
We would do
table.Columns["MyColumn"];
table.TableStyle = Style.UnicodeLines;
Chinese is not supported.
Sometimes we want to spit out a table ASAP and are happy with all the default options.
We'd want to do something like:
Console.WriteLine(Table<Planet>.QuickString(planets));
Since 42b3ffc it has been possible to build in styles. There aren't currently very many of these.
Let's add some more styles to ConTabs.
Why am I getting these errors?
`Install-Package : NU1108: Cycle detected.
ConTabs.tdwright -> ConTabs.tdwright (>= 1.2.0).
At line:1 char:1
Install-Package ConTabs.tdwright -Version 1.2.0
CategoryInfo : NotSpecified: (:) [Install-Package], Exception
FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Install-Package : Package restore failed. Rolling back package changes for 'ConTabs'.
At line:1 char:1
Install-Package ConTabs.tdwright -Version 1.2.0
CategoryInfo : NotSpecified: (:) [Install-Package], Exception
FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand`
I believe a builder pattern would make the process of table creation, and hiding fields, relatively seamless. I've implemented a working version as follows:
var table = TableBuilder<DemoAnimals>
.Initialize(animalData)
.HideColumn("Name")
.HideColumn("Color")
.Build();
If this is a feature that is would be considered beneficial, I am happy to put in the pull request.
It would be useful to add XML comments to the code to power intellisense. This would aid discovery and allow people to do more with ConTabs without needing to read the online documentation.
As per http://blog.tdwright.co.uk/2017/07/25/using-xml-comments-to-provide-intellisense-hints/
As ConTabs gets more feature-rich, it might be worth documenting it properly.
Topics to include:
Each topic should have relevant examples.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.