I am trying to add default data into a linechart however I keep getting a null pointer exception.
My code is:
public class MainController {
@FXML private LineChart<Number,Number> chtContrast;
.
.
.
private void setContrastChart() throws NullPointerException{
XYChart.Series<Number, Number> series1 = new XYChart.Series<>();
series1.setName("Series 1");
series1.getData().add(new XYChart.Data<>(0, 0));
series1.getData().add(new XYChart.Data<>(255, 255));
chtContrast.getData().add(series1);
}
}
I have the system to initilize but the null pointer exception happens on the line chtContrast.getData().add(series1);