Michael Knight
Michael Knight

Reputation: 648

jasper reports axis lines thikness

I am customizing the default charts generated by Jasper Reports and I cannot find the way to make the axis lines thicker.

So far I easily found examples to change the color: http://www.jfree.org/forum/viewtopic.php?f=3&t=11639 but this is easier to be changed by the editor.

I attach an image to illustrate the expected thickness compared to the current one.

Current result

This is my current customizer:

public void customize(JFreeChart jFreeChart, JRChart jrChart) {

    CategoryPlot plot = (CategoryPlot) jFreeChart.getPlot();
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);


    BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
    barRenderer.setItemMargin(0.0);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    NumberFormat numberFormat= NumberFormat.getNumberInstance();
    numberFormat.setMaximumFractionDigits(2);
    numberFormat.setMinimumFractionDigits(2);
    rangeAxis.setNumberFormatOverride(numberFormat);
    rangeAxis.setUpperMargin(0.2);
    rangeAxis.setAutoRange(true); //make sure that fixed range is not set
}

GitHub: https://github.com/MichaelKnight/jaspertest.git

Upvotes: 1

Views: 205

Answers (1)

Petter Friberg
Petter Friberg

Reputation: 21710

To set the Stroke of CategoryAxis and NumberAxis add the following code in your customize:

CategoryAxis categoryAxis = plot.getDomainAxis();
categoryAxis.setAxisLineStroke(new BasicStroke(2f)); //see API link below for BasicStroke

NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setAxisLineStroke(new BasicStroke(2f));

BasicStroke API

Upvotes: 3

Related Questions