Vaadin Charts: firing click event with hovered point

201 views Asked by At

I have a Vaadin chart like this:

chart with hovered point .

My goal is to get the hovered X value when clicking on the chart. Based on the previous image, I would like to get what month area is being clicked (the selected area is blue coloured in the image).

I've added a PointClickListener to that chart and inside that event I can get the needed information, but I have to click exactly hover the point. Clicking in the month area is not fired the PointClickListener:

chart.addPointClickListener(
        pointClickEvent -> {
          //Here I get the selected month:
          int monthIndex = event.getPointIndex();

So I would like to know if there's any method to obtain the hovered month by only clicking in that area, not exactly above the point.

1

There are 1 answers

1
Guille On

You could use Chart click event, and you will get the coordinates of the click, the event has info of the coordinates, for your purpose you could use the xAxisValue to know which point is in the clicked zone.