JavaFx_PieChart1
 
Code Snippet:

 
Complete Code :

package javafxtemplate1;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Side;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.chart.PieChart;
import javafx.scene.chart.PieChart.Data;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;


/**
*
* @author Manas9
*/
public class JavaFXTemplate1 extends Application {
@Override
public void start(Stage primaryStage) {
//Scene scene = new Scene(new Group());
PieChart fxpieChart = new PieChart();
fxpieChart.setData(demoGraphicData());
System.out.println(fxpieChart.dataProperty());
//
fxpieChart.setTitle("2010 Demographic Chart");
fxpieChart.setLegendSide(Side.TOP);
// fxpieChart.setLegendSide(Side.valueOf(STYLESHEET_MODENA));
fxpieChart.setClockwise(false);
fxpieChart.setLabelsVisible(true);
//
StackPane root = new StackPane();
root.getChildren().add(fxpieChart);
//((Group) scene.getRoot()).getChildren().add(fxpieChart);
primaryStage.setScene(new Scene(root, 500, 400));
primaryStage.show();
}

private ObservableList<Data> demoGraphicData() {
ObservableList<Data> races = FXCollections.observableArrayList();
races.addAll(
new PieChart.Data("African-American", 32.9),
new PieChart.Data("Hispanic", 28.9),
new PieChart.Data("White",31.37 ),
new PieChart.Data("Asian",5.5 )
);
return races;
}
public static void main(String[] args) {
launch(args);
}
}