title: How to display values in JavaFX Pie Chart?
body: <p>I am displaying pie chart representing under and over performing students for each module of a degree. The code that I have displays this:
  <a href="https://i.stack.imgur.com/ODRtO.png" rel="nofollow noreferrer">output</a></p>
  
  <p>However I would like the values for each slice to appear within it, I don't want any fancy mouselistener thing just to show the numbers in the slices.</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>public class PieChartSample extends Application { //TODO make constructor that takes hashmaps as arguments
  static Map&lt;String, Integer&gt; studsabove = new HashMap&lt;String, Integer&gt;();
  static Map&lt;String, Integer&gt; studsbelow = new HashMap&lt;String, Integer&gt;();
  
  @Override
  public void start(Stage primaryStage) throws Exception {
      primaryStage.setTitle("My First JavaFX App");
  
      ArrayList&lt;PieChart&gt; pielist = new ArrayList&lt;PieChart&gt;();
      for(Entry&lt;String, Integer&gt; mod: studsabove.entrySet()){
          for(Entry&lt;String, Integer&gt; mod2: studsbelow.entrySet()){
              PieChart pieChart = new PieChart();
              PieChart.Data above = new PieChart.Data(mod.getKey(), mod.getValue());
              PieChart.Data below = new PieChart.Data(mod2.getKey(), mod2.getValue());
  
              pieChart.getData().add(above);
              pieChart.getData().add(below);
  
              pielist.add(pieChart);
          }
      }
  
      VBox vbox = new VBox();
      for (PieChart pie: pielist){
          pie.setLabelLineLength(10); //FIXME
          pie.setLegendSide(Side.LEFT);
          vbox.getChildren().add(pie);
      }
      Scene scene = new Scene(vbox, 400, 200); //TODO: Make pie charts appear horizontally rather than vertically
  
      primaryStage.setScene(scene);
      primaryStage.setHeight(900);
      primaryStage.setWidth(400);
  
      primaryStage.show();
  }
  
  
  public static void main(String[] args) { //TODO: need to figure out how to display the values in the slices of the pie charts
  
      PieChartSample.studsabove.put("CE201", 23);
      PieChartSample.studsbelow.put("CE201", 67);
  
      PieChartSample.studsabove.put("CE222", 20);
      PieChartSample.studsbelow.put("CE222", 80);
  
  
      PieChartSample.studsabove.put("CE233", 6);
      PieChartSample.studsbelow.put("CE233", 94);
  
      PieChartSample.studsabove.put("CE244", 56);
      PieChartSample.studsbelow.put("CE244", 44);
      Application.launch(args);
  }
  </code></pre>
  
  <p>}</p>