List of usage examples for javafx.scene.chart LineChart LineChart
public LineChart(@NamedArg("xAxis") Axis<X> xAxis, @NamedArg("yAxis") Axis<Y> yAxis)
From source file:Main.java
@Override public void start(Stage stage) { final NumberAxis xAxis = new NumberAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("Number of Month"); final LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis); lineChart.setTitle("Line Chart"); XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>(); series.setName("My Data"); // populating the series with data series.getData().add(new XYChart.Data<Number, Number>(1, 23)); series.getData().add(new XYChart.Data<Number, Number>(2, 114)); series.getData().add(new XYChart.Data<Number, Number>(3, 15)); series.getData().add(new XYChart.Data<Number, Number>(4, 124)); Scene scene = new Scene(lineChart, 800, 600); lineChart.getData().add(series);/*w ww. j a v a 2s . c o m*/ stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("Month"); final LineChart<String, Number> lineChart = new LineChart<String, Number>(xAxis, yAxis); lineChart.setTitle("My Chart"); XYChart.Series<String, Number> series = new XYChart.Series<String, Number>(); series.setName("My data"); series.getData().add(new XYChart.Data<String, Number>("Jan", 23)); series.getData().add(new XYChart.Data<String, Number>("Feb", 114)); series.getData().add(new XYChart.Data<String, Number>("Mar", 15)); series.getData().add(new XYChart.Data<String, Number>("Apr", 24)); series.getData().add(new XYChart.Data<String, Number>("May", 134)); Scene scene = new Scene(lineChart, 800, 600); lineChart.getData().add(series);//from w w w. j av a 2 s . com stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("Month"); final LineChart<String, Number> lineChart = new LineChart<String, Number>(xAxis, yAxis); lineChart.setTitle("My Chart"); XYChart.Series<String, Number> series1 = new XYChart.Series<String, Number>(); series1.setName("Portfolio 1"); series1.getData().add(new XYChart.Data<String, Number>("Jan", 23)); series1.getData().add(new XYChart.Data<String, Number>("Feb", 14)); series1.getData().add(new XYChart.Data<String, Number>("Mar", 15)); XYChart.Series<String, Number> series2 = new XYChart.Series<String, Number>(); series2.setName("Portfolio 2"); series2.getData().add(new XYChart.Data<String, Number>("Jan", 33)); series2.getData().add(new XYChart.Data<String, Number>("Feb", 34)); series2.getData().add(new XYChart.Data<String, Number>("Mar", 25)); series2.getData().add(new XYChart.Data<String, Number>("Apr", 44)); XYChart.Series<String, Number> series3 = new XYChart.Series<String, Number>(); series3.setName("Portfolio 3"); series3.getData().add(new XYChart.Data<String, Number>("Jan", 44)); series3.getData().add(new XYChart.Data<String, Number>("Feb", 35)); series3.getData().add(new XYChart.Data<String, Number>("Mar", 36)); series3.getData().add(new XYChart.Data<String, Number>("Apr", 33)); series3.getData().add(new XYChart.Data<String, Number>("May", 31)); Scene scene = new Scene(lineChart, 800, 600); lineChart.getData().addAll(series1, series2, series3); stage.setScene(scene);/* www .j a va2 s . c o m*/ stage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { CategoryAxis xAxis = new CategoryAxis(); NumberAxis yAxis = new NumberAxis(); LineChart lineChart = new LineChart(xAxis, yAxis); lineChart.setData(getChartData());// ww w .j a va 2s. c o m lineChart.setTitle("Chart"); StackPane root = new StackPane(); root.getChildren().add(lineChart); primaryStage.setScene(new Scene(root, 400, 250)); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { CategoryAxis xAxis = new CategoryAxis(); NumberAxis yAxis = new NumberAxis(); LineChart lineChart = new LineChart(xAxis, yAxis); lineChart.setData(getChartData());/*from w w w. j a v a 2 s . co m*/ lineChart.setTitle("Chart"); primaryStage.setTitle("LineChart example"); StackPane root = new StackPane(); root.getChildren().add(lineChart); primaryStage.setScene(new Scene(root, 400, 250)); primaryStage.show(); }
From source file:com.deicos.lince.components.SinChartComponent.java
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))); }/*from www.ja va2 s.c o m*/ LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis); lineChart.setTitle("Sine function"); lineChart.getData().add(series); getChildren().add(lineChart); }
From source file:demo.components.SinChartComponent.java
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))); }/* w w w . j a va 2 s . c o m*/ LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis); lineChart.setTitle("Sine function"); lineChart.getData().add(series); getChildren().add(lineChart); }
From source file:com.jscriptive.moneyfx.ui.chart.ChartFrame.java
/** * This method is invoked when the daily balance button has been toggled * * @param actionEvent/*from w w w . ja va 2s. c om*/ */ public void dailyBalanceToggled(ActionEvent actionEvent) { LocalDateAxis xAxis = new LocalDateAxis(); NumberAxis yAxis = new NumberAxis(); final LineChart<LocalDate, Number> lineChart = new LineChart<>(xAxis, yAxis); lineChart.setCreateSymbols(false); chartFrame.setCenter(lineChart); ToggleButton toggle = (ToggleButton) actionEvent.getTarget(); if (toggle.isSelected()) { xAxis.setLabel("Day of year"); yAxis.setLabel("Balance in Euro"); lineChart.setTitle("Balance development day by day"); ValueRange<LocalDate> period = getTransactionOpRange(accountCombo.getValue(), yearCombo.getValue()); if (period.isEmpty()) { return; } xAxis.setLowerBound(period.from()); xAxis.setUpperBound(period.to()); Service<Void> service = new Service<Void>() { @Override protected Task<Void> createTask() { return new Task<Void>() { @Override protected Void call() throws Exception { Map<Account, List<Transaction>> transactionMap = getTransactions( accountCombo.getValue(), yearCombo.getValue()); transactionMap.entrySet().forEach(entry -> { Account account = entry.getKey(); List<Transaction> transactionList = entry.getValue(); XYChart.Series<LocalDate, Number> series = new XYChart.Series<>(); series.setName(format("%s [%s]", account.toPresentableString(), account.getFormattedBalance())); // sort transactions by operation value descending transactionList.sort((t1, t2) -> t2.getDtOp().compareTo(t1.getDtOp())); account.calculateStartingBalance(transactionList); series.getData() .add(new XYChart.Data<>(account.getBalanceDate(), account.getBalance())); // sort transactions by operation value ascending transactionList.sort((t1, t2) -> t1.getDtOp().compareTo(t2.getDtOp())); transactionList.forEach(trx -> { account.calculateCurrentBalance(trx); series.getData().add( new XYChart.Data<>(account.getBalanceDate(), account.getBalance())); }); Platform.runLater(() -> lineChart.getData().add(series)); }); return null; } }; } }; service.start(); } }
From source file:tw.edu.sju.ee.eea.module.iepe.project.window.IepeRealtimeSpectrumElement.java
private Scene createScene() { xAxis = new NumberAxis(0, MAX_DATA_POINTS, MAX_DATA_POINTS / 10); xAxis.setForceZeroInRange(false);//from w ww .java2 s . c om xAxis.setAutoRanging(false); NumberAxis yAxis = new NumberAxis(); yAxis.setAutoRanging(true); //-- Chart final LineChart<Number, Number> sc = new LineChart<Number, Number>(xAxis, yAxis) { // Override to remove symbols on each data point @Override protected void dataItemAdded(XYChart.Series<Number, Number> series, int itemIndex, XYChart.Data<Number, Number> item) { } }; sc.setAnimated(false); sc.setId("liveAreaChart"); sc.setTitle("Animated Area Chart"); //-- Chart Series series = new LineChart.Series<Number, Number>(); series.setName("Area Chart Series"); sc.getData().add(series); return new Scene(sc); }
From source file:org.specvis.view.screenandlumscale.ViewFitLumScaleController.java
private void initLineChart() { // 1. Define axes. NumberAxis xAxis = new NumberAxis(); NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("HSB Brightness (%)"); yAxis.setLabel("Luminance (cd/m2)"); // 2. Init lineChart. lineChart = new LineChart<>(xAxis, yAxis); lineChart.setTitle("Screen luminance scale"); // 3. Define chart series. XYChart.Series seriesFittedLuminance = new XYChart.Series(); seriesFittedLuminance.setName("Fitted luminance"); XYChart.Series seriesMeasuredLuminance = new XYChart.Series(); seriesMeasuredLuminance.setName("Measured luminance"); // 4. Get luminance scale. LuminanceScale luminanceScale;/*www . ja va 2 s .c om*/ if (StartApplication.getSpecvisData().getUiSettingsScreenAndLuminanceScale() .isThisWindowOpenedForStimulus()) { luminanceScale = StartApplication.getSpecvisData().getUiSettingsScreenAndLuminanceScale() .getStimulusLuminanceScale(); } else { luminanceScale = StartApplication.getSpecvisData().getUiSettingsScreenAndLuminanceScale() .getBackgroundLuminanceScale(); } // 5. Create short brightness vector. double[] shortBrightnessVector = new double[] { 0, 20, 40, 60, 80, 100 }; // 6. Get measured luminance values. double[] measuredLuminances = new double[] { luminanceScale.getLuminanceForBrightness0(), luminanceScale.getLuminanceForBrightness20(), luminanceScale.getLuminanceForBrightness40(), luminanceScale.getLuminanceForBrightness60(), luminanceScale.getLuminanceForBrightness80(), luminanceScale.getLuminanceForBrightness100() }; // 7. Create full brightness vector. double[] fullBrightnessVector = functions.createBrightnessVector(101); // 8. Nest data in series. for (int i = 0; i < fullBrightnessVector.length; i++) { seriesFittedLuminance.getData().add(new XYChart.Data(fullBrightnessVector[i], luminanceScale.getFittedLuminanceForEachBrightnessValue()[i])); } for (int i = 0; i < shortBrightnessVector.length; i++) { seriesMeasuredLuminance.getData() .add(new XYChart.Data(shortBrightnessVector[i], measuredLuminances[i])); } // 9. Add series to lineChart. lineChart.getData().addAll(seriesFittedLuminance, seriesMeasuredLuminance); vBox.getChildren().remove(vBox.getChildren().size() - 1); vBox.getChildren().add(lineChart); VBox.setVgrow(lineChart, Priority.ALWAYS); }