What are the steps to use Customiser Chart Class?

2019-08-02 07:58发布

I want to customised my charts in my reports (using jasperReport and iReport 4.0) ,this class minimise the scale ,how can I also add value on top of each bar and write the properity on X axis vertically because their are overlapping (look at the attach chart it's a mess)?

this is the class:

public class ChartCustomiser implements JRChartCustomizer{

 @Override
 public void customize(JFreeChart jfc, JRChart jrc) {

  CategoryPlot plot = (CategoryPlot)jfc.getPlot();
  ValueAxis verticalAxis = plot.getRangeAxis();
  TickUnits verticalTicks = new TickUnits();
  verticalTicks.add(new NumberTickUnit(1));
  verticalTicks.add(new NumberTickUnit(2));
  verticalTicks.add(new NumberTickUnit(5));
  verticalTicks.add(new NumberTickUnit(10));
  verticalAxis.setStandardTickUnits(verticalTicks); 
  throw new UnsupportedOperationException("Not supported yet.");
 }
}

enter image description here

I want a chart look like this:

enter image description here

1条回答
Bombasti
2楼-- · 2019-08-02 08:58

you can try this:

NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis();
rangeAxis.setVerticalTickLabels(true);
查看更多
登录 后发表回答