Let' see in JavaFx the PieChart diagram:
public class JavaFXApplication1 extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Chart example");
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(
new PieChart.Data("Grapefruit", 13),
new PieChart.Data("Oranges", 25),
new PieChart.Data("Plums", 10),
new PieChart.Data("Pears", 22),
new PieChart.Data("Apples", 30));
PieChart chart = new PieChart(pieChartData);
chart.setTitle("Imported Fruits");
StackPane root = new StackPane();
root.getChildren().add(chart);
primaryStage.setScene(new Scene(root, 300, 250));
primaryStage.show();
}
}
No comments:
Post a Comment