Only Show Tooltips on Data Points

I have created a chart with tooltips.  I only want to show tooltips for the red and blue lines, not for every point in the chart.

This picture shows tooltip for -126,4, that is an example of the points I do NOT want to show.  When I mouse over any other part of the chart I do not want tooltips.

How can I only display tooltips for the red and blue data?

This is how I create tooltips: 

         private void chartPhaseDiagram_MouseMove(object sender, MouseEventArgs e)
        {
            //The GetValueByPoint method returns the X and Y values of the ChartSeries calculated from the mousepoint.
            ChartPoint chpt = chartPhaseDiagram.ChartArea.GetValueByPoint(new Point(e.X, e.Y));

            string text =  chpt.X.ToString("n0") + "," + chpt.YValues[0].ToString("n0") ;

            //As mouse moves over the chartcontrol this displays the values as ToolTip.
            toolTip1.SetToolTip(chartPhaseDiagram, text);

        }



5 Replies 1 reply marked as answer

YP Yuvaraj Palanisamy Syncfusion Team October 30, 2020 01:41 PM UTC

   
Greetings from Syncfusion. 
 
We have analyzed your query and we would like to let you know that show tooltip when mouse over on the line by using the following code snippet. 
 
[C#] 
this.chartControl1.ShowToolTips = true; 
chartSeries1.PointsToolTipFormat = "{3}, {4}"; 
chartSeries1.FancyToolTip.Visible = true; 
  
Also, we have prepared the sample for your reference. Please find the sample from the below link. 
 
  
Output:  
 
 
For more details, please refer the below link. 
 
Regards, 
Yuvaraj 


Marked as answer

BT Beth Taylor November 2, 2020 02:46 PM UTC

Thank you very much.  I am able to see the tooltips.

I'd like to format the tooltip.   In the picture below, I only want to see 34.49, 37.73.  How can I remove the chartseries name and only show 2 decimal points for X and Y values?

Thank you,
Beth





YP Yuvaraj Palanisamy Syncfusion Team November 4, 2020 12:50 PM UTC

Hi Beth Taylor, 
  
We have analyzed your query and we have achieved your requirement “Tooltip show only 2 decimal value and removal of series name” by using PrepareStyle event of chart series. 
  
Please refer the below code snippet. 
  
[C#] 
…. 
  
chartSeries1.PrepareStyle += ChartSeries1_PrepareStyle; 
  
…. 
  
private void ChartSeries1_PrepareStyle(object sender, ChartPrepareStyleInfoEventArgs args) 
{ 
    ChartSeries series = sender as ChartSeries; 
  
    if (series != null) 
    { 
        args.Style.ToolTip = series.Points[args.Index].X.ToString("0.##")+ " , " + series.Points[args.Index].YValues[0].ToString("#.##"); 
  
        args.Handled = true; 
    } 
} 
  
  
Also, we have attached the sample for your reference. Please find the sample from the below link. 
  
  
For more detail, please refer the below link. 
  
Please let us know if you have any concern. 
  
Regards, 
Yuvaraj 



BT Beth Taylor November 4, 2020 01:34 PM UTC

Thank you for your response.  However I still have a problem.  I have used the preparestyle event.  It doesn't seem to be working.

I need the tooltip to be "x.99, y.99".  In this pic, I want the tooltip to be "-84.14, 19.15"


I set the tool tip format like this:

            bubblePointSeries.PrepareStyle += PhaseDiagram_PrepareStyleBubblePoint;
            dewPointSeries.PrepareStyle += PhaseDiagram_PrepareStyleBubblePoint;

            bubblePointSeries.PointsToolTipFormat = "{3},{4}";
            dewPointSeries.PointsToolTipFormat = "{3},{4}";

           bubblePointSeries.FancyToolTip.Visible = true;
           dewPointSeries.FancyToolTip.Visible = true;



     private void PhaseDiagram_PrepareStyleBubblePoint(object sender, ChartPrepareStyleInfoEventArgs args)
        {
            ChartSeries series = sender as ChartSeries;

            if (series != null)
            {
                args.Style.ToolTip = series.Points[args.Index].X.ToString("0.00") + "," + series.Points[args.Index].YValues[0].ToString("0.00");
                args.Handled = true;
            }
        }




YP Yuvaraj Palanisamy Syncfusion Team November 5, 2020 12:54 PM UTC

 
We have analyzed your query and you can achieve your requirement “Tooltip shows two decimal value” by removing the below lines. 
 
 
bubblePointSeries.PointsToolTipFormat = "{3},{4}"; 
dewPointSeries.PointsToolTipFormat = "{3},{4}"; 
  
 bubblePointSeries.FancyToolTip.Visible = true;
 dewPointSeries.FancyToolTip.Visible = true;
 
 
 
Output: 
 
 
Regards,
Yuvaraj.
 


Loader.
Up arrow icon