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.
Unfortunately, activation email could not send to your email. Please try again.

Show X and Y values under mouse cursor

Thread ID:

Created:

Updated:

Platform:

Replies:

100892 Sep 13,2011 03:18 AM Jun 4,2012 09:40 AM ASP.NET Web Forms (Classic) 5
loading
Tags: Chart
Ashish Mondal
Asked On September 13, 2011 03:18 AM

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?


Sivakumar D [Syncfusion]
Replied On September 13, 2011 04:30 AM

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



Ashish Mondal
Replied On September 13, 2011 04:44 AM

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.


Sivakumar D [Syncfusion]
Replied On September 13, 2011 09:58 AM

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


Harikrishna
Replied On June 4, 2012 12:05 AM

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


Sivakumar D [Syncfusion]
Replied On June 4, 2012 09:40 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;