Java Code Examples for javafx.scene.chart.PieChart#Data
The following examples show how to use
javafx.scene.chart.PieChart#Data .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DetailPCController.java From FlyingAgent with Apache License 2.0 | 7 votes |
private void addDiskBox(Disk disk) { try { Parent parentDisk = FXMLLoader.load(getClass().getResource("/resources/views/models/DiskInfo.fxml")); //Label lblName = (Label) parentDisk.lookup("#lblName"); Label lblTotalSpace = (Label) parentDisk.lookup("#lblTotalSpace"); PieChart pieData = (PieChart) parentDisk.lookup("#pieData"); pieData.setTitle(disk.getName()); lblTotalSpace.setText(Utils.humanReadableByteCount(disk.getTotalSpace())); // Data of pie chart ObservableList<PieChart.Data> data = FXCollections.observableArrayList(); data.add(new PieChart.Data("Usable", Utils.humanReadableByteCountNumber(disk.getUsableSpace()))); data.add(new PieChart.Data("Free", Utils.humanReadableByteCountNumber(disk.getFreeSpace()))); pieData.setData(data); pieData.getData().forEach(d -> d.nameProperty().bind(Bindings.concat(d.getName(), " ", d.pieValueProperty(), " GB")) ); boxContainerDisks.getChildren().add(parentDisk); } catch (IOException ioe) { ioe.printStackTrace(); } }
Example 2
Source File: DoughnutChart.java From mars-sim with GNU General Public License v3.0 | 6 votes |
private void updateInnerCircleLayout() { double minX = Double.MAX_VALUE, minY = Double.MAX_VALUE; double maxX = Double.MIN_VALUE, maxY = Double.MIN_VALUE; for (PieChart.Data data: getData()) { Node node = data.getNode(); Bounds bounds = node.getBoundsInParent(); if (bounds.getMinX() < minX) { minX = bounds.getMinX(); } if (bounds.getMinY() < minY) { minY = bounds.getMinY(); } if (bounds.getMaxX() > maxX) { maxX = bounds.getMaxX(); } if (bounds.getMaxY() > maxY) { maxY = bounds.getMaxY(); } } innerCircle.setCenterX(minX + (maxX - minX) / 2); innerCircle.setCenterY(minY + (maxY - minY) / 2); innerCircle.setRadius((maxX - minX) / 4); }
Example 3
Source File: FxmlControl.java From MyBox with Apache License 2.0 | 6 votes |
public static void setPieColors(PieChart pie, List<String> palette, boolean showLegend) { if (pie == null || palette == null || pie.getData() == null || pie.getData().size() > palette.size()) { return; } for (int i = 0; i < pie.getData().size(); i++) { PieChart.Data data = pie.getData().get(i); data.getNode().setStyle("-fx-pie-color: " + palette.get(i) + ";"); } pie.setLegendVisible(showLegend); if (showLegend) { Set<Node> legendItems = pie.lookupAll("Label.chart-legend-item"); if (legendItems.isEmpty()) { return; } for (Node legendItem : legendItems) { Label legendLabel = (Label) legendItem; Node legend = legendLabel.getGraphic(); if (legend != null) { for (int i = 0; i < pie.getData().size(); i++) { String name = pie.getData().get(i).getName(); if (name.equals(legendLabel.getText())) { legend.setStyle("-fx-background-color: " + palette.get(i)); break; } } } } } }
Example 4
Source File: ChartGenerator.java From testgrid with Apache License 2.0 | 6 votes |
/** * Generates a pie chart with the summary test results of the current build. * * @param passedCount passed test count * @param failedCount failed test count * @param skippedCount skipped test count * @param summaryChartFileName file name of the summary chart */ public void generateSummaryChart(int passedCount, int failedCount, int skippedCount, String summaryChartFileName) { List<PieChart.Data> data = new ArrayList<>(); data.add(new PieChart.Data(StringUtil.concatStrings("Test Failures (", Integer.toString(failedCount), ")"), failedCount)); data.add(new PieChart.Data(StringUtil.concatStrings("Deployment Errors (", Integer.toString (skippedCount), ")"), skippedCount)); data.add(new PieChart.Data(StringUtil.concatStrings("Passed (", Integer.toString(passedCount), ")"), passedCount)); ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(data); final PieChart chart = new PieChart(pieChartData); chart.setAnimated(false); chart.setLabelsVisible(true); chart.setTitle("Build Summary of Infrastructure Combinations (" + (failedCount + skippedCount + passedCount) + ")"); genChart(chart, 600, 600, summaryChartFileName, "styles/summary.css"); }
Example 5
Source File: TopBarView.java From erlyberly with GNU General Public License v3.0 | 5 votes |
private void showErlangMemory() { ObservableList<PieChart.Data> data = FXCollections.observableArrayList(); showPieChart(data); ErlangMemoryThread emThread; emThread = new ErlangMemoryThread(data); emThread.start(); }
Example 6
Source File: TooltipUtils.java From jstackfx with Apache License 2.0 | 5 votes |
public static void addTooltipToData(final PieChart.Data data, final StringProperty label) { data.nodeProperty().addListener((value, oldNode, newNode) -> { if (newNode != null) { Tooltip.install(newNode, createNumberedTooltip(label, data.pieValueProperty())); } }); }
Example 7
Source File: DoughnutChartSample.java From mars-sim with GNU General Public License v3.0 | 5 votes |
@Override public void start(Stage stage) { stage.setTitle("Imported Fruits"); stage.setWidth(500); stage.setHeight(500); ObservableList<PieChart.Data> pieChartData = createData(); final DoughnutChart chart = new DoughnutChart(pieChartData); chart.setTitle("Imported Fruits"); Scene scene = new Scene(new StackPane(chart)); stage.setScene(scene); stage.show(); }
Example 8
Source File: PharmacistController.java From HealthPlus with Apache License 2.0 | 5 votes |
@FXML public void fillPieChart() { HashMap<String,String> supplierNames = pharmacist.getSupplierNames(); ArrayList<ArrayList<String>> suppliers = pharmacist.getSupplierSummary(); int noOfSuppliers = suppliers.get(0).size(); ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(); for (int i = 0; i < noOfSuppliers; i++) { String supplierID = suppliers.get(0).get(i); int stocks = Integer.parseInt(suppliers.get(1).get(i)); pieChartData.add(new PieChart.Data(supplierNames.get(supplierID), stocks)); } pieChartData.forEach(data1 -> data1.nameProperty().bind( Bindings.concat( data1.getName(), " (", data1.pieValueProperty().intValue(), ")" ) ) ); //piechart.setLabelLineLength(20); piechart.setLegendSide(Side.BOTTOM); piechart.setLabelsVisible(true); piechart.setData(pieChartData); }
Example 9
Source File: ReportsController.java From HealthPlus with Apache License 2.0 | 5 votes |
public void fillPieChart(int months) { ArrayList<ArrayList<String>> data = admin.lastMonthsReports(months); String[] test = { "Blood Grouping & Rh","Lipid Profile Test","LFT","RFT", "HIV","CPK","Pathalogy Test", "Complete Blood Count" }; ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(); pieChartData.clear(); int tmpSize = test.length; for(int i = 0; i < tmpSize; i++) { pieChartData.add(new PieChart.Data(test[i], Integer.parseInt(data.get(1).get(i)))); } pieChartData.forEach(data1 -> data1.nameProperty().bind( Bindings.concat( data1.getName(), " (", data1.pieValueProperty(), ")" ) ) ); labReportPieChart.setData(pieChartData); ArrayList<Integer> month = new ArrayList<Integer>(); for (int i = 1; i < 13; i++) { month.add(i); } //reportsCombo.getItems().clear(); //reportsCombo.getItems().addAll(month); //reportsCombo.setValue(12); }
Example 10
Source File: StatisticsPane.java From logbook-kai with MIT License | 5 votes |
/** * 経験値比率 * @param ships 対象艦 */ private void setRatio(List<Ship> ships) { Map<TypeGroup, Long> collect = ships.stream() .collect(Collectors.groupingBy(TypeGroup::toTypeGroup, TreeMap::new, Collectors.summingLong(this::getExp))); ObservableList<PieChart.Data> value = FXCollections.observableArrayList(); for (Entry<TypeGroup, Long> data : collect.entrySet()) { if (data.getKey() != null) value.add(new PieChart.Data(data.getKey().name(), data.getValue())); } this.ratio.setData(value); }
Example 11
Source File: PieChartSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public PieChartSample() { ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( new PieChart.Data("Sun", 20), new PieChart.Data("IBM", 12), new PieChart.Data("HP", 25), new PieChart.Data("Dell", 22), new PieChart.Data("Apple", 30) ); PieChart chart = new PieChart(pieChartData); chart.setClockwise(false); getChildren().add(chart); }
Example 12
Source File: DrilldownPieChartSample.java From marathonv5 with Apache License 2.0 | 5 votes |
private void setDrilldownData(final PieChart pie, PieChart.Data data, final String labelPrefix) { data.getNode().setOnMouseClicked(new EventHandler<MouseEvent>() { public void handle(MouseEvent t) { pie.setData(FXCollections.observableArrayList( new PieChart.Data(labelPrefix + "-1", 7), new PieChart.Data(labelPrefix + "-2", 2), new PieChart.Data(labelPrefix + "-3", 5), new PieChart.Data(labelPrefix + "-4", 3), new PieChart.Data(labelPrefix + "-5", 2))); } }); }
Example 13
Source File: DoughnutChartSample.java From mars-sim with GNU General Public License v3.0 | 5 votes |
private ObservableList<PieChart.Data> createData() { return 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)); }
Example 14
Source File: TopVehiclesUIController.java From RentLio with Apache License 2.0 | 5 votes |
@FXML private void setPieChartGraph(){ Integer chartType = chbxTest.getValue(); //switch by vehicle type switch (chartType){ case 1 : ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( new PieChart.Data("Prius", 13), new PieChart.Data("Audi A7", 25), new PieChart.Data("Audi R8", 10), new PieChart.Data("BMW i8", 22), new PieChart.Data("Premio", 30)); topVehiclesChart.setData(pieChartData); topVehiclesChart.setTitle("Top Vehicles"); break; case 2 : pieChartData = FXCollections.observableArrayList( new PieChart.Data("Prius", 73), new PieChart.Data("Audi A7", 25), new PieChart.Data("Audi R8", 17), new PieChart.Data("BMW i8", 45), new PieChart.Data("Premio", 90)); topVehiclesChart.setData(pieChartData); break; case 3 : break; default : new AlertBuilder("warn","Top Vehicles","Top Vehicle Graph", "Invalid type of graph !!"); } }
Example 15
Source File: Dashboard.java From DashboardFx with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void initialize(URL location, ResourceBundle resources) { ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( new PieChart.Data("Sun", 20), new PieChart.Data("IBM", 12), new PieChart.Data("HP", 25), new PieChart.Data("Dell", 22), new PieChart.Data("Apple", 30) ); pieChart.setData(pieChartData); pieChart.setClockwise(false); XYChart.Series<String, Number> series = new XYChart.Series<>(); series.setName("Legend 1"); series.getData().add(new XYChart.Data<>("0", 2D)); series.getData().add(new XYChart.Data<>("1", 8D)); series.getData().add(new XYChart.Data<>("2", 5D)); series.getData().add(new XYChart.Data<>("3", 3D)); series.getData().add(new XYChart.Data<>("4", 6D)); series.getData().add(new XYChart.Data<>("5", 8D)); series.getData().add(new XYChart.Data<>("6", 5D)); series.getData().add(new XYChart.Data<>("7", 6D)); series.getData().add(new XYChart.Data<>("8", 5D)); areaChart.getData().setAll(series); areaChart.setCreateSymbols(true); }
Example 16
Source File: ProcView.java From erlyberly with GNU General Public License v3.0 | 4 votes |
@FXML private void onTotalHeapPie() { ObservableList<PieChart.Data> data = buildData(chartableProcs(), (p) -> {return p.getTotalHeapSize(); }); showPieChart("Total Heap", data); }
Example 17
Source File: ProcView.java From erlyberly with GNU General Public License v3.0 | 4 votes |
@FXML private void onHeapPie() { ObservableList<PieChart.Data> data = buildData(chartableProcs(), (p) -> {return p.getHeapSize(); }); showPieChart("Process Heap", data); }
Example 18
Source File: TopBarView.java From erlyberly with GNU General Public License v3.0 | 4 votes |
public ErlangMemoryThread(ObservableList<PieChart.Data> thePieData) { pieData = thePieData; setName("Erlang Memory Thread"); setDaemon(true); }
Example 19
Source File: ScanAllController.java From FlyingAgent with Apache License 2.0 | 4 votes |
private void initMemoryChart(MemoryInformation memoryInfo) { pieMemory.setTitle("Total size: " + Utils.humanReadableByteCount(memoryInfo.getPhysicalMemorySize())); //pieMemory.setTitle("Total size: " + Utils.humanReadableByteCount(5500000012L) + "GB"); // Data of pie chart ObservableList<PieChart.Data> data = FXCollections.observableArrayList(); data.add(new PieChart.Data("In Use " + Utils.humanReadableByteCount(memoryInfo.getInUseMemorySize()), Utils.humanReadableByteCountNumber(memoryInfo.getInUseMemorySize()))); data.add(new PieChart.Data("Free " + Utils.humanReadableByteCount(memoryInfo.getFreePhysicalMemory()), Utils.humanReadableByteCountNumber(memoryInfo.getFreePhysicalMemory()))); //data.add(new PieChart.Data("In Use", Utils.humanReadableByteCount(3000000012L))); //data.add(new PieChart.Data("Free", Utils.humanReadableByteCount(2200000012L))); pieMemory.setData(data); pieMemory.getData().forEach(d -> { d.nameProperty().bind(Bindings.concat(d.getName())); } ); }
Example 20
Source File: ProcView.java From erlyberly with GNU General Public License v3.0 | 4 votes |
@FXML private void onStackPie() { ObservableList<PieChart.Data> data = buildData(chartableProcs(), (p) -> {return p.getStackSize(); }); showPieChart("Process Stack", data); }