private void addDataToSeries() { for (int i = 0; i < 50; i++) { // -- add some new samples to the plot if (ErrorProfileView.dataError.isEmpty()) { break; } this.errorSeries.getData().add( new LineChart.Data<Number, Number>(this.xSeriesData++, ErrorProfileView.dataError.remove())); } // remove points to keep us at no more than MAX_DATA_POINTS if (this.errorSeries.getData().size() > ErrorProfileView.MAX_DATA_POINTS) { this.errorSeries.getData().remove( 0, this.errorSeries.getData().size() - ErrorProfileView.MAX_DATA_POINTS); } // update Axis this.xAxis.setLowerBound(this.xSeriesData - ErrorProfileView.MAX_DATA_POINTS); this.xAxis.setUpperBound(this.xSeriesData - 1); }
public void simpleIndexChart(Stage stage) { stage.setTitle("Index Chart"); final LineChart<String, Number> lineChart = new LineChart<>(xAxis, yAxis); lineChart.setTitle("Belgium Population"); yAxis.setLabel("Population"); series.setName("Population"); addDataItem(series, "1950", 8639369); addDataItem(series, "1960", 9118700); addDataItem(series, "1970", 9637800); addDataItem(series, "1980", 9846800); addDataItem(series, "1990", 9969310); addDataItem(series, "2000", 10263618); Scene scene = new Scene(lineChart, 800, 600); lineChart.getData().add(series); stage.setScene(scene); stage.show(); }
private void init(Stage primaryStage) { Group root = new Group(); primaryStage.setScene(new Scene(root)); 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) )) ); LineChart chart = new LineChart(xAxis, yAxis, lineChartData); root.getChildren().add(chart); }
protected LineChart<Number, Number> createChart() { final NumberAxis xAxis = new NumberAxis(); final NumberAxis yAxis = new NumberAxis(); final LineChart<Number,Number> lc = new LineChart<Number,Number>(xAxis,yAxis); // setup chart lc.setTitle("Basic LineChart"); xAxis.setLabel("X Axis"); yAxis.setLabel("Y Axis"); // add starting data XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>(); series.setName("Data Series 1"); series.getData().add(new XYChart.Data<Number,Number>(20d, 50d)); series.getData().add(new XYChart.Data<Number,Number>(40d, 80d)); series.getData().add(new XYChart.Data<Number,Number>(50d, 90d)); series.getData().add(new XYChart.Data<Number,Number>(70d, 30d)); series.getData().add(new XYChart.Data<Number,Number>(170d, 122d)); lc.getData().add(series); return lc; }
protected LineChart<String, Number> createChart() { final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); final LineChart<String,Number> lc = new LineChart<String,Number>(xAxis,yAxis); // setup chart lc.setTitle("LineChart with Category Axis"); xAxis.setLabel("X Axis"); yAxis.setLabel("Y Axis"); // add starting data XYChart.Series<String,Number> series = new XYChart.Series<String,Number>(); series.setName("Data Series 1"); series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[0], 50d)); series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[1], 80d)); series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[2], 90d)); series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[3], 30d)); series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[4], 122d)); series.getData().add(new XYChart.Data<String,Number>(CATEGORIES[5], 10d)); lc.getData().add(series); return lc; }
public LineChartSample() { 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) )) ); LineChart chart = new LineChart(xAxis, yAxis, lineChartData); getChildren().add(chart); }
public MonitorPaneTemplate() { super(); super.getStyleClass().add("pane"); x = new NumberAxis(); x.setAutoRanging(false); y = new NumberAxis(); y.setAutoRanging(false); chart = new LineChart<>(x, y); chart.setCreateSymbols(false); chart.legendVisibleProperty().setValue(false); chart.setPrefHeight(250); chart.setPrefWidth(750); data = new Series<>(); chart.getData().add(data); super.getChildren().add(chart); }
private static EventHandler<Event> createZoomOutLineChartEventHandler(LineChart<String, Number> lineChart, Scene scene, int originalIndexInParent) { return new EventHandler<Event>() { @Override public void handle(Event e) { lineChart.removeEventHandler(MouseEvent.MOUSE_CLICKED, this); zoomOutAndReset(lineChart); resetToOriginalIndexInParent(lineChart, originalIndexInParent); lineChart.addEventHandler(MouseEvent.MOUSE_CLICKED, createZoomInLineChartEventHandler(lineChart, scene)); } }; }
private static EventHandler<Event> createZoomInLineChartEventHandler(LineChart<String, Number> lineChart, Scene scene) { return new EventHandler<Event>() { @Override public void handle(Event e) { lineChart.removeEventHandler(MouseEvent.MOUSE_CLICKED, this); int originalIndexInParent = getOriginalIndexInParent(lineChart); zoomInAndCenter(lineChart, lineChart.getWidth(), lineChart.getHeight(), false); lineChart.addEventHandler(MouseEvent.MOUSE_CLICKED, createZoomOutLineChartEventHandler(lineChart, scene, originalIndexInParent)); } }; }
@Override public void initialize(URL location, ResourceBundle resources) { sdf = new SimpleDateFormat(Constants.TIMEFORMAT); NumberAxis numberAxis = new NumberAxis(); DateAxis dateAxis = new DateAxis(); lightChart = new LineChart<>(dateAxis, numberAxis); contentPane.setCenter(lightChart); intervalCB.setItems(GraphInterval.INTERVALS); intervalCB.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { if (sensor != null) { sensor.setGraphInterval(newValue); } }); intervalCB.getSelectionModel().select(1); }
@Override public void initialize(URL location, ResourceBundle resources) { sdf = new SimpleDateFormat(Constants.TIMEFORMAT); NumberAxis numberAxis = new NumberAxis(); DateAxis dateAxis = new DateAxis(); lightChart = new LineChart<>(dateAxis, numberAxis); lightChart.setLegendVisible(false); lightChart.setCreateSymbols(false); contentPane.setCenter(lightChart); intervalCB.setItems(GraphInterval.INTERVALS); intervalCB.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { if (sensor != null) { sensor.setGraphInterval(newValue); } }); intervalCB.getSelectionModel().select(1); }
@Override public void initialize(URL location, ResourceBundle resources) { sdf = new SimpleDateFormat(Constants.TIMEFORMAT); isNameEdit = false; NumberAxis numberAxis = new NumberAxis(); numberAxis.setForceZeroInRange(false); DateAxis dateAxis = new DateAxis(); tempChart = new LineChart<>(dateAxis, numberAxis); tempChart.setLegendVisible(false); tempChart.setCreateSymbols(false); contentPane.setCenter(tempChart); intervalCB.setItems(GraphInterval.INTERVALS); intervalCB.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { if (sensor != null) { sensor.setGraphInterval(newValue); } }); intervalCB.getSelectionModel().select(1); offsetCB.setItems(OFFSET_VALUES); offsetCB.getSelectionModel().select(6); }
public DashboardPIDTuner(String name) { super(name, FlashboardSendableType.PIDTUNER); series = new LineChart.Series<Number, Number>(); kp = new SimpleDoubleProperty(); ki = new SimpleDoubleProperty(); kd = new SimpleDoubleProperty(); kf = new SimpleDoubleProperty(); setpoint = new SimpleDoubleProperty(); valueBinder = new SimpleDoubleProperty(); timeBinder = new SimpleDoubleProperty(); funcPeriodBinder = new SimpleDoubleProperty(); setpointBinder = new SimpleStringProperty("0.0"); tuners.put(name, this); }
/** * get the LineChart for this history * @return - the line chart */ @SuppressWarnings("rawtypes") public LineChart<Number, Number> createLineChart() { //defining the axes final NumberAxis xAxis = new NumberAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel(xTitle); //creating the chart lineChart = new LineChart<Number,Number>(xAxis,yAxis); lineChart.setTitle(title); for (CANProperty canProperty : this.canProperties.values()) { Series<Number, Number> series = this.createSeries(canProperty); seriesMap.put(canProperty.getName(), series); updateSeries(series,canProperty); lineChart.getData().add(series); } return lineChart; }
@Override public void start(Stage stage) { final NumberAxis xAxis = new NumberAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel(xName); yAxis.setLabel(yName); final LineChart<Number,Number> lineChart = new LineChart<Number,Number>(xAxis,yAxis); lineChart.setTitle(title); XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>(); for (int i=1; i<n+1; i++){ series.getData().add(new XYChart.Data<Number, Number>(x[i], y[i])); } Scene scene = new Scene(lineChart,800,600); lineChart.getData().add(series); stage.setScene(scene); stage.show(); }
private void displayIndex(Map<String, Double> resultIndex, String title, String header) { BaseDialog dialog = new BaseDialog(title, header); dialog.getDialogPane().setPrefSize(800, 600); dialog.getDialogPane().getButtonTypes().addAll(new ButtonType(Configuration.getBundle().getString("ui.actions.stats.close"), ButtonBar.ButtonData.CANCEL_CLOSE)); // draw final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); final LineChart<String,Number> lineChart = new LineChart<>(xAxis, yAxis); lineChart.setTitle(title); lineChart.setLegendVisible(false); xAxis.setLabel(Configuration.getBundle().getString("ui.actions.stats.xaxis")); yAxis.setLabel(Configuration.getBundle().getString("ui.actions.readable.yaxis")); XYChart.Series<String, Number> series = new XYChart.Series(); for(Map.Entry<String, Double> st:resultIndex.entrySet()) { series.getData().add(new XYChart.Data(st.getKey(), st.getValue())); } lineChart.getData().addAll(series); dialog.getDialogPane().setContent(lineChart); dialog.setResizable(true); dialog.showAndWait(); }
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(); } } ); }
private void initializeChart(){ controllerNames = simulator.getControllerNames(); lineChartData = FXCollections.observableArrayList(); // Create set point data set setPointSeries = new LineChart.Series<Double, Double>(); setPointSeries.setName("Set Point"); lineChartData.add(setPointSeries); // Create plant output data sets plantOutputSeries = new ArrayList<LineChart.Series<Double, Double>>(); for (int controller = 0; controller < controllerNames.length; controller++) { plantOutputSeries.add(new LineChart.Series<Double,Double>()); plantOutputSeries.get(controller).setName(controllerNames[controller]); lineChartData.add(plantOutputSeries.get(controller)); } chart.setCreateSymbols(false); chart.setData(lineChartData); chart.createSymbolsProperty(); }
@Override public Node drawNode() { final NumberAxis xAxis = new NumberAxis(); final NumberAxis yAxis = new NumberAxis(); final LineChart<Number, Number> chart = new LineChart<>(xAxis, yAxis); XYChart.Series series = new XYChart.Series(); series.getData().add(new XYChart.Data(8, 45)); series.getData().add(new XYChart.Data(9, 43)); series.getData().add(new XYChart.Data(10, 17)); series.getData().add(new XYChart.Data(11, 29)); series.getData().add(new XYChart.Data(12, 25)); series.getData().add(new XYChart.Data(1, 23)); series.getData().add(new XYChart.Data(2, 14)); series.getData().add(new XYChart.Data(3, 15)); series.getData().add(new XYChart.Data(4, 24)); series.getData().add(new XYChart.Data(5, 34)); series.getData().add(new XYChart.Data(6, 36)); series.getData().add(new XYChart.Data(7, 22)); chart.getData().add(series); return chart; }
public GraphView(String chartName, String dataName, LoggerController controller) { this.updateTimer = new UpdateTimer(); this.chartName = chartName; this.plotData = new ConcurrentHashMap<>(); this.xA = new NumberAxis(0, 20, 20 / 10); this.xA.setForceZeroInRange(false); this.xA.setAutoRanging(false); this.yA = new NumberAxis(); yA.setAutoRanging(true); // this.graph = new AreaChart<Number, Number>(xA, yA); this.graphIn = new LineChart<Number, Number>(xA, yA); this.graphOut = new LineChart<Number, Number>(xA, yA); this.destinations = new HashSet<>(); // this.graph.setAnimated(true); this.graphIn.setTitle(chartName + " in"); this.graphOut.setTitle(chartName + " out"); this.dataName = dataName; this.controller = controller; }
@SuppressWarnings({"unchecked", "rawtypes"}) protected void makeChart(String comp, String period, String periodCB, String interval) { XYChart.Series series = new XYChart.Series(); List<ChartData> stocks = getChartData(comp, period, periodCB, interval); for (int i = stocks.size() - 1; i >= 0; i--) { findStartAndEnd(stocks, i); XYChart.Data data = setData(stocks, i); series.getData().add(data); } final NumberAxis yAxis = new NumberAxis(startValue, endValue * 1.04, (endValue - startValue) / 20); final CategoryAxis xAxis = new CategoryAxis(); lineChart = new LineChart<String, Number>(xAxis, yAxis); lineChart.setTitle(comp); lineChart.getData().addAll(series); lineChart.setLegendVisible(false); }
private void updateChartStyles() { int n = chart instanceof XYChart<?, ?> ? ((XYChart<?, ?>)chart).getData().size() : 1; List<String> stylesheets = new ArrayList<>(); stylesheets.add(getClass().getClassLoader().getResource("css/charts/chart_base.css").toExternalForm()); stylesheets.add(chartStyleProperty.get().getStylesheet(n)); stylesheets.add(strokeWidthProperty.get().getStylesheet(n)); if (!useSolidLines.get()) stylesheets.add(getClass().getClassLoader().getResource("css/charts/chart_strokes_dashed.css").toExternalForm()); chart.getStylesheets().setAll(stylesheets); // Set the legend to be more appropriate for a line chart if (chart instanceof LineChart<?, ?> && chart.isLegendVisible()) ChartToolsFX.setLineChartLegendLines(chart, 25); persistentStrokeWidthProperty.set(strokeWidthProperty.get()); persistentChartStyleProperty.set(chartStyleProperty.get()); persistentSolidLinesProperty.set(useSolidLines.get()); }
@Override public void start(Stage stage) throws Exception { final long startTime = System.currentTimeMillis(); chart = new LineChart<Number, Number>(new NumberAxis("Size distortion", 0, .6, 0.1), new NumberAxis("Shape distortion", 0, .6, 0.1)); chart.setCreateSymbols(true); chart.setAxisSortingPolicy(SortingPolicy.NONE); double[][][] globe = Projection.globe(0.01); PrintStream log = new PrintStream(new File("output/parameters.txt")); chart.getData().add(analyzeAll(globe, EXISTING_PROJECTIONS)); for (Projection p: PROJECTIONS_TO_OPTIMIZE) chart.getData().add(optimizeFamily(p, globe, log)); System.out.println("Total time elapsed: " + (System.currentTimeMillis() - startTime) / 60000. + "m"); stage.setTitle("Map Projections"); stage.setScene(new Scene(chart)); ImageIO.write(SwingFXUtils.fromFXImage(chart.snapshot(null, null), null), "png", new File("output/graph - optimizer.png")); stage.show(); log.close(); }
private Node createGraph() { // create a graph node to be acted on by the controls. // setup graph NumberAxis xAxis = new NumberAxis(); xAxis.setLabel("X Axis"); NumberAxis yAxis = new NumberAxis(); yAxis.setLabel("Y Axis"); LineChart<Number,Number> graph = new LineChart<Number,Number>(xAxis,yAxis); graph.setTitle("Test Graph"); graph.setCreateSymbols(false); // add starting data XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>(); series.setName("Squares"); for (int x = 0; x <= 10; x++) series.getData().add(new XYChart.Data<Number,Number>(x, x * x)); graph.getData().add(series); graph.setMinSize(300, 260); graph.setMaxSize(300, 260); //return graph; return new Circos(new long[]{34,56,90, 65, 10}, null, null); }
private static Scene createScene() { javafx.scene.chart.NumberAxis myaxis1 = new javafx.scene.chart.NumberAxis(); javafx.scene.chart.NumberAxis myaxis2 = new javafx.scene.chart.NumberAxis(); LineChart lc = new LineChart(myaxis1, myaxis2); XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>(); series.setName(plotName); lc.setTitle(plotTitle); int N = pointsX.length; for (int k = 0; k < N; k++) series.getData().add(new XYChart.Data<Number, Number>(pointsX[k], pointsY[k])); lc.getData().add(series); BorderPane pane = new BorderPane(); pane.setCenter(lc); Scene myScene = new Scene(pane, Color.ALICEBLUE); return myScene; }
private void createChart() { xAxis = new NumberAxis();// lowerBoundX, upperBoundX, CHART_AXIS_TICK_UNIT); yAxis = new NumberAxis();// lowerBoundY, upperBoundY, CHART_AXIS_TICK_UNIT); chart = new LineChart<>(xAxis, yAxis); xAxis.setLabel("X"); yAxis.setLabel("Y"); final List<XYChart.Series<Number, Number>> seriesList = createChartSeries(); chart.getData().addAll(seriesList); chartPane = new StackPane(chart); VBox.setVgrow(chartPane, Priority.ALWAYS); chartBox.getChildren().add(0, chartPane); addDataItemChangeListener(); addSelectionListener(); addDataImportListener(); }
@Override public void start(Stage stage) { stage.setTitle("Beacon RSSI"); //defining the axes final NumberAxis xAxis = new NumberAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("Minute"); xAxis.setAutoRanging(true); xAxis.setForceZeroInRange(false); //creating the chart final LineChart<Number, Number> lineChart = new LineChart<>(xAxis, yAxis); lineChart.setTitle("Beacon RSSI"); //defining a series XYChart.Series series = new XYChart.Series(); series.setName("RSSI"); //populating the series with data series.getData().addAll(data); Scene scene = new Scene(lineChart, 800, 600); lineChart.getData().add(series); stage.setScene(scene); stage.show(); }
private void addDataToSeries() { for (int i = 0; i < 100; i++) { // -- add some new samples to the plot if (AltitudeProfileView.dataBarometricAltitude.isEmpty()) { break; } this.barometricAltitudeSeries .getData() .add(new LineChart.Data<Number, Number>( this.barometricAltitudeXSeriesDataPosition++, AltitudeProfileView.dataBarometricAltitude.remove())); } // remove points to keep us at no more than MAX_DATA_POINTS if (this.barometricAltitudeSeries.getData().size() > AltitudeProfileView.MAX_DATA_POINTS) { this.barometricAltitudeSeries.getData().remove( 0, this.barometricAltitudeSeries.getData().size() - AltitudeProfileView.MAX_DATA_POINTS); } // update Axis this.xAxis.setLowerBound(this.barometricAltitudeXSeriesDataPosition - AltitudeProfileView.MAX_DATA_POINTS); this.xAxis.setUpperBound(this.barometricAltitudeXSeriesDataPosition - 1); }
private void addDataToSeries() { for (int i = 0; i < 50; i++) { // -- add some new samples to the plot if (VelocityProfileView.dataEstimatedVelocity.isEmpty()) { break; } this.estimatedVelocitySeries .getData() .add(new LineChart.Data<Number, Number>(this.xSeriesData++, VelocityProfileView.dataEstimatedVelocity.remove())); } // remove points to keep us at no more than MAX_DATA_POINTS if (this.estimatedVelocitySeries.getData().size() > VelocityProfileView.MAX_DATA_POINTS) { this.estimatedVelocitySeries.getData().remove( 0, this.estimatedVelocitySeries.getData().size() - VelocityProfileView.MAX_DATA_POINTS); } // update Axis this.xAxis.setLowerBound(this.xSeriesData - VelocityProfileView.MAX_DATA_POINTS); this.xAxis.setUpperBound(this.xSeriesData - 1); }
private void addDataToSeries() { for (int i = 0; i < 50; i++) { // -- add some new samples to the plot if (EstimatedAltitudeProfileView.dataEstimatedAltitude.isEmpty()) { break; } this.estimatedAltitudeSeries.getData().add( new LineChart.Data<Number, Number>( this.estimatedAltitudeXSeriesDataPosition++, EstimatedAltitudeProfileView.dataEstimatedAltitude .remove())); } // remove points to keep us at no more than MAX_DATA_POINTS if (this.estimatedAltitudeSeries.getData().size() > EstimatedAltitudeProfileView.MAX_DATA_POINTS) { this.estimatedAltitudeSeries.getData().remove( 0, this.estimatedAltitudeSeries.getData().size() - EstimatedAltitudeProfileView.MAX_DATA_POINTS); } // update Axis this.xAxis.setLowerBound(this.estimatedAltitudeXSeriesDataPosition - EstimatedAltitudeProfileView.MAX_DATA_POINTS); this.xAxis.setUpperBound(this.estimatedAltitudeXSeriesDataPosition - 1); }