Dundas Chart for ASP.NET
FilterTopN(Int32,Series,Series) Method
See Also  Example Send comments on this topic.
Dundas.Charting.WebControl Namespace > DataManipulator Class > FilterTopN Method : FilterTopN(Int32,Series,Series) Method


pointCount
The number of data points that the filtering operation will not remove (or mark as empty).
Number of top/bottom points to return.
inputSeries
Series object that is filtered.
Input series.
outputSeries
Series object that stores the remaining data points. If it does not exist an exception will be thrown.
Output series.

Enterprise Edition Only Feature. Filters all data points in a series except for a specified number of point's with the largest first Y-values.


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, _
   ByVal outputSeries As Series _
) 
Visual Basic (Usage) Copy Code
Dim instance As DataManipulator
Dim pointCount As Integer
Dim inputSeries As Series
Dim outputSeries As Series
 
instance.FilterTopN(pointCount, inputSeries, outputSeries)
C#  
public void FilterTopN( 
   int pointCount,
   Series inputSeries,
   Series outputSeries
)

Parameters

pointCount
The number of data points that the filtering operation will not remove (or mark as empty).
Number of top/bottom points to return.
inputSeries
Series object that is filtered.
Input series.
outputSeries
Series object that stores the remaining data points. If it does not exist an exception will be thrown.
Output series.

Example

The following sample adds multiple data points that have unique date/time X-values and randomly set Y-values. Then Series1 is filtered so that only 10 data points are kept that have the largest first Y-values, and these points are stored in Series2. We only display the filtered data (we do not display Series1).
Visual Basic Copy Code
Imports Dundas.Charting.WebControl<CRLF> ...<CRLF><CRLF>Dim currentDate As DateTime<CRLF>Dim randomValues As New Random()<CRLF>Dim i As Int32<CRLF><CRLF>' Initialize variables<CRLF>currentDate = DateTime.Now.Date<CRLF><CRLF>' Add randomly-sized data points to Series1<CRLF>For i = 0 To 20<CRLF> Chart1.Series("Series1").Points.AddXY(currentDate.AddDays(i), randomValues.Next(0, 100))<CRLF>Next<CRLF><CRLF>' Filter out all points except the 10 data points with the largest Y values<CRLF>Chart1.DataManipulator.FilterTopN (10, Chart1.Series("Series1"), Chart1.Series("Series2"))<CRLF><CRLF>' Do not display Series1<CRLF>Chart1.Series("Series1").ChartArea = ""
C# Copy Code
using Dundas.Charting.WebControl;<CRLF> ...<CRLF><CRLF>System.DateTime currentDate = DateTime.MinValue;<CRLF>Random randomValues = new Random();<CRLF>Int32 i = 0;<CRLF><CRLF>// Initialize variables<CRLF>currentDate = DateTime.Now.Date;<CRLF><CRLF>// Add randomly-sized data points to Series1<CRLF>for (i = 0; i &lt;= 20; i++)<CRLF>{<CRLF>    Chart1.Series["Series1"].Points.AddXY(currentDate.AddDays(i), randomValues.Next(0, 100));<CRLF>}<CRLF><CRLF>// Filter out all points except the 10 data points with the largest Y values<CRLF>Chart1.DataManipulator.FilterTopN (10, Chart1.Series["Series1"], Chart1.Series["Series2"]);<CRLF><CRLF>// Do not display Series1<CRLF>Chart1.Series["Series1"].ChartArea = "";

Remarks

This method removes all data points from the input series except for a specified number of points that have the largest first Y (e.g. Y1) 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.

If the specified output series has not been created and added to the SeriesCollection when this function call is made an exception will be thrown.

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

Copyright © 2001 - 2009 Dundas Data Visualization, Inc. and others.