Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
665
X Axis Values in LineSeries Tooltip
posted

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?

Parents
  • 30945
    Offline posted

    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

    LineSeriesToolTip.zip
Reply Children