5

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 ?

The Unfun Cat
  • 29,987
  • 31
  • 114
  • 156
famedoro
  • 1,223
  • 2
  • 17
  • 41

2 Answers2

3

You can try this solution

XYChart.Series series = new XYChart.Series();                        
        series.getData().add(new XYChart.Data(i, i));
        series.getData().add(new XYChart.Data(i, listValue));            
        lineChart.getData().addAll(series);

but I warn you it is very slow compared to Number axis

Alberto acepsut
  • 1,972
  • 10
  • 41
  • 87
2

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; }
user1803551
  • 12,965
  • 5
  • 47
  • 74
Alberto acepsut
  • 1,972
  • 10
  • 41
  • 87
  • Just a note - Instead of modifying the CSS, you can use chart.setCreateSymbols(false), you also don't need duplicated (i, 0) points – Chris Nov 20 '18 at 15:54