JavaFX LineChart Hover Values

Use XYChart.Data.setNode(hoverPane) to display a custom node for each data point. Make the hoverNode a container like a StackPane. Add mouse event listeners so that you know when the mouse enters and leaves the node. On enter, place a Label for the value inside the hoverPane. On exit, remove the label from the hoverPane.

There is some example code to demonstrate this technique.

Output of the sample code is shown with the cursor hovered over the 22 node.

hoverednode

Leave a Comment