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?
Thank you for your reply and the clarification on the matter. I have been looking into the functionality that you have described and I can suggest the approach for getting the exact X value with some changes. You can use the same binding and converter and in the converter and you can cast the double value that the GetScaledValue will return, to integer. The integer value will correspond to the index from the ItemsSource, of the item corresponding to the DataPoint. I have modified the sample application that I have attached with my previous email, in order to demonstrate this approach.
I am just checking if you require any further assistance on the matter.
Sorry for the delay. I haven't had a chance to implement it for myself, but based on what you've described and the code you provided, this should suffice. Thank you for the help!
- Jason
Hello Jason,
Thank you for your reply. I am very glad that my reply was helpful for you. Please let me know if you need any further assistance on the matter.