Java Code Examples for javafx.scene.chart.XYChart#Data
The following examples show how to use
javafx.scene.chart.XYChart#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: AdvAreaAudioChartSample.java From marathonv5 with Apache License 2.0 | 6 votes |
protected AreaChart<Number,Number> createChart() { final NumberAxis xAxis = new NumberAxis(0,128,8); final NumberAxis yAxis = new NumberAxis(0,50,10); final AreaChart<Number,Number> ac = new AreaChart<Number,Number>(xAxis,yAxis); // setup chart ac.setId("audioAreaDemo"); ac.setLegendVisible(false); ac.setTitle("Live Audio Spectrum Data"); ac.setAnimated(false); xAxis.setLabel("Frequency Bands"); yAxis.setLabel("Magnitudes"); yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis,null,"dB")); // add starting data XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>(); series.setName("Audio Spectrum"); //noinspection unchecked series1Data = new XYChart.Data[(int)xAxis.getUpperBound()]; for (int i=0; i<series1Data.length; i++) { series1Data[i] = new XYChart.Data<Number,Number>(i,50); series.getData().add(series1Data[i]); } ac.getData().add(series); return ac; }
Example 2
Source File: AdvCandleStickChartSample.java From marathonv5 with Apache License 2.0 | 6 votes |
@Override protected void seriesRemoved(Series<Number, Number> series) { // remove all candle nodes for (XYChart.Data<Number, Number> d : series.getData()) { final Node candle = d.getNode(); if (shouldAnimate()) { // fade out old candle FadeTransition ft = new FadeTransition(Duration.millis(500), candle); ft.setToValue(0); ft.setOnFinished(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { getPlotChildren().remove(candle); } }); ft.play(); } else { getPlotChildren().remove(candle); } } }
Example 3
Source File: SinChartComponent.java From spring-labs with Apache License 2.0 | 6 votes |
public SinChartComponent() { NumberAxis xAxis = new NumberAxis(); xAxis.setLabel("x"); NumberAxis yAxis = new NumberAxis(); yAxis.setLabel("y"); XYChart.Series<Number, Number> series = new XYChart.Series<>(); series.setName("Sine"); ObservableList<XYChart.Data<Number, Number>> data = series.getData(); for (double x = -Math.PI; x < Math.PI; x += 0.5) { data.add(new XYChart.Data<Number, Number>(x, 10 * Math.sin(x))); } LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis); lineChart.setTitle("Sine function"); lineChart.getData().add(series); getChildren().add(lineChart); }
Example 4
Source File: AdvAreaAudioChartSample.java From marathonv5 with Apache License 2.0 | 6 votes |
protected AreaChart<Number,Number> createChart() { final NumberAxis xAxis = new NumberAxis(0,128,8); final NumberAxis yAxis = new NumberAxis(0,50,10); final AreaChart<Number,Number> ac = new AreaChart<Number,Number>(xAxis,yAxis); // setup chart ac.setId("audioAreaDemo"); ac.setLegendVisible(false); ac.setTitle("Live Audio Spectrum Data"); ac.setAnimated(false); xAxis.setLabel("Frequency Bands"); yAxis.setLabel("Magnitudes"); yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis,null,"dB")); // add starting data XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>(); series.setName("Audio Spectrum"); //noinspection unchecked series1Data = new XYChart.Data[(int)xAxis.getUpperBound()]; for (int i=0; i<series1Data.length; i++) { series1Data[i] = new XYChart.Data<Number,Number>(i,50); series.getData().add(series1Data[i]); } ac.getData().add(series); return ac; }
Example 5
Source File: EpidemicReportsChartController.java From MyBox with Apache License 2.0 | 5 votes |
protected void drawValueBarsHorizontal(List<EpidemicReport> timeReports) { if (valuesNames.size() != 1 || timeReports == null || timeReports.isEmpty()) { return; } String valueName = orderNames.get(0); LabeledHorizontalBarChart barChart = addHorizontalBarChart(); Map<String, String> palette = new HashMap(); for (int i = timeReports.size() - 1; i >= 0; i--) { EpidemicReport report = timeReports.get(i); String location = report.getLocationFullName(); String label = (multipleDatasets ? report.getDataSet() + " - " : "") + location; palette.put(label, settingsController.locationColors.get(location)); Number value = report.value(valueName); if (value == null) { continue; } double coordinateValue = FxmlControl.coordinateValue(chartCoordinate, value.doubleValue()); XYChart.Series series = new XYChart.Series(); series.setName(label); XYChart.Data item = new XYChart.Data(coordinateValue, label); series.getData().add(item); barChart.getData().add(series); if (labelType == LabelType.Pop) { FxmlControl.setTooltip(item.getNode(), label + " " + value); } } FxmlControl.setBarChartColors(barChart, palette, legendSide != null); }
Example 6
Source File: SupplyView.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private void updateBSQBurntDailyMA(List<XYChart.Data<Number, Number>> updatedBurntBsq) { seriesBSQBurntDailyMA.getData().clear(); Comparator<Number> compareXChronology = Comparator.comparingInt(Number::intValue); Comparator<XYChart.Data<Number, Number>> compareXyDataChronology = (xyData1, xyData2) -> compareXChronology.compare( xyData1.getXValue(), xyData2.getXValue()); var sortedUpdatedBurntBsq = updatedBurntBsq .stream() .sorted(compareXyDataChronology) .collect(Collectors.toList()); var burntBsqXValues = sortedUpdatedBurntBsq.stream().map(XYChart.Data::getXValue); var burntBsqYValues = sortedUpdatedBurntBsq.stream().map(XYChart.Data::getYValue); var maPeriod = 15; var burntBsqMAYValues = MovingAverageUtils.simpleMovingAverage( burntBsqYValues, maPeriod); BiFunction<Number, Double, XYChart.Data<Number, Number>> xyToXyData = XYChart.Data<Number, Number>::new; List<XYChart.Data<Number, Number>> burntBsqMA = zip(burntBsqXValues, burntBsqMAYValues, xyToXyData) .filter(xyData -> Double.isFinite(xyData.getYValue().doubleValue())) .collect(Collectors.toList()); seriesBSQBurntDailyMA.getData().setAll(burntBsqMA); }
Example 7
Source File: VolumeChart.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void dataItemAdded(XYChart.Series<Number, Number> series, int itemIndex, XYChart.Data<Number, Number> item) { Node volumeBar = createCandle(getData().indexOf(series), item, itemIndex); getPlotChildren().remove(volumeBar); if (shouldAnimate()) { volumeBar.setOpacity(0); getPlotChildren().add(volumeBar); FadeTransition ft = new FadeTransition(Duration.millis(500), volumeBar); ft.setToValue(1); ft.play(); } else { getPlotChildren().add(volumeBar); } }
Example 8
Source File: ChartUtil.java From DevToolBox with GNU Lesser General Public License v2.1 | 5 votes |
public static void changeChart(LineChart chart, Date now, Double dt, String name) { ObservableList<XYChart.Series> data = chart.getData(); XYChart.Series xys = null; if (data.isEmpty()) { xys = getSeries(chart, dt, name); data.add(xys); addClickListener(chart); } else { boolean exits = false; for (XYChart.Series series : data) { if (name.equals(series.getName())) { exits = true; xys = series; break; } } if (!exits) { xys = getSeries(chart, dt, name); data.add(xys); addClickListener(chart); } NumberAxis na = (NumberAxis) chart.getYAxis(); na.setUpperBound(Math.max(na.getUpperBound(), dt)); } XYChart.Data xdata = new XYChart.Data<>(DATE_FORMAT.format(now), dt); xdata.setNode(new HoveredThresholdNode(dt, dt)); xdata.getNode().setVisible(CACHE.get(name) == null ? true : CACHE.get(name)); xys.getData().add(xdata); if (xys.getData().size() > 9) { xys.getData().remove(0); } }
Example 9
Source File: SampleChartController.java From OEE-Designer with MIT License | 5 votes |
public void plotValue(Number value) { if (numberSamplesToDisplay < 1) { return; } sampleNumber++; XYChart.Data<Integer, Number> nextPoint = new XYChart.Data<>(sampleNumber, value); if (interpolationType.equals(InterpolationType.STAIR_STEP) && sampleNumber > 0) { Number nextY = nextPoint.getYValue(); XYChart.Data<Integer, Number> stepPoint = new XYChart.Data<>(sampleNumber - 1, nextY); dataSeries.getData().add(stepPoint); } dataSeries.getData().add(nextPoint); // after N count, delete old sample(s) if (sampleNumber.intValue() > numberSamplesToDisplay) { int delta = 0; // drop oldest samples if (interpolationType.equals(InterpolationType.LINEAR)) { delta = dataSeries.getData().size() - numberSamplesToDisplay; } else { // stair step delta = dataSeries.getData().size() - 2 * numberSamplesToDisplay; } if (delta > 0) { dataSeries.getData().remove(0, delta); } } if (sampleNumber.intValue() > (numberSamplesToDisplay - 1)) { // move range xAxis.setLowerBound(xAxis.getLowerBound() + 1); xAxis.setUpperBound(xAxis.getUpperBound() + 1); } }
Example 10
Source File: OfferBookChartViewModel.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private void buildChartAndTableEntries(List<Offer> sortedList, OfferPayload.Direction direction, List<XYChart.Data<Number, Number>> data, ObservableList<OfferListItem> offerTableList) { data.clear(); double accumulatedAmount = 0; List<OfferListItem> offerTableListTemp = new ArrayList<>(); for (Offer offer : sortedList) { Price price = offer.getPrice(); if (price != null) { double amount = (double) offer.getAmount().value / LongMath.pow(10, offer.getAmount().smallestUnitExponent()); accumulatedAmount += amount; offerTableListTemp.add(new OfferListItem(offer, accumulatedAmount)); double priceAsDouble = (double) price.getValue() / LongMath.pow(10, price.smallestUnitExponent()); if (CurrencyUtil.isCryptoCurrency(getCurrencyCode())) { if (direction.equals(OfferPayload.Direction.SELL)) data.add(0, new XYChart.Data<>(priceAsDouble, accumulatedAmount)); else data.add(new XYChart.Data<>(priceAsDouble, accumulatedAmount)); } else { if (direction.equals(OfferPayload.Direction.BUY)) data.add(0, new XYChart.Data<>(priceAsDouble, accumulatedAmount)); else data.add(new XYChart.Data<>(priceAsDouble, accumulatedAmount)); } } } offerTableList.setAll(offerTableListTemp); }
Example 11
Source File: ChartAudioBar.java From netbeans with Apache License 2.0 | 5 votes |
protected BarChart<String, Number> createChart() { final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(0,50,10); final BarChart<String,Number> bc = new BarChart<String,Number>(xAxis,yAxis); bc.setId("barAudioDemo"); bc.setLegendVisible(false); bc.setAnimated(false); bc.setBarGap(0); bc.setCategoryGap(1); bc.setVerticalGridLinesVisible(false); // setup chart bc.setTitle("Live Audio Spectrum Data"); xAxis.setLabel("Frequency Bands"); yAxis.setLabel("Magnitudes"); yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis,null,"dB")); // add starting data XYChart.Series<String,Number> series1 = new XYChart.Series<String,Number>(); series1.setName("Data Series 1"); //noinspection unchecked series1Data = new XYChart.Data[128]; String[] categories = new String[128]; for (int i=0; i<series1Data.length; i++) { categories[i] = Integer.toString(i+1); series1Data[i] = new XYChart.Data<String,Number>(categories[i],50); series1.getData().add(series1Data[i]); } bc.getData().add(series1); return bc; }
Example 12
Source File: VolumeChart.java From bisq with GNU Affero General Public License v3.0 | 4 votes |
@Override protected void dataItemChanged(XYChart.Data<Number, Number> item) { }
Example 13
Source File: ParetoChartController.java From OEE-Designer with MIT License | 4 votes |
private void onBarChartNodeSelected(XYChart.Data<String, Number> item) { if (clickListener != null) { clickListener.onClickCategory(item); } }
Example 14
Source File: ParetoChartController.java From OEE-Designer with MIT License | 4 votes |
private BarChart<String, Number> createBarChart(String categoryLabel) { // X-Axis category CategoryAxis xAxis = new CategoryAxis(); xAxis.setLabel(categoryLabel); // Y-Axis (%) NumberAxis yAxis = new NumberAxis(0, 100, 10); yAxis.setLabel(DesignerLocalizer.instance().getLangString("percent")); yAxis.setAutoRanging(false); yAxis.setUpperBound(100.0d); yAxis.setLowerBound(0.0d); // create bar chart BarChart<String, Number> chBarChart = new BarChart<>(xAxis, yAxis); chBarChart.setTitle(chartTitle); chBarChart.setLegendVisible(false); chBarChart.setAnimated(false); chBarChart.getData().add(barChartSeries); // add the points double total = totalCount.doubleValue(); if (total > 0.0d) { int count = 0; for (ParetoItem paretoItem : paretoItems) { if (count > TOP_N) { break; } count++; Float percentage = new Float(paretoItem.getValue().floatValue() / total * 100.0f); XYChart.Data<String, Number> point = new XYChart.Data<>(paretoItem.getCategory(), percentage); barChartSeries.getData().add(point); } } // add listener for mouse click on bar for (Series<String, Number> series : chBarChart.getData()) { for (XYChart.Data<String, Number> item : series.getData()) { item.getNode().setOnMouseClicked((MouseEvent event) -> { onBarChartNodeSelected(item); }); } } return chBarChart; }
Example 15
Source File: SwapItem.java From JavaFX-Tutorial-Codes with Apache License 2.0 | 4 votes |
public XYChart.Data<String, Integer> getItemToSwap() { return itemToSwap; }
Example 16
Source File: CandleStickChart.java From bisq with GNU Affero General Public License v3.0 | 4 votes |
@Override protected void dataItemChanged(XYChart.Data<Number, Number> item) { }
Example 17
Source File: ChartBuilder.java From constellation with Apache License 2.0 | 4 votes |
public ScatterChart<X, Y> build(GraphReadMethods graph, ScatterPlotState state, Set<ScatterData> currentData, Set<ScatterData> currentSelectedData) { currentData.clear(); currentSelectedData.clear(); XYChart.Series<X, Y> series = new XYChart.Series<>(); series.setName(state.getXAttribute() + " vs. " + state.getYAttribute()); final int selectedAttribute = graph.getAttribute(state.getElementType(), VisualConcept.VertexAttribute.SELECTED.getName()); final int labelAttribute = graph.getAttribute(state.getElementType(), VisualConcept.VertexAttribute.LABEL.getName()); final int elementCount = state.getElementType().getElementCount(graph); for (int elementPosition = 0; elementPosition < elementCount; elementPosition++) { final int elementId = state.getElementType().getElement(graph, elementPosition); if (!state.isSelectedOnly() || graph.getBooleanValue(selectedAttribute, elementId)) { final String elementLabel = graph.getStringValue(labelAttribute, elementId); final X vertexXValue = xAxisBuilder.getValue(graph, state.getElementType(), state.getXAttribute().getId(), elementId); final Y vertexYValue = yAxisBuilder.getValue(graph, state.getElementType(), state.getYAttribute().getId(), elementId); final XYChart.Data<X, Y> data = new XYChart.Data<>(vertexXValue, vertexYValue); final ScatterData scatterData = new ScatterData(elementId, elementLabel, data); currentData.add(scatterData); if (graph.getBooleanValue(selectedAttribute, elementId)) { currentSelectedData.add(scatterData); } series.getData().add(data); } } final Axis<X> xAxis = xAxisBuilder.build(); xAxis.setLabel(state.getXAttribute().getName()); final Axis<Y> yAxis = yAxisBuilder.build(); yAxis.setLabel(state.getYAttribute().getName()); final ScatterChart<X, Y> scatterChart = new ScatterChart<>(xAxis, yAxis); scatterChart.setLegendVisible(false); scatterChart.setHorizontalGridLinesVisible(false); scatterChart.setVerticalGridLinesVisible(false); scatterChart.getData().clear(); scatterChart.getData().add(series); return scatterChart; }
Example 18
Source File: ResourceChartController.java From logbook-kai with MIT License | 2 votes |
/** * ボーキを設定します。 * @param bauxite ボーキ */ public void setBauxite(Collection<XYChart.Data<Number, Number>> bauxite) { this.bauxite.getData().addAll(bauxite); }
Example 19
Source File: ResourceChartController.java From logbook-kai with MIT License | 2 votes |
/** * 弾薬を取得します。 * @param from 開始日時 * @return 弾薬 */ public XYChart.Data<Number, Number> getAmmoSeries(ZonedDateTime from) { return new XYChart.Data<>(this.date.toEpochSecond() - from.toEpochSecond(), this.ammo); }
Example 20
Source File: ResourceChartController.java From logbook-kai with MIT License | 2 votes |
/** * 高速修復材を取得します。 * @param from 開始日時 * @return 高速修復材 */ public XYChart.Data<Number, Number> getBucketSeries(ZonedDateTime from) { return new XYChart.Data<>(this.date.toEpochSecond() - from.toEpochSecond(), this.bucket); }