Add support for bar charts

Closes #103
This commit is contained in:
Patrik Svensson
2020-12-22 22:26:17 +01:00
committed by Patrik Svensson
parent 1cf30f62fc
commit 7dccb310f3
21 changed files with 597 additions and 8 deletions

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
<Title>Charts</Title>
<Description>Demonstrates how to render charts in a console.</Description>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Spectre.Console\Spectre.Console.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,21 @@
using Spectre.Console;
namespace InfoExample
{
public static class Program
{
public static void Main()
{
var chart = new BarChart()
.Width(60)
.Label("[green bold underline]Number of fruits[/]")
.CenterLabel()
.AddItem("Apple", 12, Color.Yellow)
.AddItem("Orange", 54, Color.Green)
.AddItem("Banana", 33, Color.Red);
AnsiConsole.WriteLine();
AnsiConsole.Render(chart);
}
}
}