Vote count:
0
This is the code I'm using to try to generate a line in my LineChart (with the use of JavaFX).
@FXML
private LineChart<Number, Number> graphChart;
public void fillGraphChart() {
graphChart.setTitle("Stock Monitoring, 2010");
final NumberAxis xAxis = new NumberAxis();
final NumberAxis yAxis = new NumberAxis();
xAxis.setLabel("Number of Month");
//creating the chart
graphChart = new LineChart<Number,Number>(xAxis,yAxis);
//defining a series
XYChart.Series series = new XYChart.Series();
series.setName("My portfolio");
//populating the series with data
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));
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));
graphChart.getXAxis().setAutoRanging(true);
graphChart.getYAxis().setAutoRanging(true);
graphChart.getData().add(series);
System.out.println("done");
}
The problem is, no line appears. The only thing that changes is the title and the axis'. I tried a lot of different things but can't get it to work.
Any help would be appreciated.
asked 51 secs ago
No content in LineChart (JavaFX)
Aucun commentaire:
Enregistrer un commentaire