Dynamic Filter in C#.NET

Jan 21, 2010 at 10:25 AM

Hi,

I want to use the Dynamic Filter features of Excel Template in the program while drawing vertex and edges so i can filtered out some edges and vertices.

how to achieve this in the program?

Help me. :-)

Thanks in advance

-pasa

Jan 21, 2010 at 5:43 PM

Pasa:

To use Dynamic Filters:

1. Click NodeXL, Graph, Show Graph (or Refresh Graph) to read the workbook into the graph pane.

2. Click NodeXL, Analysis, Dynamic Filters.  The Dynamic Filters dialog box will show a slider for each numeric, date, and time column in the Vertices and Edges worksheet.

3. Adjust the sliders.  The vertices and edges that don't fall within the slider ranges will disappear from the graph pane.

-- Tony

Jan 21, 2010 at 5:46 PM

Are you writing your own application using our NodeXLControl?  If so, then Dynamic Filters cannot be reused in other applications.  It uses Excel formulas to do the filtering and so it is tied to the Excel template.

-- Tony

Jan 21, 2010 at 7:18 PM

yes, i am writing my own application.

I am using the Tag properties of edges and vertices to hide the visibility of them in the graph depending upon the value in the respective tag.

Is this what you guys use in the dynamic filter to hide along with excel formula or just pure excel formula only?

-pasa

Jan 21, 2010 at 8:33 PM
Edited Jan 21, 2010 at 8:34 PM

To filter vertices and edges in the NodeXLControl, you don't need to use the Tag and you don't need to modify the graph drawing code.  Instead, set the ReservedMetadataKeys.Visibility key on the vertices and edges to VisibilityKeyValue.Filtered, and the NodeXLControl will automatically draw them as filtered.  That's what the Excel Template code does.  If you don't like the default alpha value that the NodeXLControl uses to draw filtered vertices and edges (alpha=10), set the NodeXLControl.FilteredAlpha property to something else.

-- Tony

Jan 22, 2010 at 6:04 AM

hi,

i have used tag to identify the particular node so that if i can only show some particular node and hide others.

I have assigned the tag with an object having age as the member so that i can hide nodes have age, say, greater than 50.To hide the node of that particular tag value i set the ReservedMetadataKeys.Visibility key on the vertices to VisibilityKeyValue.Hidden. i can use VisibilityKeyValue.Filtered also with aplha value=0.

what i want to know is in EXCEL Template when the user add the column. How that column is bind to the edges and vertices and on the basis of that how the dynamic filter is done. like if new column is age how the dynamic filter only shown vertices and edge related to the particular edge.

for this i made class containing those new column and assign its object to tag so that i can filter on the basis of tag value.

thanks

pasa

 

Jan 22, 2010 at 5:39 PM
Edited Jan 22, 2010 at 5:40 PM

Pasa:

The Excel template makes Excel do all the actual filtering work for its Dynamic Filters feature.  The relevant code is in the DynamicFilterDialog class.  Below is the header from that class that explains how the filtering works.  If you wanted to see the hidden columns and table that NodeXL uses for filtering, you would have to unhide column I (Dynamic Filter) on the Edges worksheet, column Z (Dynamic Filter) on the Vertices worksheet, and the DynamicFilterSettings table on the Misc worksheet.

-- Tony

//*****************************************************************************
//  Class: DynamicFilterDialog
//
/// <summary>
/// Displays a dynamic filter for each column in the edge and vertex worksheets
/// that can be filtered on.
/// </summary>
///
/// <remarks>
/// This is a modeless dialog.  To show it, call its <see
/// cref="Form.Show(IWin32Window)" /> method.
///
/// <para>
/// A dynamic filter is a control that can be adjusted to selectively show and
/// hide edges and vertices in the graph in real time.
/// </para>
///
/// <para>
/// This dialog shows a RangeTrackBar or DateTimeRangeTrackBar control for each
/// numeric or date/time column in the edge and vertex worksheets.  The
/// available range of the track bar is set to the range of numbers in the
/// column.  As the user changes the track bar's selected range, the edges or
/// vertices that fall outside the selected range are hidden in the TaskPane in
/// real time.
/// </para>
///
/// <para>
/// The filtering is implemented using an Excel formula this dialog writes to
/// a Dynamic Range column added to the edge table, and another formula written
/// to the vertex table.  The formula yields a Boolean that specifies whether
/// the edge or vertex should be shown in the graph.  The TaskPane reads these
/// columns and shows and hide the graph's edges and vertices based on the
/// Boolean values.
/// </para>
///
/// <para>
/// The Excel formula looks like this, in pseudocode:
/// </para>
///
/// <para>
/// if (column N of this row is between X and Y) then TRUE else FALSE
/// </para>
///
/// <para>
/// The X and Y values come from a hidden table that this dialog populates.
/// The hidden table has one row per dynamic filter, and the columns are the
/// filtered table name, the filtered column name, and the filter's current
/// selected range.  As the user change's a track bar control's selected range,
/// this dialog updates the appropriate row in the hidden table, tells Excel to
/// recalculate the Dynamic Filter column in the edge or vertex worksheet, and
/// fires a <see cref="DynamicFilterColumnsChanged" /> event telling the
/// TaskPane to read the columns.
/// </para>
///
/// <para>
/// In addition to the <see cref="DynamicFilterColumnsChanged" /> event, the
/// TaskPane should handle the <see cref="FilteredAlphaChanged" /> event and
/// redraw the graph with the new filtered alpha value when the event fires.
/// </para>
///
/// </remarks>
//*****************************************************************************