Recently used Jfreechart to complete the project's image export task, the Chinese garbled problem whole afternoon, only to finish
Java code
/** * Configuration Font * * @param chart * Jfreechart object/private static void Configfont (Jfreechart chart) {//config font xfont = new Font ("Arial, Font.plain,")//x axis font yfont = new Font ("Arial", Font.plain,)/y axis font kfont = new Font ("Arial", Font.plain , 12);//Bottom Font Titlefont = new Font ("Official script", Font.Bold, 25); Picture title Categoryplot plot = Chart.getcategoryplot ()///Picture caption Chart.settitle (new Texttitle (). GetText (), Titlefont)); Bottom Chart.getlegend (). Setitemfont (Kfont); X-axis Categoryaxis Domainaxis = Plot.getdomainaxis (); Domainaxis.setlabelfont (XFONT);//Axis title Domainaxis.setticklabelfont (XFONT);//axis Numeric Domainaxis.setticklabelpaint ( Color.Blue); Font Color domainaxis.setcategorylabelpositions (categorylabelpositions.up_45); The label skew on the horizontal axis//Y axis Valueaxis Rangeaxis = Plot.getrangeaxis (); Rangeaxis.setlabelfont (Yfont); Rangeaxis.setlabelpaint (Color.Blue); Font Color Rangeaxis.setticklabelfont (yfont); }
Used in
The Chartfactory.createpiechart3d method will complain
Org.apache.jasper.JasperException:java.lang.ClassCastException:org.jfree.chart.plot.PiePlot3D cannot be cast to Org.jfree.chart.plot.CategoryPlot