List of usage examples for javafx.scene.chart BarChart BarChart
public BarChart(@NamedArg("xAxis") Axis<X> xAxis, @NamedArg("yAxis") Axis<Y> yAxis, @NamedArg("data") ObservableList<Series<X, Y>> data)
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.setTitle("A"); primaryStage.setTitle("BarChart example"); StackPane root = new StackPane(); root.getChildren().add(barChart);//w w w .j av a 2 s. c o m 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);//from www . j av a 2 s . c om 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);//from ww w . j a v a 2 s. c om 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.setCategoryGap(0.2);/*w w w . ja va 2 s . c om*/ 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: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 a v a2s . c om 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:gui.accessories.BattleSimFx.java
private BarChart createBarChart() { 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);/* w w w . j a v a 2 s . c o m*/ yAxis.setLabel("Units Sold"); final BarChart aChart = new BarChart(xAxis, yAxis, tableModel.getBarChartData()); 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:SampleTableModel.java
private BarChart createBarChart() { 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);/* w ww. j ava 2 s. c o m*/ yAxis.setLabel("Units Sold"); final BarChart chart = new BarChart(xAxis, yAxis, tableModel.getBarChartData()); tableModel.addTableModelListener(new TableModelListener() { 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() { public void run() { XYChart.Series<String, Number> s = (XYChart.Series<String, Number>) chart.getData() .get(row); BarChart.Data data = s.getData().get(column); data.setYValue(value); } }); } } }); return chart; }