Hi
I'm trying to figure out, how to add tooltips to the XamDataChart when the series are added through converters. I'm adding the series like in this example http://www.infragistics.com/community/forums/p/93191/461934.aspx#461934 but just can't figure out, how to get tooltips "attached" to the series.
Thanks in advance
Dennis
Hi Dennis,
Is that the correct thread that you are referring to? The only sample on there is one from Stefan and the only converter in his sample is for collapsing the tickmark label. There is no series being created through a converter.
Regardless of how you create the series though, the series has a ToolTip property which you can set.
http://help.infragistics.com/doc/WPF/2014.2/CLR4.0/?page=DataChart_Chart_Tooltips.html
Hi Rob
Yes, I have based my solution on that answer. I'm only creating /adding new lineseries in the converter instead of the possibility of also collapsing them. But I just can't get it to work by adding a tooltip. Found an example where it was added in codebehind, but couldn't get it to work when adding it in the convert for the individual series.
The converter within that example is creating the series in the example. I have removed the collapsing stuff from the converter, so now it's not possible to remove the series again, which I don't need anyway...
Thank you very much for the sample. It cleared up some other questions I had.
The reason no tooltips appear is because the series is a ScatterLineSeries. With ScatterLineSeries we only display tooltips when you mouse over the markers. Unfortunately in this case you disabled the markers so no tooltip will show. The reason we do this is for performance. Please take a look at the following forum thread. There is code you can use for displaying tooltips on the ScatterLineSeries when you hover over the line instead of the marker.
http://www.infragistics.com/community/forums/p/61168/311338.aspx#311338
That explains why I couldn't get it work in that sample. However, in my application I'm using a LineSeries instead, so I guess that isn't the same problem in my case ?
So substituting the foreach with the below it's how the LineSeries is created.
foreach (KeyValuePair<string, ObservableCollection<DataItem>> keyValuePair in historicalTrendWidgetViewModel.PlotValues) {LineSeries lineSeries = new LineSeries();lineSeries.SetBinding(LineSeries.XAxisProperty, new Binding { Source = chart.Axes.FirstOrDefault() }); lineSeries.SetBinding(LineSeries.YAxisProperty, new Binding { Source = chart.Axes[1] });lineSeries.ItemsSource = keyValuePair.Value;lineSeries.ValueMemberPath = "Value"; lineSeries.XAxis.ItemsSource = historicalTrendWidgetViewModel.PlotValues.First().Value; lineSeries.Title = keyValuePair.Key;lineSeries.UnknownValuePlotting = UnknownValuePlotting.DontPlot;chart.Series.Add(lineSeries);}
And the XAML for the graph is here
<Grid> <ig:XamDataChart x:Name="DataChart" DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}" PlotAreaBackground="Transparent" SnapsToDevicePixels="True" BorderThickness="0" PlotAreaBorderThickness="0" Legend="{Binding ElementName=chartLegend}" IsHitTestVisible="True"> <ig:XamDataChart.Tag> <MultiBinding Converter="{StaticResource TrendPlotsToSeriesConverter}"> <Binding RelativeSource="{RelativeSource Self}"/> <Binding Path="DataContext.ConfigurationChange"/> </MultiBinding> </ig:XamDataChart.Tag> <ig:XamDataChart.Axes> <ig:CategoryDateTimeXAxis x:Name="xmXAxis1" ItemsSource="{Binding PlotValues}" MajorStrokeThickness="1" MinorStrokeThickness="0" DateTimeMemberPath="Time" DisplayType="Discrete"><!--Label="{}{Time:hh:mm}">--> <ig:CategoryDateTimeXAxis.LabelSettings> <ig:AxisLabelSettings Location="OutsideBottom" Extent="35" Angle="35" /> </ig:CategoryDateTimeXAxis.LabelSettings> <ig:CategoryDateTimeXAxis.Label> <DataTemplate> <TextBlock Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Presenters1:HistoricalTrendWidget}}, Path=DataContext.XaxisInterval, Converter={StaticResource visibilityConverter}}" Foreground="White" FontSize="10" Margin="-8,0,0,0"> <TextBlock.Text> <MultiBinding Converter="{StaticResource TextFormatConverter}"> <Binding Path="Item.Time"/> <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Presenters1:HistoricalTrendWidget}}" Path="DataContext.XaxisFormatting"/> </MultiBinding> </TextBlock.Text> </TextBlock> </DataTemplate> </ig:CategoryDateTimeXAxis.Label> </ig:CategoryDateTimeXAxis> <ig:NumericYAxis x:Name="xmYAxis" MajorStrokeThickness="1" MinorStrokeThickness="0" MajorStroke="White" SnapsToDevicePixels="True" MinimumValue="0" MaximumValue="105"> <ig:NumericYAxis.LabelSettings> <ig:AxisLabelSettings Location="OutsideLeft" Extent="35" Foreground="White" /> </ig:NumericYAxis.LabelSettings> </ig:NumericYAxis> </ig:XamDataChart.Axes> </ig:XamDataChart > <ig:Legend x:Name="chartLegend" Background="Transparent" Margin="0,0,0,55" HorizontalAlignment="Right" VerticalAlignment="Bottom" BorderThickness="0" ig:XamDock.Edge="InsideBottom" Foreground="White" Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Presenters1:HistoricalTrendWidget}}, Path=ShowConfigPopOut, Converter={StaticResource InverseBooleanToVisibilityConverter}}"/> </Grid>
I switched the ScatterLineSeries with a normal LineSeries using a CategoryDateTimeXAxis but I still can see the tooltips. I couldn't use all of your code as there were some objects I did not have, such as the HistoricalTrendWidget object. So I removed those bits. I also removed the DisplayType property as it was causing the CategoryDateTimeXAxis to add a grid line for every single data point. There were 10,000 data points so this caused a considerable performance hit.
I have attached the sample using LineSeries/CategoryDateTimeXAxis showing tooltips.
Let me know if you have any further questions on this matter.