Skip to content

This article describes how to restrict the tooltip in WPF Chart when you hover over a line segment.

Notifications You must be signed in to change notification settings

SyncfusionExamples/How-to-restrict-the-tooltip-on-a-WPF-Chart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

How to restrict the tooltip on a WPF Chart

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 hovering over a segment and how to show the tooltip hovering over a marker of the segment.

To display the tooltip over a marker in the segment, you can use the ShowMarker property of the chart segment and set it to true. This will display markers on the chart segment, and the tooltip will appear over the marker when the pointer has hovered over it.

This is the actual behavior of tooltip rendering over a segment with a pointer position. You can set the Position of the tooltip as Pointer, it will display the information on every hover over the segment.

MainWindow-2023-02-13-10-26-12

The tooltip rendering on the segment has been restricted according to the code snippet below:

[C#]

public class LineSeriesExt : 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:LineSeriesExt ItemsSource="{Binding Data}"
                         XBindingPath="XValue"
                         YBindingPath="YValue"
                         ShowTooltip="True"
                         Palette="Metro">
        <local:LineSeriesExt.AdornmentsInfo>
            <chart:ChartAdornmentInfo ShowLabel="True" Background="Transparent" 
                                      SymbolHeight="40" SymbolInterior="White"
                                      SymbolWidth="40" Symbol="Ellipse" 
                                      SymbolStroke="Black" ShowMarker="True" />
        </local:LineSeriesExt.AdornmentsInfo>
    </local:LineSeriesExt>
</chart:SfChart>

MainWindow-2023-02-13-10-33-56

See Also,
How to provide animation effects for tooltip?
How to customize the tooltip in chart?
How to view the tooltip when segment is underneath the axis line?

About

This article describes how to restrict the tooltip in WPF Chart when you hover over a line segment.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages