Articles in this section
Category / Section

How to restrict the tooltip on a WPF Chart?

5 mins read

The WPF Chart tooltip displays data information over a chart segment by setting the ShowTooltip  property to true. This section explains how to restrict the tooltip from appearing over the entire segment and instead display it only over a marker within the segment.


To display the tooltip over a marker in the segment, set the ShowMarker property of the chart segment to true. This adds markers to the chart, and the tooltip will appear when the pointer hovers over a marker.


By default, the tooltip is displayed over the segment based on the pointer's position. To display the tooltip specifically at the pointer location during hover, set the tooltip's Position property to Pointer.


Output:


Default tooltip display.


To restrict tooltip rendering on the segment, refer to the following code samples:

 

[C#]

public class ExtLineSeries : LineSeries
{
 protected override void OnMouseMove(MouseEventArgs e)
 {
  //To restrict tooltip when hover on the line segment
  if (e.OriginalSource is Line)
   return;
  base.OnMouseMove(e);
 }
}

[XAML]

<chart:SfChart>
    <chart:SfChart.PrimaryAxis>
        <chart:CategoryAxis PlotOffset="20" ShowGridLines="False" />
    </chart:SfChart.PrimaryAxis>
 
    <chart:SfChart.SecondaryAxis>
        <chart:NumericalAxis Maximum="120" Minimum="0" ShowGridLines="False" PlotOffset="12"/>
    </chart:SfChart.SecondaryAxis>
 
    <chart:SfChart.Behaviors>
        <chart:ChartTooltipBehavior Position="Pointer"/>
    </chart:SfChart.Behaviors>
 
    <local:ExtLineSeries ItemsSource="{Binding Data}"
                         XBindingPath="XValue"
                         YBindingPath="YValue"
                         ShowTooltip="True"
                         Palette="Metro">
        <local:ExtLineSeries.AdornmentsInfo>
            <chart:ChartAdornmentInfo ShowLabel="True" Background="Transparent" 
                                      SymbolHeight="40" SymbolInterior="White"
                                      SymbolWidth="40" Symbol="Ellipse" 
                                      SymbolStroke="Black" ShowMarker="True" />
        </local:ExtLineSeries.AdornmentsInfo>
    </local:ExtLineSeries>
</chart:SfChart>
Output:


Tooltip will display only on marker.


Download the complete sample on GitHub


Conclusion

I hope you enjoyed learning about how to restrict the tooltip on a WPF Chart (SfChart).

You can refer to our WPF Charts feature tour page to know about its other groundbreaking feature representations. You can also explore our WPF Chart documentation to understand how to present and manipulate data.

For current customers, you can check out our WPF Controls from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our WPF Charts and other WPF controls.

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!


See also

 

How to provide animation effects for the tooltip?


How to customize the tooltip in the chart?


How to view the tooltip when a segment is underneath the axis line?

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied