Closing up blank space in JFreeChart bar chart

后端 未结 1 1910
孤独总比滥情好
孤独总比滥情好 2020-12-15 13:13

I am using JFreeChart and would like to display a bar chart of player\'s scores, with the score on the y-axis and the player\'s games grouped on the x-axis.

相关标签:
1条回答
  • 2020-12-15 14:04

    First Look at the Picture carefully enter image description here

    Here is some Explanation w.r.t Numbers.

    1. setLowerMargin(Double margin).
    2. setUpperMargin(Double margin).
    3. setCategoryMargin(Double margin).
    4. setItemMargin(Double margin).

    Here is How you can use the methods in your chart

     CategoryPlot p = chart.getCategoryPlot(); 
    
     CategoryAxis axis = p.getDomainAxis();
     axis.setLowerMargin(0.1);
     axis.setUpperMargin(0.1);
     axis.setCategoryMargin(0.1);
     BarRenderer renderer = (BarRenderer) p.getRenderer();
     renderer.setItemMargin(0.1); 
    

    You can set the value between 0.0 to 1.0 (example 0.1 means 10%)

    Hope this Helps

    (Update After your comment) Well in this Case you should use Layered Bar Chart

    enter image description here

    0 讨论(0)
提交回复
热议问题