VegaGenerator

August 25, 2024 ยท View on GitHub

A library to help generate VegaLite charts from C# code.

See the included Demo app for examples

Available on Nuget as VegaGenerator

Illustrative code

var data = new List<OrderedDictionary>();
// populate data with an OrderedDicionary per point, "x"=> xValue, "y" => yValue, "series"=>seriesName

//for a chart where X values are DateTimes and Y are numeric....
var spec = VegaChart.CreateVegaChart(
             VegaMark.Line,
             new ColumnDescription("x", "x", VegaAxisType.Temporal),
             new ColumnDescription("y", "y", VegaAxisType.Quantitative),
             new ColumnDescription("series", "series", VegaAxisType.Nominal)
         )
        .InjectData(data) //add the data 
        .UseCursorTooltip()
        .SetTitle("Demo Chart")
        .FillContainer(); 

//generate the html and display it
var html = VegaMaker.MakeHtml("demo", spec.Serialize(),"dark");

image