Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX Chart Axis only shows last label

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);

Chart with missing axis labels Can you help me out here? Thank you!

like image 762
Heisenbug Avatar asked Aug 02 '15 17:08

Heisenbug


2 Answers

change your code like this

    xAxis1.setAnimated(false);
    yAxis1.setAnimated(true);
    barChart.setAnimated(true);
like image 132
Hosein Ghasemi Avatar answered Nov 13 '22 15:11

Hosein Ghasemi


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.

like image 29
chanklor Avatar answered Nov 13 '22 15:11

chanklor