Jfreechart Chinese garbled one-stop solution a way to fix

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.