This topic demonstrates, with code examples, how to create the UltraDataChart™ control in code-behind.
The following topics are prerequisites to understanding this topic:
This topic contains the following sections:
The following is the preview of the result of this topic.
Install the Ultimate UI for Windows Forms 2014 Volume 2 or later version of the product.
Start with new Windows Forms application using Visual Studio 2013-2017 or later version.
Infragistics.Win.DataVisualization.Shared.
Infragistics.Win.DataVisualization.UltraDataChart.
Infragistics.Portable.Core.
In C#:
using Infragistics.Win.DataVisualization;
using System.Collections;
using System.Drawing;
using System.Windows.Forms;
In Visual Basic:
Imports Infragistics.Win.DataVisualization
Imports System.Collections
Imports System.Drawing
Imports System.Windows.Forms
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#:
var 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.
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.