java - Passing Locale details via Jasper-Reports to JFreechart -


I am adding internationalization to a tapestry web-app which uses the Jasper report to generate general tabular reports and Through this, charts and graphs also make JFreeChart.

Using the Jaspar REPORT_LOCALE parameter, I can set the locale for the Jasper report and it works beautifully for the tabular report but it does not work for the JFree Chart report.

Axis Tick labels are coming out in the default locale so that if I am doing the time series, then I will get the name of the month in the wrong language. The only way I came to know how to deal with this is to change JVM default locale which I'm not happy with.

Does anyone know if there is a way to configure JFreeChart to use a particular locale so that when Jasper invites it, then he uses that locale?

I just ran into it, and was able to move it around by creating a chart adapter class . / P>

In my .jrxml:

  & lt; Chart Assessment Time = "Report" customizerClass = "foo.Customizer" Render Type = "Picture" & gt;  

My customer class looks like this:

  package foo; Import java.text.NumberFormat; Import java.util.Locale; Import net.sf.jasperreports.engine.JRAbstractChartCustomizer; Import net sf.jasperreports.engine.jrChart; Import net sf.jasperreports.engine.jrparameter; Import org.jfree.chart.JFreeChart; Import org.jfree.chart.axis.NumberAxis; Import org.jfree.chart.plot.CategoryPlot; Public category optimizer enhances JRAbstractChartCustomizer {Optimize Public Zero (Geoffrey Chart Chart, Jr. Chart Jasper Chart) {Category Plot Plot = (Category Plot) chart.getPlot (); Number axis range xx = (number axis) plot. GetRangeAxis (); RangeAxis.setNumberFormatOverride (NumberFormat.getInstance (Locale) getParameterValue (JRParameter.REPORT_LOCALE))); }}  

Yes, this code creates many assumptions, but I always set up people clearly before running a report, so I know that is not empty and I know That's a class plot and number x in my special chart, so I do not have an example of checking. But you get this idea.

Charles


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -