Hi team,
Hello elinder,
With the way the tooltip is defined, it doesn't need to be placed on every StackedFragmentSeries. It only needs to be placed on the StackedColumnSeries. This is because the template already displays the values presented by the StackedFragmentSeries, so there's no need to place a tooltip on each individual fragment series if they are all going to show the same data anyway.
The reason the tooltips aren't working is because DataTemplates cannot be assigned to the ToolTip directly. The tooltip needs to be assigned to a control and inside that control you can place something like a ContentPresenter to use your template.
<ig:StackedColumnSeries.ToolTip> <Grid> <ContentPresenter Content="{Binding}" ContentTemplate="{StaticResource TooltipTemplate}"/> </Grid> </ig:StackedColumnSeries.ToolTip>
I have attached a modified version of your sample that you can take a look at. Let me know if you have any questions.
Hi elinder,
Let me know if you have any further questions on this matter.
Hi Rob,
In the sample:
1. Tooltip values (Date, Item, Value and Percentage) are same for all the series (StackedFragmentSeries), which needs to be different - as per Chart's normal behavior.2. Tooltip Title is not working with Binding. It works if we set it directly in XAML.
In our scenario, we have defined all possible series in XAML (around 10), and in most of cases around 5 of them have data in DataSource. So, series generated in this scenario is correct but we can see all 10 Legends even if there is no data for a series. How can we control this behavior, so that Series and Legends stay synchronized?
You may refer attached sample application with snapshot showing first two scenarios.
1.) I'm not sure what you mean. If you look at the DataTemplate in my sample, it's binding to the Value1, Value2 and Value3 properties. These are the properties that the StackedFragmentSeries are bound to. So no matter which StackedFragmentSeries you hover over, it's going to show the same values. Only the title is going to change. If you move to a different column though, you will see the values change.
2.) The tooltip title isn't working with the binding you set because the DataContext of the window is an ObservableCollection. This means the DataContext of the chart is also this collection. The source of the binding on Title is the DataContext and ObservableCollection does not have a property called Title. This causes the binding to fail. You need to provide the correct source for the binding in order for it to work.
For the legend, the series is going to be visible in the legend as long as the StackedFragmentSeries is not collapsed, even if the value it's bound to is 0 or null. If you don't want the legend to display the series if the data associated with the series is empty, you can provide your own LegendItemTemplate and then bind the content Visibility to the series ItemsSource and ValueMemberPath using a MultiBinding. Inside your converter you would check to see if the ValueMemberPath inside the data source has a valid value. If no items in the data source have a valid value the converter will return collapsed and the legend item will be hidden. I've attached a modified version of your sample that demonstrates this.
The XamDataChart uses reflection in order to get the property values using the ValueMemberPath string, and reflection can't be used to get values from an ExpandoObject. Please see the following forum thread regarding this: http://es.infragistics.com/community/forums/t/48732.aspx
If you would like to see built in support for dynamic objects in the XamDataChart, I recommend that you submit this as a product idea at: http://ideas.infragistics.com
Your provided solution is great, We have one more issue with StackedFragmentSeries ValueMemberPath.
We have almost 10 StackedFragmentSeries, and we have a class that contains values like Value1 to Value10, and these values are assigned to StackedFragmentSeries ValueMemberPath (in sample application we use Value1, Value2 and Value3). Its working fine. But we want to use ExpandoObject to avoid defining large number of object properties, please see the employee, manager example from the following link
http://msdn.microsoft.com/en-us/library/system.dynamic.expandoobject(v=vs.100).aspx
By using this approach, XamDataChart is not displaying data, but this approach is working fine with ListBox.
can you please modify the sample by using ExpandoObject ?
It turns out I was wrong about the DataContext for your series Title binding. The StackedFragmentSeries object derives from DependencyObject so it doesn't even have a DataContext. This means it isn't going to inherit it's "parent's" DataContext, so your binding doesn't have any source. In order to bind this property, you are going to need to use a StaticResource binding. I've attached a modified version of the sample you sent me with the changes.
Regarding the datatemplate stuff, the templates you originally had threw me off because they used values from each series. So I was wondering why you needed to display a template for each StackedFragmentSeries if the content in the template was always the same. But your new sample shows that you changed the bindings to include the appropriate values based on the series. As such, I have modified your sample. It's not possible to assign DataTemplates directly to the series ToolTip property as it is expecting a UI control. The best you can do is move your templates into your Resources collection and then use the XAML code I sent you earlier on Oct 3rd. The code effectively does the same exact thing as before but it removes the templates from inside the XamDataChart XAML and allows you to put them into a resource dictionary so you can clean up the code some.
Your legend solution is great, but still we have some issues with other two points.
1. We want to display StackedFragmentSeries own value on mouse over, now i was defined tooltip of every StackedFragmentSeries, due to this approach we achieve desired results, but following this approach our code is redundant, we have almost 10 series and every series contains same tooltip code, only item.value changed, we want to replace this approach using DataTemplate like in previous sample application.
2. We tried to solve title binding according to your approach, but still not worked. Can you please modify the sample as you explained it in your previous reply?
I've attached a modified sample application.