We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Display multiple tooltips based on maximum and minimum of data

Background: I have a chart with a data source. This chart has a tooltip enabled so that when a user presses one of the points (line, bar, etc), the tooltip shows.

Question: Can I have two tooltips hovering over the minimum and maximum values of the data? I have these values, but I would like a tooltip for both at the same time on the chart indicating them to the user.

Additionally, I would like the user to be able to press one of the points on the chart and the min/max tooltips to go away, and reappear when the user’s choice times out. I understand that this will involve working with the OnClick event or whatever it’s called.

Thanks in advance.


1 Reply

MK Muneesh Kumar G Syncfusion Team September 11, 2019 09:56 AM UTC

Hi Daniel, 
 
Greetings from Syncfusion.  
 
Query 1: Can I have two tooltips hovering over the minimum and maximum values of the data? I have these values, but I would like a tooltip for both at the same time on the chart indicating them to the user. 
 
We have analyzed your requirement and if you want to show the two values for the single series means, you can achieve this by using the TooltipTemplate property which is available in ChartSeries. Please refer the below code. 
 
Code snippet[XAML]: 
<DataTemplate x:Key="template"> 
    <StackLayout Orientation="Vertical"> 
        <StackLayout Orientation="Horizontal"> 
            <Label Text="Minimum :" /> 
            <Label Text="{Binding Value1}"/> 
        </StackLayout> 
        <StackLayout Orientation="Horizontal"> 
            <Label Text="Maximum :" /> 
            <Label Text="{Binding Value2}"/> 
        </StackLayout> 
    </StackLayout> 
</DataTemplate> 
 
-      - 
<chart:LineSeries ItemsSource="{Binding LineData1}" XBindingPath="XValue" YBindingPath="Value1" EnableTooltip="True" TooltipTemplate="{StaticResource template}"> 
</chart:LineSeries> 
 
Note – The BindingContext for the tooltip data template will be the respective underlying object from ItemsSource. So, you can bind the values only if it is present in that model. 
 
 
Or if your requirement is to show the data point for all the YValues present in the same XValue, you have to use the TrackballBehavior. Please refer the below code. 
 
Code snippet[XAML]: 
<chart:SfChart.ChartBehaviors> 
    <chart:ChartTrackballBehavior ShowLine="False" /> 
</chart:SfChart.ChartBehaviors> 
 
 
Query 2:  I would like the user to be able to press one of the points on the chart and the min/max tooltips to go away, and reappear when the user’s choice times out. 
 
You can achieve this by using the Hide and Show methods of TooltipBehavior. Please refer the below code. 
 
Code snippet [C#]: 
tooltipBehavior.Show(pointX, pointY, true); 
 
-     -  
 
tooltip.Hide(true); 
 
Please refer the below UG for more details: 
 
 
If the above solution not fulfilled your requirement. Please share the image you want to achieve. This would be helpful for us to provide you a better solution at the earliest. 
  
Thanks, 
Muneesh Kumar G. 
 


Loader.
Live Chat Icon For mobile
Up arrow icon