How to Change the Cursor to a Hand Pointer in a JavaScript Chart?
To change the mouse cursor to a hand pointer when hovering over the bars in a JavaScript Chart, you can use the chartMouseMove event. This event is triggered whenever the mouse moves over any part of the chart. Inside the event handler, the args.target property helps identify which chart element the mouse is currently over.
Bar elements in the chart typically have IDs that include the string βbar-container_Series_β. By checking if args.target includes this substring, you can detect when the mouse is hovering over a bar. Once identified, use document.getElementById(args.target) to access the DOM element and set its style.cursor property to βpointerβ, which changes the cursor to a hand icon.
Code Example
var chart = new ej.charts.Chart({
  ...
 chartMouseMove: function (args) {
   if (args.target.includes('bar-container_Series_')) {
     document.getElementById(args.target).style.cursor = 'pointer';
   }
 },
});
chart.appendTo('#bar-container'); 
Output
Sample
Conclusion
I hope you enjoyed learning about how to change the cursor to a hand pointer in a JavaScript Chart.
You can refer to our JavaScript Chart feature tour page to learn about its other groundbreaking feature representations. You can also explore our JavaScript Chart Documentation to understand how to present and manipulate data.
For current customers, you can check out our JavaScript components on the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to explore our JavaScript Chart and other JavaScript components.
If you have any queries or require clarifications, please let us know in the comments below. You can also contact us through our support forums, Direct-Trac or feedback portal, or the feedback portal. We are always happy to assist you!
