Dundas Chart for Windows Forms
FilterTopN(Int32,Series) Method
See Also  Example Send comments on this topic.
DundasWinChart Assembly > Dundas.Charting.WinControl Namespace > DataManipulator Class > FilterTopN Method : FilterTopN(Int32,Series) Method


pointCount
The number of data points that the filtering operation will not remove.
Number of top/bottom points to return.
inputSeries
Series object that is filtered. It is also used to store the modified data.
Input series.

Enterprise Edition Only Feature. Filters out all data points in a series except for a specified number of points with the largest (first) Y-values. The Series object that is filtered is used to store the modified data.


Keeps only N top/bottom points of the series.

Syntax

Visual Basic (Declaration)  
Public Overloads Sub FilterTopN( _
   ByVal pointCount As Integer, _
   ByVal inputSeries As Series _
) 
Visual Basic (Usage) Copy Code
Dim instance As DataManipulator
Dim pointCount As Integer
Dim inputSeries As Series
 
instance.FilterTopN(pointCount, inputSeries)
C#  
public void FilterTopN( 
   int pointCount,
   Series inputSeries
)

Parameters

pointCount
The number of data points that the filtering operation will not remove.
Number of top/bottom points to return.
inputSeries
Series object that is filtered. It is also used to store the modified data.
Input series.

Example

The following sample adds multiple data points that have unique date/time X-values and randomly set Y-values. Then the series (named "Series1") is filtered so that only 10 data points are kept that have the largest first Y-values.
Visual Basic Copy Code
Imports Dundas.Charting.WinControl
...

    ' Initialize variables
    Dim currentDate As DateTime = DateTime.Now.Date
    Dim randomValues As New Random()

    ' Add randomly-sized data points to Series1
    For i = 0 To 20
        Chart1.Series("Series1").Points.AddXY(currentDate.AddDays(i), randomValues.Next(0, 100)
    Next

    ' Filter out all points except the 10 data points with the largest Y values
    Chart1.DataManipulator.FilterTopN(10, Chart1.Series("Series1"))

..
C# Copy Code
using Dundas.Charting.WinControl
...

   
// Declare variables
   
DateTime currentDate = DateTime.Now.Date;
   Random randomValues =
new Random();
   
   
// Add randomly-sized data points to Series1
   
for (int i = 0; i < 20; i++)
       Chart1.Series(
"Series1").Points.AddXY(currentDate.AddDays(i), randomValues.Next(0, 100);
    
   
// Filter out all points except the 10 data points with the largest Y values
   
Chart1.DataManipulator.FilterTopN(10, Chart1.Series["Series1"]);

...

Remarks

This method removes all data points from the input series except for a specified number of points that have the largest first Y-values. For example, this method can be used to retrieve the top five products by sales.

To filter a series:

  • and keep data points with the smallest values use another definition of this function that uses a getTopValues argument.
  • based on a data point value other than the first Y-value (e.g. "X", "Y2", "Y3", etc.) use another definition of this method that takes a usingValue argument.
  • and preserve the original series use another definition of this function that uses an outputSeries argument.

Filtered points can be either removed from a series (default) or displayed as empty points, depending on the FilterSetEmptyPoints value.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2009 All Rights Reserved.