The Quick Start topic familiarizes you with adding Sparkline control to your Windows Form application and populate data in it.
To create a simple WinForms application for Sparkline control, follow the mentioned steps and the below output appears after executing the application.
In this step, you add a class to your project that returns an enumerable collection of numeric data points to be plotted on the Sparkline chart. This code example assumes that you add a class named SampleData.cs to return a collection of numeric values.
C# |
コードのコピー
|
---|---|
class SampleData { public List<double> Sales { get { List<double> data = new List<double>() { 1.0, -1.0, 2.0, -3.0, 4.0, 5.0, -5.0, 2.0 }; return data; } } } |
VB |
コードのコピー
|
---|---|
Class SampleData Public ReadOnly Property Sales As List(Of Double) Get Dim data As List(Of Double) = New List(Of Double)() From { 1.0, -1.0, 2.0, -3.0, 4.0, 5.0, -5.0, 2.0 } Return data End Get End Property End Class |
The SampleData.cs class added in the above step returns a collection of numeric values using the ?ESTRONG>Sales?Eproperty defined in the class. In this step, you bind this collection to the Sparkline control so that data can be plotted at runtime.
To create a simple WinForms application in .NET5 Core for Sparkline control, follow the mentioned steps and the below output appears after executing the application.
Note: WinForms .NET 5 Edition does not include rich design-time support yet. We will enhance it in future releases.
// C1Sparklineコントロールを初期化します C1Sparkline sparkline= new C1Sparkline(); // C1Sparklineコントロールをフォームに追加します this.Controls.Add(sparkline);
In this step, you add a class to your project that returns an enumerable collection of numeric data points to be plotted on the Sparkline chart. This code example assumes that you add a class named SampleData.cs to return a collection of numeric values.
class SampleData { public List<double> Sales { get { List<double> data = new List<double>() { 1.0, -1.0, 2.0, -3.0, 4.0, 5.0, -5.0, 2.0 }; return data; } } }
The SampleData.cs class added in the above step returns a collection of numeric values using the <STRONG>Sales property defined in the class. In this step, you bind this collection to the Sparkline control so that data can be plotted at runtime.
// SampleDataクラスを初期化します SampleData sampleData = new SampleData(); // SampleDataクラスで使用可能な「Sales」リストをC1Sparklineコントロールの「Data」プロパティに割り当てます sparkline.Data = sampleData.Sales;