Windows Forms: Live Charts in C#
By FoxLearn 6/3/2017 5:56:22 PM 15.59K
Live Charts are Simple, flexible, interactive & powerful data visualization for .Net. It's just data visualization but built and for everyone
Step 1: Click 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
Step 2: Right click on your project select Manage NuGet Packages -> Search live charts -> Install
Step 3: Design your form as below
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
Categories
Popular Posts
How to implement Jint in C#
09/14/2024
How to Download Chromedriver for Selenium
09/14/2024
C# Tutorial
07/20/2024