Windows Forms: Live Charts in C#

Live Charts are Simple, flexible, interactive & powerful data visualization for .Net. It's just data visualization but built and for everyone

Step 1Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "LiveChartDemo" and then click OK

live charts in c#Step 2: Right click on your project select Manage NuGet Packages -> Search live charts -> Install

download live chartsStep 3: Design your form as below

live charts in c#

You need to create a stored procedure to get total orders from the orders table in the Northwind database, then add your stored procedure to Entity Framework Model First

Step 4: Add code to handle your form as below

private void Form1_Load(object sender, EventArgs e)
{
    using (NorthwindEntities db = new NorthwindEntities())
    {
        //Retrieve data from stored procedure
        var data = db.GetTotalOrders();
        //Create columns chart
        ColumnSeries col = new ColumnSeries() { DataLabels = true, Values = new ChartValues<int>(), LabelPoint = point => point.Y.ToString() };
        Axis ax = new Axis() { Separator = new Separator() { Step = 1, IsEnabled = false } };
        ax.Labels = new List<string>();
        //Add data to your chart
        foreach (var x in data)
        {
            col.Values.Add(x.Total.Value);
            ax.Labels.Add(x.Year.ToString());
        }
        cartesianChart1.Series.Add(col);
        cartesianChart1.AxisX.Add(ax);
        cartesianChart1.AxisY.Add(new Axis
        {
            LabelFormatter = value => value.ToString(),
            Separator = new Separator()
        });
    }
}

VIDEO TUTORIALS