/** * Create the charts. * * @param timeRange * the max time range * @return the {@link LineChart} */ public static LineChart<Number, Number> createDerivativeLineChart(final int timeRange) { final NumberAxis x2Axis = new NumberAxis("Space", -100, 100, 1); final NumberAxis x1Axis = new NumberAxis("Time", 0, timeRange, 1); final LineChart<Number, Number> lineChart = new LineChart<>(x1Axis, x2Axis); lineChart.getYAxis().setAutoRanging(false); lineChart.getYAxis().setAutoRanging(false); lineChart.setAnimated(false); return lineChart; }
/** * Set the chart with the selected length. * * @param xFrames * the x frame length * @param yFrames * the y frame length */ public void setChart(final int xFrames, final int yFrames) { this.xSeries = new XYChart.Series<>(); this.ySeries = new XYChart.Series<>(); this.lineChartX = RecordingFactory.createDerivativeLineChart(xFrames); this.lineChartY = RecordingFactory.createDerivativeLineChart(yFrames); this.lineChartX.getData().add(this.xSeries); this.lineChartY.getData().add(this.ySeries); this.lineChartX.setTitle("Derivative: X"); this.lineChartY.setTitle("Derivative: Y"); HBox.setHgrow(this.lineChartX, Priority.ALWAYS); HBox.setHgrow(this.lineChartY, Priority.ALWAYS); this.vbox.getChildren().setAll(this.lineChartX, this.lineChartY); }
public TPSChart() { final NumberAxis yAxis = new NumberAxis(); this.xAxis = new NumberAxis( 0, 512, 1000 ); this.xAxis.setAutoRanging( false ); this.chart = new LineChart<>( xAxis, yAxis ); this.chart.setAnimated( false ); this.chart.setCreateSymbols( false ); this.chart.setLegendVisible( false ); this.fullTimeSeries = new XYChart.Series<>(); this.actualTimeSeries = new XYChart.Series<>(); this.averageTimeSeries = new XYChart.Series<>(); this.scrollBar = new ScrollBar(); this.scrollBar.valueProperty().addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> observable, Number oldValue, Number newValue ) { currentDataStart = (int) ( newValue.floatValue() * ( TimeUnit.SECONDS.toNanos( 1 ) / tickNanos ) * 60 ); updateChart(); } } ); }
public Node getNode() { this.chart.getData().addAll( this.actualTimeSeries, this.fullTimeSeries, this.averageTimeSeries ); this.chart.setPrefHeight( 200 ); this.fullTimeSeries.getNode().setStyle( "-fx-stroke-width: 2px; -fx-stroke: #f34602;" ); this.actualTimeSeries.getNode().setStyle( "-fx-stroke-width: 2px; -fx-stroke: #f39502;" ); this.averageTimeSeries.getNode().setStyle( "-fx-stroke-width: 2px; -fx-stroke: #45df02;" ); updateChart(); return this.chart; }
static Node createLineChart() { NumberAxis xAxis = new NumberAxis("Values for X-Axis", 0, 3, 1); NumberAxis yAxis = new NumberAxis("Values for Y-Axis", 0, 3, 1); ObservableList<XYChart.Series<Double,Double>> lineChartData = FXCollections.observableArrayList( new LineChart.Series<Double,Double>("Series 1", FXCollections.observableArrayList( new XYChart.Data<Double,Double>(0.0, 1.0), new XYChart.Data<Double,Double>(1.2, 1.4), new XYChart.Data<Double,Double>(2.2, 1.9), new XYChart.Data<Double,Double>(2.7, 2.3), new XYChart.Data<Double,Double>(2.9, 0.5) )), new LineChart.Series<Double,Double>("Series 2", FXCollections.observableArrayList( new XYChart.Data<Double,Double>(0.0, 1.6), new XYChart.Data<Double,Double>(0.8, 0.4), new XYChart.Data<Double,Double>(1.4, 2.9), new XYChart.Data<Double,Double>(2.1, 1.3), new XYChart.Data<Double,Double>(2.6, 0.9) )) ); return new LineChart(xAxis, yAxis, lineChartData); }