title: how to add 3 legend for a single series barchart?? JAVAFX
body: <p>Here is my code to generate 10 bars of different colors. I want to add legend respectively but it only shows yellow legend i can change its color but i want 3 legend. </p>
  
  <p>I think it shows only 1 color because there is only 1 series. Is it possible to add more than 1 legend for a single series?</p>
  
  <p>output:<img src="https://i.stack.imgur.com/fSNu7.png" alt="enter image description here"></p>
  
  <p>or if i can add this image as legend to the middle left of my chart</p>
  
  <p><img src="https://i.stack.imgur.com/cchch.png" alt="enter image description here"></p>
  
  <p>i need how to display image in bar chart or how to create 3 different labels for a single series bar chart</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.beans.value.*;
  import javafx.scene.*;
  import javafx.scene.chart.*;
  import javafx.stage.Stage;
  
  public class DynamicallyColoredBarChart extends Application {
  
      @Override
      public void start(Stage stage) {
          final CategoryAxis xAxis = new CategoryAxis();
          xAxis.setLabel("Bars");
          final NumberAxis yAxis = new NumberAxis();
          yAxis.setLabel("Value");
  
          final BarChart&lt;String, Number&gt; bc = new BarChart&lt;&gt;(xAxis, yAxis);
          bc.setLegendVisible(false);
  
          XYChart.Series series1 = new XYChart.Series();
  
          for (int i = 0; i &lt; 10; i++) {
              // change color of bar if value of i is &gt;5 than red if i&gt;8 than blue
              final XYChart.Data&lt;String, Number&gt; data = new XYChart.Data("Value " + i, i);
              data.nodeProperty().addListener(new ChangeListener&lt;Node&gt;() {
                  @Override
                  public void changed(ObservableValue&lt;? extends Node&gt; ov, Node oldNode, Node newNode) {
                      if (newNode != null) {
                          if (data.getYValue().intValue() &gt; 8) {
                              newNode.setStyle("-fx-bar-fill: navy;");
                          } else if (data.getYValue().intValue() &gt; 5) {
                              newNode.setStyle("-fx-bar-fill: red;");
                          }
                      }
                  }
              });
              series1.getData().add(data);
          }
          bc.getData().add(series1);
          stage.setScene(new Scene(bc));
          stage.show();
      }
  
      public static void main(String[] args) {
          launch(args);
      }
  }
  </code></pre>