You must be logged in to post your query.
Home › Forums › Chart Support › X-axis click event
If I click on axis x, how do I get the x coordinate of this point
@weijian-zhu2,
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:
jQuery(".canvasjs-chart-canvas").last().on("click", function(e){ var parentOffset = $(this).parent().offset(); var relX = e.pageX - parentOffset.left; var xValue = Math.round(chart.axisX[0].convertPixelToValue(relX)); console.log(xValue); });
— Thangaraj Raman Team CanvasJS
Thank you very much. I’ll try it right away
You must be logged in to reply to this topic. Login/Register