List of usage examples for javafx.scene.chart NumberAxis NumberAxis
public NumberAxis()
From source file:Main.java
@Override public void start(Stage primaryStage) { CategoryAxis xAxis = new CategoryAxis(); NumberAxis yAxis = new NumberAxis(); BarChart barChart = new BarChart(xAxis, yAxis, getChartData()); barChart.setCategoryGap(0.2);//from w w w . ja va2 s.c o m barChart.setTitle("A"); primaryStage.setTitle("BarChart example"); StackPane root = new StackPane(); root.getChildren().add(barChart); 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(); BarChart barChart = new BarChart(xAxis, yAxis, getChartData()); barChart.setBarGap(0.2);/* ww w . ja va 2 s .c o m*/ barChart.setTitle("A"); primaryStage.setTitle("BarChart example"); StackPane root = new StackPane(); root.getChildren().add(barChart); 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 ava 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:Main.java
@Override public void start(Stage primaryStage) { CategoryAxis xAxis = new CategoryAxis(); NumberAxis yAxis = new NumberAxis(); BarChart barChart = new BarChart(xAxis, yAxis, getChartData()); barChart.setCategoryGap(0.2);//ww w. ja v a 2 s.co m System.out.println(barChart.getBarGap()); System.out.println(barChart.getCategoryGap()); barChart.setTitle("A"); primaryStage.setTitle("BarChart example"); StackPane root = new StackPane(); root.getChildren().add(barChart); primaryStage.setScene(new Scene(root, 400, 250)); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("Month"); xAxis.setCategories(/*w w w. j a v a2 s. c o m*/ FXCollections.<String>observableArrayList(Arrays.asList("January", "February", "March"))); yAxis.setLabel("Value"); final StackedBarChart<String, Number> stackedBarChart = new StackedBarChart<String, Number>(xAxis, yAxis); stackedBarChart.setTitle("StackedBarChart"); XYChart.Series<String, Number> series1 = new XYChart.Series(); series1.setName("XYChart.Series 1"); series1.getData().add(new XYChart.Data("January", 100)); series1.getData().add(new XYChart.Data("February", 200)); series1.getData().add(new XYChart.Data("March", 50)); XYChart.Series<String, Number> series2 = new XYChart.Series(); series2.setName("XYChart.Series 2"); series2.getData().add(new XYChart.Data("January", 150)); series2.getData().add(new XYChart.Data("February", 100)); series2.getData().add(new XYChart.Data("March", 60)); stackedBarChart.getData().addAll(series1, series2); root.getChildren().addAll(stackedBarChart); primaryStage.setScene(new Scene(root, 500, 400)); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { final NumberAxis xAxis = new NumberAxis(); final CategoryAxis yAxis = new CategoryAxis(); final BarChart<Number, String> bc = new BarChart<Number, String>(xAxis, yAxis); bc.setTitle("Summary"); xAxis.setLabel("Value"); xAxis.setTickLabelRotation(90);/*from www .j a v a 2s. c o m*/ yAxis.setLabel("Item"); XYChart.Series series1 = new XYChart.Series(); series1.setName("2003"); series1.getData().add(new XYChart.Data(2, itemA)); series1.getData().add(new XYChart.Data(20, itemB)); series1.getData().add(new XYChart.Data(10, itemC)); XYChart.Series series2 = new XYChart.Series(); series2.setName("2004"); series2.getData().add(new XYChart.Data(50, itemA)); series2.getData().add(new XYChart.Data(41, itemB)); series2.getData().add(new XYChart.Data(45, itemC)); XYChart.Series series3 = new XYChart.Series(); series3.setName("2005"); series3.getData().add(new XYChart.Data(45, itemA)); series3.getData().add(new XYChart.Data(44, itemB)); series3.getData().add(new XYChart.Data(18, itemC)); Timeline tl = new Timeline(); tl.getKeyFrames().add(new KeyFrame(Duration.millis(500), new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { for (XYChart.Series<Number, String> series : bc.getData()) { for (XYChart.Data<Number, String> data : series.getData()) { data.setXValue(Math.random() * 100); } } } })); tl.setCycleCount(Animation.INDEFINITE); tl.play(); Scene scene = new Scene(bc, 800, 600); bc.getData().addAll(series1, series2, series3); stage.setScene(scene); stage.show(); }
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))); }/*from w w w .j a v a2s . c om*/ 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.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 ww 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:gui.accessories.GraphPopup.java
private BarChart createBarChartDynamic() { SampleTableModel tableModel = new SampleTableModel(); CategoryAxis xAxis = new CategoryAxis(); xAxis.setCategories(FXCollections.<String>observableArrayList(tableModel.getColumnNames())); xAxis.setLabel("Year"); double tickUnit = tableModel.getTickUnit(); NumberAxis yAxis = new NumberAxis(); yAxis.setTickUnit(tickUnit);/*from ww w. j av a 2 s .c o m*/ yAxis.setLabel("Units Sold"); final BarChart aChart = new BarChart(xAxis, yAxis, tableModel.getBarChartData()); aChart.setAnimated(true); tableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { if (e.getType() == TableModelEvent.UPDATE) { final int row = e.getFirstRow(); final int column = e.getColumn(); final Object value = ((SampleTableModel) e.getSource()).getValueAt(row, column); Platform.runLater(new Runnable() { @Override public void run() { XYChart.Series<String, Number> s = (XYChart.Series<String, Number>) aChart.getData() .get(row); BarChart.Data data = s.getData().get(column); data.setYValue(value); } }); } } }); return aChart; }
From source file:nl.rivm.cib.fx.HelloWorldJavaFX.java
public Parent createContent() { final ObservableList<XYChart.Series<Double, Double>> lineChartData = FXCollections.observableArrayList( new LineChart.Series<>("Series 1", FXCollections.observableArrayList( new XYChart.Data<>(0.0, 1.0), new XYChart.Data<>(1.2, 1.4), new XYChart.Data<>(2.2, 1.9), new XYChart.Data<>(2.7, 2.3), new XYChart.Data<>(2.9, 0.5) )),/*from w ww.j ava2 s.co m*/ new LineChart.Series<>("Series 2", FXCollections.observableArrayList( new XYChart.Data<>(0.0, 1.6), new XYChart.Data<>(0.8, 0.4), new XYChart.Data<>(1.4, 2.9), new XYChart.Data<>(2.1, 1.3), new XYChart.Data<>(2.6, 0.9) )) ); final NumberAxis xAxis = new NumberAxis(); xAxis.setAutoRanging(false); xAxis.setTickLabelsVisible(false); xAxis.setTickMarkVisible(false); final NumberAxis yAxis = new NumberAxis(); yAxis.setAutoRanging(true); this.chart = new LineChart(xAxis, yAxis, lineChartData); return this.chart; }