Histogram Control


Data Binding

This page describes how to data bind the histogram control. The histogram control of the .Net Analytics package is of the following type:

The first step is to include the necessary namespaces for the controls and add a chart.

Programmatically Databind a Chart

Below, we will programmatically databind a Hisstogram chart (named hcChart in the examples below). You can also use the Properties window to graphically access the databound properties for the chart:

[Visual Basic]
' Add some data to the dataset dsDataSet - could also have dataset bound to a database
DataRow drRow = dsDataSet.Tables(0).NewRow()
drRow(0) = 0.134
dsDataSet.Tables(0).Rows.Add(drRow)
drRow = dsDataSet.Tables(0).NewRow()
drRow(0) = 0.423
dsDataSet.Tables(0).Rows.Add(dr)
drRow = dsDataSet.Tables(0).NewRow()
drRow(0) = 0.314
dsDataSet.Tables(0).Rows.Add(drRow)

' Programmatically set the databound fields
hcChart.DataSource = dsDataSet.Tables(0)
hcChart.DataValueField = "ValueColumn"

[Visual C#]
// Add some data to the dataset dsDataSet - could also have dataset bound to a database
DataRow drRow = dsDataSet.Tables[0].NewRow();
drRow[0] = 0.134;
dsDataSet.Tables[0].Rows.Add(drRow);
drRow = dsDataSet.Tables[0].NewRow();
drRow[0] = 0.423;
dsDataSet.Tables[0].Rows.Add(dr);
drRow = dsDataSet.Tables[0].NewRow();
drRow[0] = 0.314;
dsDataSet.Tables[0].Rows.Add(drRow);

// Programmatically set the databound fields
hcChart.DataSource = dsDataSet.Tables[0];
hcChart.DataValueField = "ValueColumn";

After the data binding, and the number of cells/bins set to 2, the resulting chart should look similar to the following:

Databound Histogram chart