0
私は、学位の各モジュールについて生徒のパフォーマンスを下回る、または上回っていることを表す円グラフを表示しています。私はディスプレイを持っているコードは、この:私はその中に表示される各スライスの値を希望しかし outputJavaFX Pie Chartに値を表示する方法は?
、私はスライス内の数値を表示するために、任意の空想のMouseListener事を望んでいません。次のように
私のコードは次のとおりです。
public class PieChartSample extends Application { //TODO make constructor that takes hashmaps as arguments
static Map<String, Integer> studsabove = new HashMap<String, Integer>();
static Map<String, Integer> studsbelow = new HashMap<String, Integer>();
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("My First JavaFX App");
ArrayList<PieChart> pielist = new ArrayList<PieChart>();
for(Entry<String, Integer> mod: studsabove.entrySet()){
for(Entry<String, Integer> 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);
}
}
これは、わずかに異なる。 http://stackoverflow.com/questions/35479375/display-additional-values-in-pie-chart – Sedrick