Jump to content

bar chart: wrong label font


andrey_nado

Recommended Posts

Hi!

I've turned on showing labels in my bar chart (<barPlot isShowLabels="true">). Labels are displayed right to bars (my chart is horizontal).  It works well but label font is incorrect. Legend, title, axis labels are all dispalyed in proper font - default report font. How can I control font of bar labels?

Thank you!

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Log this as a bug, somethings seems to be missing here.

In the meantime, you can set the bar label font by using a chart customizer as below.  Alternatively, you can extend the default chart theme to do the same thing.

Regards,

Lucian

Code:
package jr;import java.awt.Font;import net.sf.jasperreports.engine.JRChart;import net.sf.jasperreports.engine.JRChartCustomizer;import net.sf.jasperreports.engine.util.JRFontUtil;import org.jfree.chart.JFreeChart;import org.jfree.chart.renderer.category.BarRenderer;public class BarChartCustomizer implements JRChartCustomizer{	public void customize(JFreeChart chart, JRChart jasperChart)	{		BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer();		Font font = JRFontUtil.getAwtFont(jasperChart.getTitleFont(), null);		renderer.setBaseItemLabelFont(font);	}}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...