My requirement is I have x and y axis units i.e seriesNames are in chinese.. I have passed the unicode characters of the units ( series name ) to XYSeries class. The value is properly shown in JSP page.. But in the JFreeChart's lengend are shown as boxes.. i.e the values are not shown.. probably the font or encoding may not be set probably.. Please help meto solve this issue..
Please let me know as how to localize the legends text in chinese characters..
My example code is attached here..
Code: Select all
XYSeriesCollection dataset = new XYSeriesCollection();
XYSeries xy= new XYSeries(series[j]);
dataset.addSeries(xy);
XYDataset data1 = new XYSeriesCollection(dataset.getSeries(0));
XYDataset data2 = new XYSeriesCollection(dataset.getSeries(1));
XYItemRenderer renderer1 = new AreaXYRenderer();
renderer1.setSeriesPaint(0, (Color)graphHash.get("PrimaryColor"));
renderer1.setToolTipGenerator(ttg);
ValueAxis rangeAxis = new ExtendedNumberAxis(yaxis);
rangeAxis.setStandardTickUnits(ExtendedNumberAxis.createIntegerTickUnits());
for(int i=0; i < maxStr.length; i++)
{
if(Double.parseDouble(maxStr[i])>0.0d)
{
rangeAxis.setStandardTickUnits(ExtendedNumberAxis.createStandardTickUnits());
break;
}
}
XYPlot plot;
{
DateAxis domainAxis = new DateAxis(null);
domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
domainAxis.setVerticalTickLabels(false);
plot = new XYPlot(data1, domainAxis, rangeAxis, renderer1);
}
StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(StandardXYItemRenderer.LINES);
renderer2.setToolTipGenerator(ttg);
renderer2.setSeriesPaint(0, (Color)graphHash.get("SecondaryColor"));
plot.setSecondaryDataset(0, data2);
plot.setSecondaryRenderer(0, renderer2);
//plot.setBackgroundAlpha((float)1.0);
plot.setInsets(new java.awt.Insets(10, 10, 10, 10));
plot.setWeight(20);
plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
plot.setDomainGridlinesVisible(true);
plot.setForegroundAlpha(.55f);
plot.setDomainGridlinePaint(Color.black);
plot.setRangeGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.black);
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
JFreeChart chart = new JFreeChart(title,new java.awt.Font("Helvetica",java.awt.Font.BOLD,11), plot, legend);
Thanks
R.Ravikumar