Nevron Open Vision Documentation
Common Series Functionality

In NOV Chart for .NET data is grouped into series, which in turn are added to the chart Series collection. Each series contains data and properties that control how this data is visualized - for example the axes on which it will scale, the default fill of the data points in the series, how data labels are formatted etc.

All series derive directly or indirectly from the NSeries base class. The following sections describe the functionality exposed by this class.

Series Data

Each series in the control has an associated property called DataPoints which gives you access to the data points stored in the series. The following code snippet shows how to add data points to a series:

C#
Copy Code

NBarSeries bar = new NBarSeries();

bar.DataPoints.Add(new NBarDataPoint(10));

bar.DataPoints.Add(new NBarDataPoint(20));

bar.DataPoints.Add(new NBarDataPoint(30));

chart.Series.Add(bar);

Scatter Series

All cartesian and polar series have a property called UseXValues which instructs the series to use the XValue of the data points added to the series instead of its category index. The following code snippet shows how to create a XY scatter line chart connecting two points:

C#
Copy Code

NLineSeries line = new NLineSeries();

chart.Series.Add(line);

line.UseXValues = true;

line.DataPoints.Add(new NLineDataPoint(0, 0));

line.DataPoints.Add(new NLineDataPoint(10, 10));

Default Appearance

The series has two properties called Fill and Stroke that control the default appearance of the data points contained inside that series. The following code snippet shows how to change the color of all data points inside a series:

C#
Copy Code

NBarSeries bar = new NBarSeries();

chart.Series.Add(bar);

bar.Fill = new NColorFill(NColor.Blue);

bar.Stroke = new NStroke(2, NColor.DarkBlue);

bar.DataPoints.Add(new NBarDataPoint(10.0));

bar.DataPoints.Add(new NBarDataPoint(20.0));

bar.DataPoints.Add(new NBarDataPoint(30.0));

chart.Series.Add(bar);

Name

The series name appears on the legend when it displays information about it. It is accessible from the Name property:

C#
Copy Code
someSeries.Name = "Series Name";
Visibility

The visibility of series is controlled from the Visible property - the following code makes the series invisible:

C#
Copy Code
someSeries.Visible = false;
When the series is invisible it does not affect the ranges of the axes it scales on.
Legend View

Each series can display information to the legend attached to the chart. The information displayed on the legend is controlled from the NSeriesLegendView object attached to the series. This object is exposed from the LegendView property. The following code snippet shows how to configure the series to display legend items per each data point (the default setting is to display information about the series):

C#
Copy Code

bar.LegendView.Mode = ENSeriesLegendMode.DataPoints;

The following table lists the available options:

ENSeriesLegendMode Description
None The series is not represented in the legend.
Series The series is represented in the legend by one series defined entry.
SeriesVisibility The series is represented in the legend by one series defined entry (checkbox) which also controls its visibility.
DataPoints The series adds its data points to the legend.
SeriesLogic The series adds series specific information in the legend describing the logic it uses.

 Following is a list of the other properties of the NSeriesLegendViewObject:

The ItemMargins, ShapeMargins, TextMargins properties control the margins applied on legend items, legend item mark shapes and legend item texts.

The Legend property allows you to specify a legend for the series which differs from the default one specified for the chart that contains the series.

The Order property allows you to control whether legend items produced by the series will be appended or prepended to the content of the legend.

The MarkSize property controls the size of the legend item marks.

The Format property controls the format used to generate legend items. For more information see the Label Formatting topic.

TextStyle, MaxTextWidth and TextWrapMode properties control the text style and wrapping of text when displayed on the legend.

OriginIndex

The series has a property called OriginIndex which allows you to specify which data point is treated as the first data point in the series. This property is commonly used in real time charts that display a window of data. In such charts it is common to remove the first data point and add a new one at the end of the data points collection of the series. This results in memory shifting which is CPU intensive. In order to avoid this shift you can use the OriginIndex property. The following code snippet shows how to take advantage of this property:

C#
Copy Code

   NLineSeries lineSeries;
   int dataPointCount = 20;

   if (lineSeries.DataPoints.Count < dataPointCount)
   {
    lineSeries.DataPoints.Add(new NLineDataPoint(newValue));
   }
   else
   {
    lineSeries.DataPoints[lineSeries.OriginIndex].Value = newValue;

    lineSeries.OriginIndex++;

    if (lineSeries.OriginIndex >= lineSeries.DataPoints.Count)
    {
     lineSeries.OriginIndex = 0;
    }
   }

The above code example allows a maximum of 20 data points in the series. When the number of data points exceeds 20 it shifts the Origin index and modifies the already existing data points values instead of adding / removing data points from the collection.

 

See Also
Send Feedback