Search code examples
javafx-2bar-chartlinechart

JavaFx 2.x: BarChart with both axes as numbers


1) I want a BarChart where both axes are numbers(<Number, Number>), but it seems like this isn't supported and that you need to have a category and a number axis.

Is there a way to override the BarChart class to get both axes as Number, Number?

2) Is it possibile to use LineChart to plot bars instead of BarChart class to get a histogram plot ?


Solution

  • Found a good solution: I suggest to do in this way

    series.getData().add(new XYChart.Data(i, 0));
    series.getData().add(new XYChart.Data(i, listValue));          
    series.getData().add(new XYChart.Data(i, 0));
    

    in this way you can use LineChart to plot bars

    also, if you want to remove symbols from AreaChart you can accomplish this by using css

    .chart-area-symbol 
                { -fx-background-color: null, null; }