Friday, December 21, 2007

HierarchicalData from Flat XMLList data where nodes have parent info

This example shows how to make ADG display data in a Treeview or HierarchicalView when the source data is flat XMLList of nodes and each node has information about its parent node. Sample data is shown below:

<?xml version="1.0" encoding="utf-8"?>

<tasks>

<task id="1" name="Advanced Data Grid" type="parent" parentTask="0"/>

<task id="2" name="Collections" type="parent" parentTask="0"/>

<task id="3" name="OLAP" type="parent" parentTask="0"/>

<task id="4" name="Treeview" type="parent" parentTask="1"/>

<task id="5" name="Column grouping" type="parent" parentTask="1"/>

<task id="6" name="IHierarhcicalData, IGroupingCollection" type="child" parentTask="2"/>

<task id="7" name="Concrete classes" type="child" parentTask="2"/>

<task id="8" name="OLAP Interfaces" type="child" parentTask="3"/>

<task id="9" name="OLAP DataGrid" type="child" parentTask="3"/>

<task id="10" name="Charts" type="parent" parentTask="0"/>

<task id="11" name="Region selection" type="child" parentTask="10"/>

<task id="12" name="Drag drop support" type="child" parentTask="10"/>

<task id="13" name="Tree items display" type="child" parentTask="4"/>

<task id="14" name="Drag drop support" type="child" parentTask="4"/>

<task id="15" name="Column spec" type="child" parentTask="5"/>

<task id="16" name="Column drag drop" type="child" parentTask="5"/>

<task id="16" name="Column Ressize" type="child" parentTask="5"/>

</tasks>

Here each node has a parentTask attribute which specifies the parent task id. The top most nodes have parent task attribute set to zero. The nodes can be in any order.

We use the FlatXMLHD class which implements the IHierarchicalData interface to hide the XMLList parsing details. The result :

The source is available here.

Friday, December 7, 2007

Displaying GroupingCollection/HierarchicalData in Charts with drill-down

This example shows how to use GroupingCollection/HierarchicalData as dataProvider to a Chart and how to support drill down and drill up navigation.

Click on any item to drill-down and Ctrl+Click on any item to drill-up. The top chart uses HierarchicalData sample and the second chart uses GroupingCollection to generate a summary information from flat data.

Please note that all data is fictitious and I just cooked it up for the sample.

To get access to parent and children collections a HierarchicalCollectionView is constructed using GC/HD as source. To display a drilled down view the children collection is set as charts dataProvider. For a drill-up operation the clicked items parent collection is set as dataProvider.

The source can be downloaded from here.

I have used the DrillDown, DrillUp effects from Ely's chart drill down sample of XML data. The sample would have looked a bit dull without them. Thanks to Ely!.