title: JavaFX LineChart Hover Values
body: <p>I am in the process of creating a line chart in JavaFX. All is good currently and it successfully creates the chart with the data I need from a database stored procedure. Anyway what I require if possible is for every data point on the LineChart to have a mouse hover event on it which states the value behind the specific point, for example £150,000. I have seen examples of this been done on PieCharts where it shows the % value on hover but I cannot find examples anywhere for LineCharts, can this even be done?</p>
  
  <p>Can anyone point me in the right direction if possible? </p>
  
  <p>Code so far:</p>
  
  <pre><code>private static final String MINIMIZED = "MINIMIZED";
  private static final String MAXIMIZED = "MAXIMIZED";
  private static String chartState = MINIMIZED;
  // 12 Month Sales Chart
  XYChart.Series&lt;String, Number&gt; series = new XYChart.Series&lt;&gt;();
  XYChart.Series&lt;String, Number&gt; series2 = new XYChart.Series&lt;&gt;();
  
  public void getDeltaData() {
  
      try {
          Connection con = DriverManager.getConnection(connectionUrl);
          //Get all records from table
          String SQL = "";
          Statement stmt = con.createStatement();
  
          //Create the result set from query execution.
          ResultSet rs = stmt.executeQuery(SQL);
  
          while (rs.next()) {
  
              series.getData().add(new XYChart.Data&lt;String, Number&gt;(rs.getString(1),
                      Double.parseDouble(rs.getString(7))));
              series2.getData().add(new XYChart.Data&lt;String, Number&gt;(rs.getString(1),
                      Double.parseDouble(rs.getString(8))));
  
          }
          rs.close();
          stmt.close();
  
      } catch (Exception e) {
      }
      yearChart = createChart();
  }
  
      protected LineChart&lt;String, Number&gt; createChart() {
      final CategoryAxis xAxis = new CategoryAxis();
      final NumberAxis yAxis = new NumberAxis();
  
      // setup chart
      series.setName("Target");
      series2.setName("Actual");
      xAxis.setLabel("Period");
      yAxis.setLabel("£");
  
      yearChart.getData().add(series);
      yearChart.getData().add(series2);
  
      yearChart.setCreateSymbols(false);
  
      return yearChart;
  }
  </code></pre>
  
  <p><strong>Answer provided by jewelsea is a perfect solution to this problem.</strong></p>
  
  <p>Thank you, jewelsea.</p>