Home Forums Chart Support X-axis click event

X-axis click event

Viewing 3 posts - 1 through 3 (of 3 total)
  • #42219

    If I click on axis x, how do I get the x coordinate of this point



    You can bind mouse events to the chart container and get mouse coordinates in pixels, which can be converted to corresponding values along the axis using convertPixelToValue as shown in this documentation page. Please take a look at the code snippet below:

    	var parentOffset = $(this).parent().offset();
    	var relX = e.pageX - parentOffset.left;
    	var xValue = Math.round(chart.axisX[0].convertPixelToValue(relX));

    Thangaraj Raman
    Team CanvasJS


    Thank you very much. I’ll try it right away

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.