Add the following code to solve the problem of Chinese character garbled Categoryaxis domainaxis = categoryplot.getdomainaxis (); /*------Set the text on the x-axis coordinates-----------*/ domainaxis.setticklabelfont ("Sans-serif",  FONT.PLAIN, 11)); /*------Set the title text for the x-axis------------*/ domainaxis.setlabelfont ("XXFarEastFont-Arial").  FONT.PLAIN, 12)); /*------Set the text on the y-coordinate-----------*/ Numberaxis.setticklabelfont (" Sans-serif ", font.plain, 12)); /*------Set the y-axis title text------------*/ Numberaxis.setlabelfont ("bold",  FONT.PLAIN, 12)); /*------This code solves the problem of the bottom character garbled-----------*/ jfreechart.getlegend (). Setitemfont ( New font ("Arial", font.plain, 12));
Categoryaxis Domainaxis = Categoryplot.getdomainaxis ();
/*------Set the text on the x-axis coordinates-----------
/domainaxis.setticklabelfont (New Font ("Sans-serif", Font.plain, one));
/*------Set the title text of the x axis------------
/Domainaxis.setlabelfont (New Font ("XXFarEastFont-Font.plain,");
/*------Set the text on the y-coordinate-----------
/numberaxis.setticklabelfont (New Font ("Sans-serif", Font.plain,);
/*------Set the y-axis title text------------
/numberaxis.setlabelfont (new Font ("bold", Font.plain,);
/*------This code solves the problem of the bottom Chinese character garbled-----------
/Jfreechart.getlegend (). Setitemfont (New Font ("Arial", Font.plain, 12));
Operation effect is as follows
Full code view Copy to clipboard print package net.java2000.jfreechat.demo.bar; import java.awt.color; import java.awt.dimension; import java.awt.font; import java.awt.gradientpaint; import javax.swing.jpanel; import org.jfree.chart.chartfactory; import org.jfree.chart.chartpanel; import org.jfree.chart.jfreechart; import org.jfree.chart.axis.categoryaxis; import org.jfree.chart.axis.categorylabelpositions; import org.jfree.chart.axis.numberaxis; import org.jfree.chart.labels.standardcategoryserieslabelgenerator; import org.jfree.chart.plot.categoryplot; import org.jfree.chart.plot.plotorientation; import org.jfree.chart.renderer.category.barrenderer; Import org.jfree.data.categorY.categorydataset; import org.jfree.data.category.defaultcategorydataset; import org.jfree.ui.applicationframe; import org.jfree.ui.refineryutilities; public class barchartdemo1 extends applicationframe { public barchartdemo1 (string s) { super (s); jpanel jpanel = createdemopanel (); jpanel.setpreferredsize (New dimension (500, 270)); setcontentpane (JPanel); } private static CategoryDataset CreateDataSet () { String s = "Daily PV"; String s1 = "Daily IP number";    &NBSp string s2 = "Number of registered users"; String s3 = "a website"; String s4 = "b website"; String s5 = "C website"; String s6 = "D website"; String s7 = "e website"; DefaultCategoryDataset defaultcategorydataset = new Defaultcategorydataset (); defaultcategorydataset.addvalue (1.0D, S, S3); defaultcategorydataset.addvalue (4D, S, S4); defaultcategorydataset.addvalue (3D, S, S5); defaultcategorydataset.addvalue (5D, S, S6); defaultcategorydataset.addvalue (5D, S, S7); &Nbsp; defaultcategorydataset.addvalue (5D, S1, S3); defaultcategorydataset.addvalue (7D, S1, S4); defaultcategorydataset.addvalue (6D, S1, S5); defaultcategorydataset.addvalue (8D, S1, S6); defaultcategorydataset.addvalue (4D, S1, S7); defaultcategorydataset.addvalue (4D, S2, S3); defaultcategorydataset.addvalue (3D, S2, S4); defaultcategorydataset.addvalue (2D, S2, S5); defaultcategorydataset.addvalue (3D, S2, S6); defaultcategorydataset.addvalue (6D, S2, S7); return defaultcategorydataset;   } private static jfreechart createchart (categorydataset Categorydataset) { JFreeChart jfreechart = Chartfactory.createbarchart ("bar chart demo 1", "website", "value", categorydataset, plotorientation.vertical, true, true, false); CategoryPlot categoryplot = (Categoryplot) Jfreechart.getplot (); categoryplot.setdomaingridlinesvisible (TRUE); categoryplot.setrangecrosshairvisible (TRUE); categoryplot.setrangecrosshairpaint (Color.Blue); NumberAxis numberaxis = (Numberaxis) Categoryplot.getrangeaxis (); numberaxis.setstandaRdtickunits (Numberaxis.createintegertickunits ()); BarRenderer barrenderer = (barrenderer) Categoryplot.getrenderer (); barrenderer.setbaseitemlabelfont ("XXFarEastFont-New font", font.plain,  12)); barrenderer.setseriesitemlabelfont (1, new font ("XXFarEastFont-, ") FONT.PLAIN, 12)); CategoryAxis domainAxis = Categoryplot.getdomainaxis (); /*------Set the text on the x-axis coordinates-----------*/ domainaxis.setticklabelfont (New font ("Sans-serif", font.plain, 11)); /*------Set the title text of the x axis------------*/ domainaxis.setlabelfont (New font ("XXFarEastFont-Arial", font.plain, 12)); /*------Set on the y axis coordinatesText-----------*/ numberaxis.setticklabelfont (New font ("Sans-serif"),  FONT.PLAIN, 12)); /*------Set the y-axis caption text------------*/ numberaxis.setlabelfont (New font ("Blackbody", font.plain, 12)); /*------This code solves the problem of the bottom character garbled-----------*/ jfreechart.getlegend (). Setitemfont (New font ("XXFarEastFont-Arial", font.plain, 12)); barrenderer.setdrawbaroutline (false); gradientpaint gradientpaint = new gradientpaint (0.0F, 0.0f, color.blue, 0.0f, 0.0f, new color ( 0, 0, 64));     GRADIENTPAINT GRADIENTPAINT1 = NEW&NBSp Gradientpaint (0.0f, 0.0f, color.green, 0.0f, 0.0f, new color (0, 64, 0)); gradientpaint gradientpaint2 = new gradientpaint (0.0F, 0.0f, color.red, 0.0f, 0.0f, new color ( 64, 0, 0)); barrenderer.setseriespaint (0, gradientpaint); barrenderer.setseriespaint (1, GRADIENTPAINT1); barrenderer.setseriespaint (2, gradientpaint2); barrenderer.setlegenditemtooltipgenerator (new Standardcategoryserieslabelgenerator ( "Tooltip:  {0} ")); categoryaxis categoryaxis = categorYplot.getdomainaxis (); categoryaxis.setcategorylabelpositions (categorylabelpositions .createuprotationlabelpositions (0.52359877559829882D)); return jfreechart; } public static JPanel Createdemopanel () { jfreechart jfreechart = createchart (CreateDataSet ()); return new chartpanel (Jfreechart);  } public static void main (String args[]) { BarChartDemo1 barchartdemo1 = new BarChartDemo1 ("boldface Jfreechart: barchartdemo1.java"); barchartdemo1.pack (); refineryutilIties.centerframeonscreen (BARCHARTDEMO1); barchartdemo1.setvisible (TRUE); } }