This case is to display data with swing. Need to introduce Jfreechart related packages, different versions may not be the same, I use this case in the SSI framework will be error, without the framework is not a problem. Java Background Logic Code:
public class Barchart {Chartpanel frame1;public barchart () {Categorydataset DataSet = GetDataSet (); Jfreechart chart = Chartfactory.createbarchart3d ("fruit",//Chart title "Fruit Type",//Catalog Axis display label "Quantity",//value axis display label DataSet,//DataSet Plotorie Ntation. VERTICAL,//Chart direction: Horizontal, vertical true,//Whether the legend is displayed (the simple histogram must be false) false,//whether the build tool false//generates a URL link);//starting from here categoryplot plot = ch Art.getcategoryplot ();//Gets the chart area object Categoryaxis Domainaxis = Plot.getdomainaxis (); Horizontal bottom list Domainaxis.setlabelfont (new Font ("Blackbody", Font.Bold, 14)); Horizontal Bottom Header Domainaxis.setticklabelfont (new Font ("Arial", Font.Bold, 12)); Vertical caption Valueaxis Rangeaxis = Plot.getrangeaxis ();//Get Columnar Rangeaxis.setlabelfont (new Font ("Blackbody", Font.Bold, 15)); Chart.getlegend (). Setitemfont (New font ("Black body", font.bold,)), Chart.gettitle (). SetFont (New Font ("Arial", Font.Bold, 20)) ;//Set the title Font//to end here, although the code is a bit more, but only for one purpose, solve the problem of Chinese characters garbled frame1 = new Chartpanel (chart, True); You can also use Chartframe to generate a standalone frame}private static Categorydataset GetDataSet () {Defaultcategorydataset DataSet = new DefaultcaTegorydataset (); list<news> data = new arraylist<news> (); Newsdao dao = new Newsdao (); arraylist<news> list = Dao.queryall ();d ouble value = 0; String Rowkeys=null; String columnkeys=null;for (News news:list) {//data.add (New News (News.getnewsid (), News.gettypeid (), News//.gettitle ( ), News.getpublishtime (), News.getbody (), News//.gettag (), News.getauthor (), News.getclicks (), News//.getimgurl ()); Value = News.getnewsid (); Rowkeys = News.gettitle (); Columnkeys = News.getauthor ();d ataset.addvalue (value, Rowkeys, Columnkeys); System.out.println (value+ "" +rowkeys+ "" +columnkeys);} if (value!=0&&rowkeys!=null&&columnkeys!=null) {//system.out.println (value+ "" +rowKeys+ "" + Columnkeys);//dataset.addvalue (value, Rowkeys, Columnkeys);//}//dataset.addvalue (100, "Beijing", "apple");// Dataset.addvalue (100, "Shanghai", "Apple"),//dataset.addvalue (100, "Guangzhou", "Apple"),//dataset.addvalue (200, "Beijing", "pear");// Dataset.addvalue (200, "Shanghai", "pear"),//dataset.addvalue (200, "Guangzhou", "pear");//dataset.addvalue (300, "Beijing", "Grape"),//dataset.addvalue (300, "Shanghai", "Grape"),//dataset.addvalue (300, "Guangzhou", "Grape"),//dataset.addvalue (400, "Beijing" , "banana"),//dataset.addvalue (400, "Shanghai", "banana"),//dataset.addvalue (400, "Guangzhou", "Banana"),//dataset.addvalue (500, "Beijing", "Litchi"); /dataset.addvalue (500, "Shanghai", "Litchi"),//dataset.addvalue (500, "Guangzhou", "Litchi"); return dataset;} Public Chartpanel Getchartpanel () {return frame1;} public static void Main (string[] args) {JFrame frame = new JFrame ("Java Data Chart");//Frame.setlayout (New GridLayout (2,2,10,1 0)); Frame.add (new Barchart (). Getchartpanel ()); Add a Column chart//Frame.add (New BarChart1 (). Getchartpanel ()); Another effect of adding a column chart//Frame.add (New Piechart (). Getchartpanel ()); Add a pie chart//Frame.add (New Timeserieschart (). Getchartpanel ()); Add a Line chart frame.setbounds (.); Frame.setvisible (True);}}Other classes are not on the code, as you normally do with databases. See Zhang: [Data scrambling]