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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Get mouse clicked X and Y axis values

Thread ID:

Created:

Updated:

Platform:

Replies:

146674 Aug 13,2019 02:38 PM UTC Aug 14,2019 07:16 AM UTC Angular - EJ 2 1
loading
Tags: Chart
Neo
Asked On August 13, 2019 02:38 PM UTC

Hi all,

How to get X and Y axis values when mouse clicking on the chart?

Thank you.

Kesavan Muthusamy [Syncfusion]
Replied On August 14, 2019 07:16 AM UTC

Hi Isanka, 

Greetings from Syncfusion. 

We have analyzed your query. We can obtain the x and y Axis values in the mouse click. To achieve this you can import the getValueXByPoint() and getValueYByPoint() from our package like in the below snippet: 

Code snippet:  
  mouseClick = (args: IMouseEventArgs) => { 
     
    this.xValue = getValueXByPoint(Math.abs(args.x - this.xAxis.rect.x), this.xAxis.rect.width, this.xAxis); 
    this.yValue = getValueYByPoint(Math.abs(args.y - this.yAxis.rect.y), this.yAxis.rect.height, this.yAxis) 
    alert('xValue:' + this.xValue.toFixed(3) + ' - ' + 'yValue:' + this.yValue.toFixed(3)) 
     
  } 

Output: 
 

Sample 
We have attached the stackblitz sample link for your reference. 

Please let us know if you have any concerns about this. 

Regards, 
Kesavan 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon