Hi team,
Hi elinder,
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.
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.
Let me know if you have any further questions on this matter.
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.