jfreechart生成三维折线图(AJava.org群友原创)

/**  
* @author star 
* http://ajava.org  
* 折线图  
*/  
public class PolyLine {   
       
    public static void createPolyLine(){   
           
        /*    
         * 报表字体    
         */     
       final  Font CHART_FONT = new Font("宋体", 12, 12);      
           
           
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();   
        dataset.addValue(100, "ten", "jfree");   
        dataset.addValue(150, "ten", "chart");   
        dataset.addValue(300, "ten", "struts");   
        dataset.addValue(100, "ten", "hibernate");   
        /*  
        三维折线图把createLineChart换成createLineChart3D就可以实现三维折线图。  
         */  
        JFreeChart chart = ChartFactory.createLineChart(   
                "chart",                    // 标题   
                "num",                      // 横坐标   
                "type",                     // 纵坐标   
                dataset,                    // 数据   
                PlotOrientation.VERTICAL,   // 竖直图表   
                true,                       // 是否显示legend   
                false,                      // 是否显示tooltip   
                false                       // 是否使用url链接   
            );   
        //XYPlot plot = null;   
  
        // 设置字体,解决中文乱码问题     
        chart.getTitle().setFont(CHART_FONT);      
        chart.getLegend().setItemFont(CHART_FONT);      
        // plot.getRangeAxis().setLabelFont(CHART_FONT);      
        //plot.getDomainAxis().setLabelFont(new Font("宋体", 12, 24));   
        FileOutputStream fos = null;   
  
        try {   
            fos = new FileOutputStream("src/poly.png");   
            ChartUtilities.writeChartAsPNG(fos, chart, 400, 300);   
        } catch (FileNotFoundException e) {   
            e.printStackTrace();   
        } catch (IOException e) {   
            e.printStackTrace();   
        } finally {   
            try {   
                fos.close();   
            } catch (IOException e) {   
                e.printStackTrace();   
            }   
        }   
    }   
       
    public static void main(String[] args) {   
        PolyLine.createPolyLine();   
    }   
  
}  

你可能感兴趣的:(Hibernate,struts,jfreechart)