Create barchart using jfreechart with bars of same category together

后端 未结 2 1049
生来不讨喜
生来不讨喜 2021-01-18 23:04

I want to make bar chart using jfreechart such that the bars which belong to the same category should be displayed adjacent without any gaps. The categories should be displa

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-19 00:08

    You can do this with the setCategoryMargin() method on the domain axis.

    For example with a Category Plot:

    CategoryPlot plot = chart.getCategoryPlot();
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryMargin(0.15f);
    

    You will need to play with different values for the margin to find the correct value for your graph.

提交回复
热议问题