简体   繁体   中英

Java jasper reports valueAxis position

I would like to change the valueAxis(bar) to be on the right side of my stacked bar. Am struggling to change it cause once i change the position then i will change the orientation.

Please find below my source

<barPlot>
<plot orientation="Horizontal">
  <seriesColor seriesOrder="0" color="#FFFF80"/>
  <seriesColor seriesOrder="1" color="#FF8000"/>
  <seriesColor seriesOrder="2" color="#F47A00"/>
</plot>
<itemLabel/>
  <categoryAxisFormat>
<axisFormat/>
</categoryAxisFormat>
<valueAxisFormat>
<axisFormat/>
</valueAxisFormat>
</barPlot>

You can add a chart customizer to your chart to make the modification. Learn about how to do that here: http://mdahlman.wordpress.com/2010/08/18/chart-customizers-1/

The command you need to change the axis location is setRangeAxisLocation .

plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

So your customizer would look something like this:

public class myCustomizer implements JRChartCustomizer {
  public void customize(JFreeChart chart, JRChart jasperChart) {
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM