What are the steps to use Customiser Chart Class?

2019-08-02 08:14发布

问题:

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.");
 }
}

I want a chart look like this:

回答1:

you can try this:

NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis();
rangeAxis.setVerticalTickLabels(true);