'How can i get mouse cursor value in Java Chart? [duplicate]

I try to get mouse cursor values in Java Chart. I have two variables on Y axis and I have one variable on X axis. My y axis variables looks like: enter image description here and I use crosshair to get the values of axis. My code is attached below.

@Override
public void chartMouseMoved(ChartMouseEvent event){
  ChartEntity chartEntity = event.getEntity();
  if(chartEntity instanceof XYItemEntity)
  {
     XYItemEntity xyItemEntity = (XYItemEntity) chartEntity;
     XYDataset xyDataSet = xyItemEntity.getDataset();
     this.xCrosshair.setValue(xyDataSet.getXValue(xyItemEntity.getSeriesIndex(), 
     xyItemEntity.getItem()));
     this.yCrosshair.setValue(xyDataSet.getYValue(xyItemEntity.getSeriesIndex(), 
     xyItemEntity.getItem()));

  }

When I put my mouse to values of temperature I can get these values but when I put my values of power, I can't get the values. Here is the example of temperature values :enter image description here As you can see I got temperature value 19.215 and here is the example of power :enter image description here I can't get the value. How can I get rid of this problem and how can I get all values of two axis?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source