Is it possible to access the corresponding X-axis value for an item in a series when displaying a LineSeries tooltip? For example, I'm using the following to display the Y-axis value and series title on the tooltip
<StackPanel x:Key="SeriesToolTip"> <TextBlock Margin="2" Text="{Binding Series.Title}" FontWeight="Bold" VerticalAlignment="Center" /> <StackPanel Orientation="Horizontal"> <TextBlock Margin="2" Text="{Binding Item.Magnitude}" VerticalAlignment="Center" /> <TextBlock Margin="2" Text="{Binding Series.Tag}" VerticalAlignment="Center" /> </StackPanel> </StackPanel>
However my "Item" object doesn't contain the x-axis value. Is there any way to obtain that correct x-axis value? Do I have to add it to my bound ItemsSource objects?
Hello,
Thank you for your post. I have been looking into your question and the Item property of the DataContext of the Tooltip is the data item corresponding to the closes data point of the series. Since the Item is containing the actual item of the ItemsSource of the series, you can use its properties, to get both X and Y value. Also if you wish to show the exact value of the X axis, based on the mouse position, you can use the GetUnscaledValue method of your axis. You can do that in the TollTip, by binding the Text of a TextBlock to the Series.XAxis and using a converter to get the mouse position based on the XamDataChart’s plot are and using the GetUnscaledValue method to get the exact X value. I have created a sample application for you, that shows how you can implement this approach.
Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Hi Krasimir,
Thanks for the information. The "exact value" X axis stuff could may be useful to me at some point, so I appreciate the example.
Regarding my initial question, the x axis values don't exist on my bound "Items". Only the Y axis values exist here. I'm plotting the magnitude of complex values, so each "Item" is that complex value. My domain is stored in another array containing the corresponding frequencies for each complex value. So, when setting up my chart, it's something like this:
series.ItemSource = block.ComplexValues
chart.XAxis.ItemsSource = block.FrequencyDomain
So as you can see, they're coming from different sources. Is there anyway to obtain the value contained in FrequencyDomain from within the Tooltip binding?