Histogram Control


Add a New Series

This page describes how to add a histogram series. The histogram control of the .Net Analytics package is of the following type:

The series class of the histogram chart is:

The first step is to include the necessary namespaces for the controls.

Add a Single Series

Below, we will add a new series to a Histogram chart (named hcChart in the examples below):

[Visual Basic]
' Create a new series
Dim hsSeries As New HistogramSeries("Series 1")
' Add the series to the collection
hcChart.SeriesCollection.Add(hsSeries)

' An alternative is to add the series directly to the collection
hcChart.SeriesCollection.Add("Series 1")

[Visual C#]
// Create a new series
HistogramSeries hsSeries = new HistogramSeries("Series 1");
// Add the series to the collection
hcChart.SeriesCollection.Add(hsSeries);

// An alternative is to add the series directly to the collection
hcChart.SeriesCollection.Add("Series 1");

After the series has been added, samples may then be added to the series. Adding samples is discussed here. The first series of the chart can be referenced via hcChart.SeriesCollection[0]. The resulting chart should look similar to the following:

Histogram chart with one series

Add More than One Series

The histogram control supports multiple series. Just add more series to the series collection.

[Visual Basic]
' Create a new series
hsSeries = New HistogramSeries("Series 2")
' Add the series to the collection
hcChart.SeriesCollection.Add(hsSeries)

' An alternative is to add the series directly to the collection
hcChart.SeriesCollection.Add("Series 2")

[Visual C#]
// Create a new series
hsSeries = new HistogramSeries("Series 2");
// Add the series to the collection
hcChart.SeriesCollection.Add(hsSeries);

// An alternative is to add the series directly to the collection
hcChart.SeriesCollection.Add("Series 2");

The nth series of the chart can be referenced via hcChart.SeriesCollection[n]. The resulting chart from above should look similar to the chart on the left after data has been added to the series. The chart on the right has the first series hidden:

Histogram chart with two series shown Histogram chart with only one out of two series shown