Pre loader

FAQ: How to apply a TooltipLabelTemplate Selector to the RolloverModifier, TooltipModifier and VerticalSliceModifier

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums


A question was recently asked on priority support tickets – how to to apply a Template Selector to the RolloverModifier, to display different tooltips based on series type?

We are answering the question below so that other users can benefit from it!

  • You must to post comments
Best Answer

Using the API from v3.2/v3.3 of SciChart, we can do the following:

1. Declare a RolloverModifier in your XAML

    <s:ModifierGroup s:MouseManager.MouseEventGroup="ChartGroup">
        <s:RolloverModifier ShowTooltipOn="Always"
                            TooltipLabelTemplateSelector="{StaticResource PriceRolloverTooltipTemplate}" />

2. Declare a template selector in the resources

3. Where the OhlcSeriesTemplate is defined as

<!-- Overlay Border Style -->
<Style x:Key="OverlayBorderStyle" TargetType="Border">
    <Setter Property="Padding" Value="3 1 3 1" />
    <Setter Property="Background" Value="#165284" />
    <Setter Property="BorderBrush" Value="White" />
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="Opacity" Value="0.9" />

<!-- Overlay Text Style -->
<Style x:Key="OverlayTextStyle" TargetType="TextBlock">
    <Setter Property="FontSize" Value="11" />
    <Setter Property="Foreground" Value="White" />
    <Setter Property="HorizontalAlignment" Value="Left" />

<DataTemplate x:Key="EmptyDataTemplate" />

<!-- OhlcSeries Rollover Template -->
<!-- Note the SeriesInfo types that are binding to --> 
<DataTemplate x:Key="OhlcSeriesRolloverTooltipTemplate" DataType="scichart:OhlcSeriesInfo">
    <Border Style="{StaticResource OverlayBorderStyle}" >
        <StackPanel Orientation="Vertical">
            <TextBlock Style="{StaticResource OverlayTextStyle}"
                Text="{Binding OpenValue, Mode=OneWay}" />
            <TextBlock Style="{StaticResource OverlayTextStyle}"
                Text="{Binding HighValue, Mode=OneWay}" />
            <TextBlock Style="{StaticResource OverlayTextStyle}"
                Text="{Binding LowValue, Mode=OneWay}" />
            <TextBlock Style="{StaticResource OverlayTextStyle}"
                Text="{Binding CloseValue, Mode=OneWay}" />

What are the SeriesInfo types?

Each DataTemplate has as a SeriesInfo type as its DataContext. You can find out more info about the SeriesInfo types and properties at the article SeriesInfo – The Series ViewModel for Legends, Tooltips, Rollovers

What is the result?

See attached image. In this example we choose to hide all tooltips for series other than Ohlc series. The Ohlc has a custom tooltip

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.