I have the following problem when using any JavaFX Chart: I dynamically add data to the chart and only the last X-Axis label shows up.
I already noticed that the chart is displayed fine when animations are disabled.
XYChart.Series<String,Double> series1= new Series<String, Double>();
series1.setName(scenario1.getName());
XYChart.Series<String,Double> series2= new Series<String, Double>();
series2.setName(scenario2.getName());
for(int period = 0; period < config1.getPeriods(); period++){
series1.getData().add(new Data<String, Double>("Period "+(period+1), rmList1.get(0).getCashflowsPerPeriod(config1)[period]));
System.out.println("Series1: "+rmList1.get(0).getCashflowsPerPeriod(config1)[period]);
}
for(int period = 0; period < config2.getPeriods(); period++){
series2.getData().add(new Data<String, Double>("Period "+(period+1), rmList2.get(0).getCashflowsPerPeriod(config2)[period]));
System.out.println("Series2: "+rmList2.get(0).getCashflowsPerPeriod(config2)[period]);
}
sacCashflows.getData().addAll(series1,series2);
Can you help me out here? Thank you!
change your code like this
xAxis1.setAnimated(false);
yAxis1.setAnimated(true);
barChart.setAnimated(true);
Disabling the animation worked for me.
sacCashflows.setAnimated(false);
I know you said in the comments that you had already tried that and it hadn't worked, but maybe for someone else having the same problem it will.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With