Created
November 29, 2016 01:24
-
-
Save alvareztech/e2e1d539df11fcbbcbdcf79cbfc9ee42 to your computer and use it in GitHub Desktop.
Ejemplo PieChart JavaFX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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