This topic demonstrates, with code examples, how to create the {DataChartName}™ control in code-behind.
The following topics are prerequisites to understanding this topic:
Topic | Purpose |
---|---|
This topic provides a general overview of the {DataChartName} control |
|
This topic provides information on getting started with the {DataChartName} control. |
|
This topic provides information on requirements of Series objects in the {DataChartName} control. |
This topic contains the following sections:
-
Install the Infragistics WinForms 2014 Volume 2 or later version of the product.
-
Start with new Windows Forms application using {PlatformIDE} or later version.
-
{ApiPlatform}Win.DataVisualization.Shared.{ApiVersion}
-
{ApiPlatform}Win.DataVisualization.UltraDataChart.{ApiVersion}
-
{ApiPlatform}Portable.Core.{ApiVersion}
The chart control supports various types of data visualizations called Series. These series objects can visualize wide range of data source. Refer to the Series Types topic for complete list of series supported in the chart control. Each type of series can plot data that meets certain requirements (such as number of data column and their types) as well as what type of axis can be used with it. Refer to the Series Requirements topic for requirements for each of the series.
For demonstration purpose, this topic uses sample data with only one AreaSeries and two axes: CategoryXAxis and NumericYAxis.
Copy sample data code from the Sample Energy Data resource and create an instance of category sample data:
In C#:
CategorySampleData data = new EnergyProductionDataSample();
In Visual Basic:
Dim data As New EnergyProductionDataSample()
The following code example defines the category X-axis for displaying labels on horizontal axis.
Note
|
Note:
The DataSource property is required in order to bind the category axis to IEnumerable data. |
In C#:
var xAxis = new CategoryXAxis
{
Label = "Label",
DataSource = data
};
In Visual Basic:
Dim xAxis = New CategoryXAxis() With { _
.Label = "Label", _
.DataSource = data _
}
The following code example defines the numeric Y-axis for displaying value on vertical axis.
In C#:
var yAxis = new NumericYAxis();
In Visual Basic:
Dim yAxis = New NumericYAxis()
Create an instance of a series bounding to the data source and setting data mapping. In addition, the series must have settings for two axes created in the previous section.
In C#:
AreaSeries series = new AreaSeries();
series.XAxis = xAxis;
series.YAxis = yAxis;
series.ValueMemberPath = "Coal";
series.DataSource = data;
In Visual Basic:
Dim series = New AreaSeries()
series.DataSource = data
series.ValueMemberPath = "Coal"
series.XAxis = xAxis
series.YAxis = yAxis
Create an instance of the chart control with one series and two axes.
In C#:
UltraDataChart chart = new UltraDataChart();
chart. Dock = DockStyle.Fill ;
chart.Axes.Add(xAxis);
chart.Axes.Add(yAxis);
chart.Series.Add(series);
In Visual Basic:
Dim chart As New UltraDataChart()
chart.Dock = DockStyle.Fill
chart.Axes.Add(xAxis)
chart.Axes.Add(yAxis)
chart.Series.Add(series)
The following topics provide additional information related to this topic.
Topic | Purpose |
---|---|
This topic provides information on getting started with the {DataChartName} control. |
|
This topic provides information on requirements of Series objects in the {DataChartName} control. |
|
This topic demonstrates creating WinForms {DataChartName} using the VisualStudio designer interface. |