@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Europian Country Population"); stage.setWidth(500); stage.setHeight(500); ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( new PieChart.Data("Belgium", 3), new PieChart.Data("France", 26), new PieChart.Data("Germany", 35), new PieChart.Data("Netherlands", 7), new PieChart.Data("Sweden", 4), new PieChart.Data("United Kingdom", 25)); final PieChart pieChart = new PieChart(pieChartData); pieChart.setTitle("Country Population"); ((Group) scene.getRoot()).getChildren().add(pieChart); stage.setScene(scene); stage.show(); }
@Override public Node drawNode() { final PieChart chart = (PieChart)createObject(); Platform.runLater(new Runnable() { public void run() { int counter = 0; chart.setAnimated(true); for (Data item : data) { if (counter > chart.getData().size()) { chart.getData().add(item); } else { chart.getData().add(counter, item); } counter+= 2; } } }); return chart; }
public DrilldownPieChartSample() { String drilldownCss = DrilldownPieChartSample.class.getResource("DrilldownChart.css").toExternalForm(); PieChart pie = new PieChart( FXCollections.observableArrayList( A = new PieChart.Data("A", 20), B = new PieChart.Data("B", 30), C = new PieChart.Data("C", 10), D = new PieChart.Data("D", 40))); ((Parent) pie).getStylesheets().add(drilldownCss); setDrilldownData(pie, A, "a"); setDrilldownData(pie, B, "b"); setDrilldownData(pie, C, "c"); setDrilldownData(pie, D, "d"); getChildren().add(pie); }
@Override public void start(Stage stage) throws Exception { ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( new PieChart.Data("Education", 200), new PieChart.Data("Health", 130), new PieChart.Data("Defense", 200), new PieChart.Data("Agriculture", 200) ); PieChart budget = new PieChart(pieChartData); budget.setTitle("Economy Divison"); FlowPane root = new FlowPane(); root.getChildren().add(budget); Scene scene = new Scene(root,500,500); stage.setTitle("Pie Chart Demo"); stage.setScene(scene); stage.show(); }
private PieChart populationsScreen(Scene scene) { ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( new PieChart.Data("Alive", timeLine.getCurrentTimeInstant().getPopulation()), new PieChart.Data("Dead", fieldHeight * fieldWidth - timeLine.getCurrentTimeInstant().getPopulation())); final PieChart chart = new PieChart(pieChartData); final Timer timer = new java.util.Timer(); timer.schedule(new TimerTask() { public void run() { Platform.runLater(() -> { pieChartData.get(0).setPieValue(timeLine.getCurrentTimeInstant().getPopulation()); pieChartData.get(1).setPieValue(fieldHeight * fieldWidth - timeLine.getCurrentTimeInstant().getPopulation()); }); } }, 0, INTERVAL); return chart; }
private void drawChart(List<ClassHistogram.HistoDataEntry> entries){ long others = entries.stream() .skip(CHART_COLORS.length) .mapToLong(ClassHistogram.HistoDataEntry::getBytes) .sum(); histoPieChart.getData().clear(); ObservableList<PieChart.Data> chartData = histoPieChart.getData(); PieChart.Data data; for(int Cnt = 0; Cnt < CHART_COLORS.length; Cnt++){ data = new PieChart.Data(entries.get(Cnt).getName(), entries.get(Cnt).getBytes()); chartData.add(data); data.getNode().setStyle(String.format("-fx-pie-color: #%08x;", CHART_COLORS[Cnt].hashCode())); } data = new PieChart.Data("Others", others); chartData.add(data); data.getNode().setStyle("-fx-pie-color: gray;"); }
/** * Creates a pie chart * * @return {@link PieChart} */ private PieChart createPieChart() { PieChart chart = new PieChart(); chart.setMinHeight(chartHeight); chart.setTitle("Time needed in mode"); chart.setLegendVisible(false); chart.getStyleClass().add("statistic-chart"); chart.getStyleClass().add("statistic-chart-pie"); long[] durations = trackingSession.getDuration(); PieChart.Data redData = new PieChart.Data("RED", durations[0]/1000.0); PieChart.Data greenData = new PieChart.Data("GREEN", durations[1]/1000.0); PieChart.Data blueData = new PieChart.Data("BLUE", durations[2]/1000.0); if(durations[0] != 0) { chart.getData().addAll(redData, greenData, blueData); } return chart; }
@FXML public void initialize() { StringConverter<PieChart.Data> labelConverter = new StringConverter<PieChart.Data>() { @Override public String toString(Data d) { String formatedValue = String.format("%s\n%.2f %%", d.getName(), d.getPieValue()); return formatedValue; } @Override public Data fromString(String string) { return null; } }; picChart.setLabelConverter(labelConverter); picChart.setTooltipConverter(labelConverter); tbFileProperties.getItems().addAll(apply(this.file)); tbFileProperties.getSelectionModel().setCellSelectionEnabled(true); tbFileProperties.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); FxUtil.installClipboardKeyEvent(tbFileProperties); FxClipboardUtil.installCopyPasteHandler(tbFileProperties); }
public PieChart root_center(){ List<Event> startEvents= EventHandler.getPhaseStartEvents(); int test = 0; int code = 0; int ref = 0; for(Event e : startEvents){ switch(((PhaseStartEvent)e).getPhase()){ case 0: test = test+((PhaseStartEvent)e).getDuration();break; case 1: code = code+((PhaseStartEvent)e).getDuration();break; case 2: ref = ref+((PhaseStartEvent)e).getDuration();break; } } ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( new PieChart.Data("Test", test), new PieChart.Data("Code", code), new PieChart.Data("Refactor", ref)); PieChart chart = new PieChart(pieChartData); chart.setTitle("Time per phase:"); return chart; }
private void updateChart(CloudSettings set){ PieChart.Data availableData = new PieChart.Data("Available", set.getAvailableSpace()); PieChart.Data usingData = new PieChart.Data("Using", set.getUsingSpace()); PieChart.Data totalData = new PieChart.Data("Empty", set.getTotalSpace()-set.getCloudRaidSpace()); ObservableList<PieChart.Data> list = FXCollections.observableArrayList( availableData, usingData, totalData ); chart.setData(list); applyCustomColorSequence( list, "bisque", "red", "aqua" ); }
public HBox getAddItemHBox() { HBox hb = new HBox(); Label lb = new Label("Add item"); final TextField tf = TextFieldBuilder.create().prefWidth(50).id(ADD_ITEM_VALUE_TEXT_FIELD_ID).build(); Label namedLabel = new Label(" named "); final TextField name = TextFieldBuilder.create().prefWidth(50).id(ADD_ITEM_TEXT_FIELD_ID).build(); Label atLb = new Label("at pos"); final TextField tfPos = TextFieldBuilder.create().prefWidth(50).id(ADD_ITEM_POSITION_TEXT_FIELD_ID).build(); Button bt = ButtonBuilder.create().text("Add!").id(ADD_ITEM_BUTTON_ID).build(); bt.setOnAction(new EventHandler() { public void handle(Event t) { int index = Integer.parseInt(tfPos.getText()); Data newData = new Data("".equals(name.getText()) ? String.valueOf(index) : name.getText(), Double.parseDouble(tf.getText())); ((PieChart) testedPieChart).getData().add(index, newData); tb.addDoublePropertyLine(newData.pieValueProperty(), -10, 10000, 100, newData); } }); hb.getChildren().addAll(lb, tf, namedLabel, name, atLb, tfPos, bt); return hb; }
/** * Be careful, it returns the copy of the data array, and it is not * synchronized with he original data array. */ final public ObservableList<PieChart.Data> getData() { final ObservableList<PieChart.Data> data = FXCollections.observableArrayList(); new GetAction() { @Override public void run(Object... os) throws Exception { PieChart chart = (PieChart) piechart.getControl(); for (PieChart.Data dataItem : chart.getData()) { data.add(dataItem); } } }.dispatch(Root.ROOT.getEnvironment()); return data; }
@Test(timeout = 300000) public void startAnglePropertyTest() throws InterruptedException, Throwable { assertEquals(new PieChart().getStartAngle(), 0.0, 0.000001); List<Double> initialAngles = pieChartDescriptionProvider.getLinesAngles(); setPropertyBySlider(SettingType.SETTER, PieChartProperties.startAngle, 30.0); checkStartAngle(initialAngles, 30); setPropertyBySlider(SettingType.BIDIRECTIONAL, PieChartProperties.startAngle, 90.0); checkStartAngle(initialAngles, 90); setPropertyBySlider(SettingType.UNIDIRECTIONAL, PieChartProperties.startAngle, -60.0); checkStartAngle(initialAngles, -60); for (int i = -50; i < 300; i += 10) { setPropertyBySlider(SettingType.UNIDIRECTIONAL, PieChartProperties.startAngle, i); checkStartAngle(initialAngles, i); } }
@Test(timeout = 300000)//RT-27751 public void labelLineLengthTest() throws Throwable { assertEquals(new PieChart().getLabelLineLength(), 20, 0.0); checkLineLengths(20); setPropertyBySlider(SettingType.BIDIRECTIONAL, PieChartProperties.labelLineLength, 20); checkLineLengths(20); setPropertyBySlider(SettingType.SETTER, PieChartProperties.labelLineLength, 10); checkLineLengths(10); setPropertyBySlider(SettingType.UNIDIRECTIONAL, PieChartProperties.labelLineLength, 30); checkLineLengths(30); setPropertyBySlider(SettingType.UNIDIRECTIONAL, PieChartProperties.labelLineLength, -30); checkLineLengths(0); }
@Test(timeout = 300000) public void clockwisePropertyTest() throws Throwable { assertTrue(((PieChart) getNewChartInstance()).isClockwise()); List<Double> angles = pieChartDescriptionProvider.getLinesAngles(); setPropertyByToggleClick(SettingType.BIDIRECTIONAL, PieChartProperties.clockWise, false); checkTextFieldText(PieChartProperties.clockWise, "false"); checkClockWiseAffecting(angles, false); setPropertyByToggleClick(SettingType.SETTER, PieChartProperties.clockWise, true); checkTextFieldText(PieChartProperties.clockWise, "true"); checkClockWiseAffecting(angles, true); setPropertyByToggleClick(SettingType.UNIDIRECTIONAL, PieChartProperties.clockWise, false); checkTextFieldText(PieChartProperties.clockWise, "false"); checkClockWiseAffecting(angles, false); }
protected void checkLegendContentSizeCorrectness() { int itemsSize = new GetAction<Integer>() { @Override public void run(Object... os) throws Exception { final Chart chart = testedControl.getControl(); if (chart instanceof PieChart) { setResult(((PieChart) chart).getData().size()); } else { setResult(((XYChart) chart).getData().size()); } } }.dispatch(Root.ROOT.getEnvironment()); final List<Wrap<? extends Label>> legendLabels = chartDescriptionProvider.getLegendLabels(); Assert.assertEquals(legendLabels.size(), itemsSize); }
private GridPane getPieGrid() { GridPane pieGrid = null; try { pieGrid = FXMLLoader.load(QuestionView.class.getResource("/client/evaluationPieChartView.fxml")); } catch (IOException ex) { ex.printStackTrace(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("", ex); } } if (pieGrid == null) return null; this.pieChart = (PieChart) pieGrid.lookup("#pieChart"); ToggleGroup toggleGrp = new ToggleGroup(); this.rbtCount = (RadioButton) pieGrid.lookup("#rbtCount"); this.rbtCount.setToggleGroup(toggleGrp); this.rbtWeight = (RadioButton) pieGrid.lookup("#rbtWeight"); this.rbtWeight.setToggleGroup(toggleGrp); rbtCount.setSelected(true); return pieGrid; }
/** * Generate pipe chart */ private void initChart() { PieChart.Data available = new PieChart.Data("Available", 13); PieChart.Data used = new PieChart.Data("Used", 25); PieChart.Data empty = new PieChart.Data("Empty", 10); ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(available, used, empty); final PieChart chart = new PieChart(pieChartData); chart.setTitle(""); chart.setPrefSize(350, 350); chart.setLegendVisible(false); chart.setStyle("-fx-background-color: none"); pieChartPane.getChildren().add(chart); available.getNode().setStyle("-fx-background-color: #55c4fe"); used.getNode().setStyle("-fx-background-color: #008287"); empty.getNode().setStyle("-fx-background-color: #219297"); }
/** * This method is used to create a PieChart out of the information we got from * @see #leseZeiten(int) . * @return The created PieChart which contains the gathered information. */ private PieChart erstellePieChart() { ObservableList<PieChart.Data> daten = FXCollections.observableArrayList( new PieChart.Data("Red " + leseZeiten(1) + " Sekunden", leseZeiten(1)), new PieChart.Data("Green " + leseZeiten(2) + " Sekunden", leseZeiten(2)), new PieChart.Data("Refactor " + leseZeiten(3) + " Sekunden", leseZeiten(3))); PieChart pieChart = new PieChart(daten); pieChart.setTitle(gebeProzenteAus()); int i = 0; for (PieChart.Data data : daten) { if(i == 0) data.getNode().setStyle("-fx-pie-color: #FF0000;"); if(i == 1) data.getNode().setStyle("-fx-pie-color: #008000;"); if(i == 2) data.getNode().setStyle("-fx-pie-color: #000000;"); i++; } pieChart.setClockwise(false); pieChart.setStartAngle(180); return pieChart; }
private HBox getSystemPanel() { ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(); CONNECTIONS.forEach((string, clientObject) -> { if (clientObject.getSYSTEM_OS() != null) { if (operatingSystems.containsKey(clientObject.getSYSTEM_OS())) { operatingSystems.put(clientObject.getSYSTEM_OS(), operatingSystems.get(clientObject.getSYSTEM_OS()) + 1); } else { operatingSystems.put(clientObject.getSYSTEM_OS(), 1); } } }); operatingSystems.forEach((string, integer) -> { pieChartData.add(new PieChart.Data(string, CONNECTIONS.size() / integer)); }); final PieChart chart = new PieChart(pieChartData); chart.setLegendVisible(false); chart.setTitle("Operating Systems"); chart.setMaxSize(300, 300); return Styler.hContainer(Styler.vContainer(10, chart)); }
public String getChartInfos(PieChart chart,char Phase) { actualPhase = Phase; stopTime(Phase); elapsedTimed=System.currentTimeMillis()-(StartTime+trackerTime); RedTimeInPreCent = Math.round(((double) RedTime/elapsedTimed)*100); GreenTimeInPreCent = Math.round(((double) GreenTime/elapsedTimed)*100); RefactorTimeInPreCent = Math.round(((double) RefactorTime/elapsedTimed)*100); ExtraInfo=setExtraInfo(); ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList( new PieChart.Data("RED-Time", RedTimeInPreCent), new PieChart.Data("GREEN-Time", GreenTimeInPreCent), new PieChart.Data("REFACTOR-Time", RefactorTimeInPreCent)); chart.setData(pieChartData); chart.setTitle("Phase Duration"); return getTrackingStats(); }
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); }
@Override protected void addAdditionalStatistics(VBox statisticsView, WorklogStatistics statistics, List<TaskWithWorklogs> displayResult) { super.addAdditionalStatistics(statisticsView, statistics, displayResult); if (statistics.getEmployeeToProjectToWorktime().size() > 0) { PieChart pieChart = new PieChart(); pieChart.setLabelsVisible(false); pieChart.setTitle(FormattingUtil.getFormatted("view.statistics.byproject")); statisticsView.getChildren().add(pieChart); // since getDisplayData only returns own data // we can safely assume the employee map only contains // one username Map.Entry<String, Map<String, AtomicLong>> projectToWorktime = statistics.getEmployeeToProjectToWorktime().entrySet().iterator().next(); projectToWorktime.getValue().keySet().stream() .sorted(COLLATOR::compare) .forEach(project -> { AtomicLong timespentForThisProject = projectToWorktime.getValue().get(project); pieChart.getData().add(new PieChart.Data(project, timespentForThisProject.doubleValue())); }); } }
/** * Updates the given {@link PieChart} with new data. * * @param pPieChart the {@link PieChart} to update. */ private void updatePieChart(PieChart pPieChart) { pPieChart.setAnimated(chartAnimation); List<PieChart.Data> data = pPieChart.getData(); for (String yColumnName : yColumnNames) { try { dataBook.fetchAll(); for (int index = 0; index < dataBook.getRowCount(); index++) { IDataRow dataRow = dataBook.getDataRow(index); data.add(new PieChart.Data(dataRow.getValueAsString(xColumnName), ((BigDecimal) dataRow.getValue(yColumnName)).doubleValue())); } } catch (ModelException e) { e.printStackTrace(); } } }
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); }
public static void setupPieChartHovering(Chart chart) { if (chart instanceof PieChart) { new ChartHoverUtil<PieChart.Data>( data -> String.format("Value = %s", data.getPieValue()), PieChart.Data::getNode) .setupHovering(((PieChart)chart).getData()); } if (chart instanceof XYChart) { new ChartHoverUtil<XYChart.Series<String, Number>>( data -> String.format("Value = %s", data.getData().get(0).getYValue()), data -> data.getNode()) .setupHovering(((XYChart)chart).getData()); } }
private PieChart makeGenotypePie(final VariantContext ctx) { final Counter<GenotypeType> countTypes= new Counter<>(); if(ctx!=null) { for(final Genotype g:ctx.getGenotypes()) { // ignore genotype if not displayed final SampleDef sampleDef= this.name2sampledef.get(g.getSampleName()); if(sampleDef==null || !sampleDef.isDisplayed()) continue; countTypes.incr(g.getType()); } } final ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(); for(final GenotypeType t:GenotypeType.values()) { int c= (int)countTypes.count(t); if(c==0) continue; pieChartData.add(new PieChart.Data( t.name()+" = "+c, c)); } final PieChart chart = new PieChart(pieChartData); chart.setLegendVisible(false); return chart; }
/** * {@inheritDoc} */ @Override ObservableList<PieChart.Data> pieChartData() { ObservableList<PieChart.Data> data = FXCollections.observableArrayList(); List<Location> locations = locationMapper.readAll(); Integer timesWorkedAtLocation; for (Location location : locations) { timesWorkedAtLocation = getNumberOfLogEntriesContainingSpecifiedDatabaseItem(location.getLocationName()); data.add(new PieChart.Data(location.getLocationName(), timesWorkedAtLocation)); } return data; }
/** * {@inheritDoc} */ @Override ObservableList<PieChart.Data> pieChartData() { ObservableList<PieChart.Data> data = FXCollections.observableArrayList(); List<Company> companies = companyMapper.readAll(); Integer timesWorkedForCompany; for (Company company : companies) { timesWorkedForCompany = getNumberOfLogEntriesContainingSpecifiedDatabaseItem(company.getCompanyName()); data.add(new PieChart.Data(company.getCompanyName(), timesWorkedForCompany)); } return data; }
/** * {@inheritDoc} */ @Override ObservableList<PieChart.Data> pieChartData() { ObservableList<PieChart.Data> data = FXCollections.observableArrayList(); List<Supervisor> supervisors = supervisorMapper.readAll(); Integer timesWorkedUnderSupervisor; for (Supervisor supervisor : supervisors) { timesWorkedUnderSupervisor = getNumberOfLogEntriesContainingSpecifiedDatabaseItem(supervisor.getSupervisorDisplayName()); data.add(new PieChart.Data(supervisor.getSupervisorDisplayName(), timesWorkedUnderSupervisor)); } return data; }
protected PieChart createChart() { final PieChart pc = new PieChart(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) )); // setup chart pc.setId("BasicPie"); pc.setTitle("Pie Chart Example"); return pc; }
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))); } }); }
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); }