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

Hierarchical legend

Hi, I am trying to develop a hierarchical legend in one of my charts.

The idea is very much similar to what is shown in the following link:
http://manyeyes.alphaworks.ibm.com/manyeyes/visualizations/us-government-expenses-1962-2004

Is there support in the library that will let me make a legend like this? Or do I have to tweak the code according to my needs? Any other suggestions...?

I am a licensed customer and have access to the source code.

Regards,
Saad

Using:
Essential Studio WPF Edition 2009 vol 1 (7.1.0.21)
VS 2008 .Net framework 3.5


11 Replies

PJ Pavithra J Syncfusion Team February 20, 2009 12:30 PM UTC

Hi Saad,

Thanks for your interest in Syncfusion products.

ChartLegend with its item will be automatically loaded while rendering a ChartSeries. So you cannot achieve your requirement with the help of ChartLegend. Also, we could see that the sample from the link provided by you doesn't seems to a be Legend.

You requirement can be satisfied with the help of a TreeView. You can use a seperate TreeView Control and when a TreeView Item is selected you can load the chart series.

Please let us know if you require a sample with TreeView Control and also if you have any queries.

Regards,
Pavithra.J



SA Saad February 24, 2009 01:58 PM UTC

Thanks...I tried what you said. Now, I have a very simple TreeViewAdv with TreeViewItemAdv(s) added in XAML code. The tree looks like this:

+ All
> Item1
>> Item1_1
>>> Item1_1_1
>>> Item1_1_2
>>> Item1_1_3
...
>> Item1_2
...
>> Item1_3
...
> Item2
...
> Item3
...

Here is how I add an item in the tree:














It works fine but every once in a while I get an exception. It occurs randomly and is never raised from my code. It usually happens when the mouse is over(hover not click) any of the tree items.

Exception:

System.InvalidOperationException was unhandled
Message="Specified element is already the logical child of another element. Disconnect it first."
Source="PresentationFramework"
StackTrace:
at System.Windows.FrameworkElement.ChangeLogicalParent(DependencyObject newParent)
at MS.Internal.FrameworkObject.ChangeLogicalParent(DependencyObject newParent)
at System.Windows.FrameworkElement.AddLogicalChild(Object child)
at System.Windows.Controls.ContentControl.OnContentChanged(Object oldContent, Object newContent)
at System.Windows.Controls.ContentControl.OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at System.Windows.Data.BindingOperations.SetBinding(DependencyObject target, DependencyProperty dp, BindingBase binding)
at System.Windows.Controls.PopupControlService.RaiseToolTipOpeningEvent()
at System.Windows.Controls.PopupControlService.OnRaiseToolTipOpeningEvent(Object sender, EventArgs e)
at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at TreeViewItemsControlSource.App.Main() in C:\Documents and Settings\semosaa\My Documents\Visual Studio 2008\Projects\TreeViewItemsControlSource\TreeViewItemsControlSource\obj\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:






PJ Pavithra J Syncfusion Team February 25, 2009 01:43 PM UTC

Hi Saad,

Thanks for your interest in Syncfusion products.

We couldn't reproduce the issue mentioned by you. Please refer to the attached sample in which we have used TreeViewAdv and added items to it. You can download the sample from the below given link,

TreeViewSample

Here, in this sample when you click the treeview item , the series corresponding to the selected TreeviewItem will be loaded.

Please let us know if you have further queries.

Regards,
Pavithra.J



SA Saad March 5, 2009 07:25 AM UTC

Thank you for the reply and the solution!
I am doing it the same way as in the example code but the exception still pops up. I'll reply back with my findings if I succeed in fixing this issue. For now, I am using .Net's TreeView control.



PJ Pavithra J Syncfusion Team March 6, 2009 05:48 AM UTC

Hi Saad,

Thanks for your interest in Syncfusion products.

We deeply regret for this inconvenience caused.

We are not able to reproduce your mentioned issue. We suspect that there might be some problems with the assemblies installed in your machine. Could you please try uninstalling the EssentialStudio and reinstall it freshly.

Please let us know, if the issue prevails even after the reinstallation.

Regards,
Pavithra.J




SA Saad April 1, 2009 07:32 AM UTC

Hi,

I found a fix to the problem. However, I still don't understand what caused the exception in the first place.

This is what I was doing before:






I wrapped the Checkbox in a StackPanel and also put it in a UserControl later. Both of these approaches somehow fixed the exception I was getting.





... contains checkbox and other controls ...






Regards,
Saad




PJ Pavithra J Syncfusion Team April 1, 2009 01:32 PM UTC

Hi Saad,

Thanks for your interest in Syncfusion products.

We are not able to reproduce your mentioned issue. As we said already have you tried uninstalling the EssentialStudio and reinstall it freshly.

Regards,
Pavithra.J



SA Saad April 2, 2009 07:26 AM UTC

Thanks for the suggestion. Yes, I have tried reinstalling and even tried it on a different machine but couldn't get rid of the issue until I tried the solution I posted above.

/Saad



PJ Pavithra J Syncfusion Team April 3, 2009 06:27 AM UTC

Hi Saad,

Thanks for your interest in Syncfusion products.

We will analyze more about the issue mentioned by you. If we could reproduce it we will log it as a defect and resolve it in future.

Please let us know if you have further query.

Regards,
Pavithra.J



HI Himani replied to Saad February 25, 2018 01:23 PM UTC

Hi,

I found a fix to the problem. However, I still don't understand what caused the exception in the first place.

This is what I was doing before:






I wrapped the Checkbox in a StackPanel and also put it in a UserControl later. Both of these approaches somehow fixed the exception I was getting.





... contains checkbox and other controls ...






Regards,
Saad



Hi,
I want to download this file


KJ Keerthana Jegannathan Syncfusion Team February 26, 2018 12:35 PM UTC

Hi Himani,

As our previous link has been expired, you are not able to download our TreeViewAdv sample. In the updated sample, we have provided the simple TreeViewAdv control with items loaded in it in XAML. Can you please confirm whether you are required this sample? Based on your update, we will create a new sample with TreeViewAdv in order to provide the solution.

Regards,
Keerthana J

Loader.
Live Chat Icon For mobile
Up arrow icon