Skip to content

Instantly share code, notes, and snippets.

@alvareztech
Created November 29, 2016 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvareztech/e2e1d539df11fcbbcbdcf79cbfc9ee42 to your computer and use it in GitHub Desktop.
Save alvareztech/e2e1d539df11fcbbcbdcf79cbfc9ee42 to your computer and use it in GitHub Desktop.
Ejemplo PieChart JavaFX
package tech.alvarez;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Side;
import javafx.scene.Scene;
import javafx.scene.chart.PieChart;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
ObservableList<PieChart.Data> datos = FXCollections.observableArrayList(
new PieChart.Data("Partido 1", 230),
new PieChart.Data("Partido 2", 70),
new PieChart.Data("Partido 3", 120)
);
PieChart grafico = new PieChart(datos);
grafico.setTitle("Elecciones nacionales");
grafico.setLegendSide(Side.LEFT);
Scene scene = new Scene(grafico, 400, 400);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment