We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Heirarchical Levels do not work

Hi,

I'm having trouble getting the SfTreeMap control to display heirarchical levels properly. 

I have a two-tiered heirarchy consisting of an ObservableCollection<TreeMapDept>, each TreeMapDept of which contains an ObservableCollection<TreeMapSubDept>. In other words:

public class TreeMapSubDept {
   public double TreeMapWeight;
   public double TreeMapLeafLabel; 
   // various business attributes
}

public class TreeMapDept {
   public ObservableCollection<TreeMapSubDept> TreeMapSubDepts;
   public double TreeMapWeight;
   public double TreeMapLeafLabel; 
   // various business attributes
}

public class ViewModel {
   public ObservableCollection<TreeMapDept> Depts;
}

My XAML looks like this:

I am able to display the flat level of Depts with the following XAML:

<TreeMap:SfTreeMap
         ItemsSource="{Binding Depts}"
         WeightValuePath="TreeMapWeight"
         LeafLabelPath="TreeMapLeafLabel">
         <TreeMap:SfTreeMap.LeafColorMapping>
            <TreeMap:DesaturationColorMapping />
         </TreeMap:SfTreeMap.LeafColorMapping>
         <TreeMap:SfTreeMap.Levels>
            <TreeMap:TreeMapFlatLevel
               ShowLabels="True" />
         </TreeMap:SfTreeMap.Levels>
      </TreeMap:SfTreeMap>
   
However, when I want to display a heirarchical level, with the following XAML:

<TreeMap:SfTreeMap
         ItemsSource="{Binding Depts}"
         WeightValuePath="TreeMapWeight"
         LeafLabelPath="TreeMapLeafLabel">
         <TreeMap:SfTreeMap.LeafColorMapping>
            <TreeMap:DesaturationColorMapping />
         </TreeMap:SfTreeMap.LeafColorMapping>
         <TreeMap:SfTreeMap.Levels>
            <TreeMap:TreeMapHierarchicalLevel
               ChildPath="TreeMapSubDepts"
               ShowLabels="True" />
         </TreeMap:SfTreeMap.Levels>
      </TreeMap:SfTreeMap>

I get the following exception:

ArgumentException: Specified Path () does not match with any fields in given DataSource
   at Syncfusion.UI.Xaml.TreeMap.TreeMapEngine.GetValue(String field, Object o)
   at Syncfusion.UI.Xaml.TreeMap.TreeMapEngine.GetTreeMapItems(String valueData, String colorData, String labelData, String headerData)
   at Syncfusion.UI.Xaml.TreeMap.SfTreeMap.GenerateTreeMapItems()
   at Syncfusion.UI.Xaml.TreeMap.SfTreeMap.SfTreeMap_SizeChanged(Object sender, SizeChangedEventArgs e)

InnerException: None

I have verified at runtime that the ViewModel's object graph is correctly built and populated. What do I have to do to get heirarchical levels to show up in the TreeMap?

1 Reply

DR Dhanasekar R Syncfusion Team June 26, 2014 12:06 PM UTC

Hi Daniel, 

Thanks for your interest in syncfusion products. 

The following mistakes you have done in your sample

1) All the Properties should be Dependency Property or CLR Property.

2) ColorValuePath is a mandatory property. (You can give value of WeightValuePath).

Please find the attached sample for reference

Please let us know if any further clarifications.

Regards,

Dhanasekar R


Attachment: TreeMapSample_2f4e0100.zip

Loader.
Up arrow icon