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
close icon

Show X and Y values under mouse cursor

Is there is way to show the X and Y values of a chart under the the mouse cursor when we hover the mouse over a chart?


5 Replies

SD Sivakumar D Syncfusion Team September 13, 2011 08:30 AM UTC

Hi Ashish,

Thanks for using syncfusion products.

We suggest you to use Tooltip property of series to get the X and Y values of the chart.Please refer below code snippet.

[C#]

this.ChartWebControl1.ShowToolTips = true;
series.PointsToolTipFormat = "{2}";
for (int i = 0; i < series.Points.Count; i++)
{
series.Styles[i].ToolTip = string.Format("X = {0}, Y = {1}", series.Points[i].X.ToString(), series.Points[i].YValues[0]);
}


For more information about tooltip,please refer our online documentation links below.

http://help.syncfusion.com/ug_93/User%20Interface/ASP.NET/Chart/Documents/45185tooltip.htm

http://help.syncfusion.com/ug_93/User%20Interface/ASP.NET/Chart/Documents/45186tooltipformat.htm

For your convenience, we have created sample and the same can be downloaded from the following link.

100892_Chart-355776587.zip

Please let me know if you have any other questions or concerns.

Regards,
Siva




AM Ashish Mondal September 13, 2011 08:44 AM UTC

Thanks for the quick response.

But I want to show the X-Y values even when there is nothing plotted on the chart.

That is, the X-Y values shown will correspond to actual location of mouse cursor on the graph.

Also, the tool tip should be visible for as long as the mouse is over the chart.



SD Sivakumar D Syncfusion Team September 13, 2011 01:58 PM UTC

Hi Asish,

Thanks for your update.

We are sorry for inconvenience caused.In our current implementation of chartwebcontrol doesn't support to show the actual location of x and y values when there is nothing plotted on the chart.Tooltip property of series is displayed only when there is a points in the chart and also tooltip is visible as long as mouse over the points in the chart.

Please let me know if you have any other questions or concerns.

Regards,
Siva



HA Harikrishna June 4, 2012 04:05 AM UTC

Hi Siva,

This is Hari, I have a similar requirement as Asish mentioned but I am using syncfusion charts in WPF and I am able to show the tool tip on the deviation on the chart i.e., on change in angle inclination/declination, I have a requirement that I have to show the toop tip when ever we place mouse pointer on the chart irrespective of the plotted areas we need to take Horizontal and Vertial cline which bisects/touches the plotted points and need to show the point of intersection on the toop tip., It would be great help if you could tell me is it possible to show..,

 

Thanks,

 Hari



SD Sivakumar D Syncfusion Team June 4, 2012 01:40 PM UTC

Hi Ashish,

Thanks for your update.

We suggest you to use PrepareStyle event of ChartSeries to show the X any Y values for each point when mouse over the chart. When a series point is about to be rendered by the chart, it will raise this event and allow event subscribers to change the style used.

We can use GetValueByPoint and   GetPointByValue method of Chart Area to get the X and Y values for each point in the chart. Please refer below code snippet.

[C#]
<code>
void series_PrepareStyle(object sender, ChartPrepareStyleInfoEventArgs args)
    {
        ChartSeries series = sender as ChartSeries;
        if (series != null)
        {
            ChartPoint chpt = new ChartPoint(series.Points[args.Index].X, series.Points[args.Index].YValues[0]);
            Point pt = ChartWebControl1.ChartArea.GetPointByValue(chpt);
            ChartPoint cpoint = ChartWebControl1.ChartArea.GetValueByPoint(pt);

            args.Style.ToolTip = "Chart Point - " + chpt.ToString() + "<br/>Result of method GetPointByValue - " + pt.ToString() + "<br/>Result of method GetValueByPoint - {" + cpoint.X.ToString() + "," + cpoint.YValues[0].ToString() + "}";
        }
    }
</code>

For more information about PrepareStyle event, Please refer our online documentation link below.

http://help.syncfusion.com/UG/User%20Interface/ASP.NET/Chart/default.htm#!Documents/4174preparestyleevent.htm

Online Sample link:

http://asp.syncfusion.com/demos/ui/chart/User%20Interaction/ChartGetValue/CS/ChartGetValueSample.aspx

Please let me know if we misunderstood your requirement.

Regards,
Siva



100892_Chart_25356de1.zip

Loader.
Live Chat Icon For mobile
Up arrow icon