zoukankan      html  css  js  c++  java
  • jfreechar中文乱码设置主题样式解决

    package cn.sh.jfreechar.test;
    
    import java.awt.Font;
    
    import org.jfree.chart.ChartFactory;
    import org.jfree.chart.ChartFrame;
    import org.jfree.chart.JFreeChart;
    import org.jfree.chart.StandardChartTheme;
    import org.jfree.chart.plot.PlotOrientation;
    import org.jfree.data.category.DefaultCategoryDataset;
    
    /**
     * 柱状图--设置主题样式解决中文乱码
     * @ClassName:JfreeChartTest
     * @Description:TODO
     * @author: Administrator
     * @date:2012-2-22下午04:22:46
     */
    public class JfreeChartTest {   
        
        public static void main(String[] args) {     
            //     创建类别图(Category)数据对象            
            DefaultCategoryDataset dataset = new DefaultCategoryDataset();            
            dataset.addValue(100, "北京", "苹果");            
            dataset.addValue(100, "上海", "苹果");            
            dataset.addValue(100, "广州", "苹果");            
            dataset.addValue(200, "北京", "梨子");            
            dataset.addValue(200, "上海", "梨子");            
            dataset.addValue(200, "广州", "梨子");            
            dataset.addValue(300, "北京", "葡萄");            
            dataset.addValue(300, "上海", "葡萄");            
            dataset.addValue(300, "广州", "葡萄");            
            dataset.addValue(400, "北京", "香蕉");            
            dataset.addValue(400, "上海", "香蕉");            
            dataset.addValue(400, "广州", "香蕉");            
            dataset.addValue(500, "北京", "荔枝");            
            dataset.addValue(500, "上海", "荔枝");            
            dataset.addValue(500, "广州", "荔枝");         
            //创建主题样式         
            StandardChartTheme standardChartTheme=new StandardChartTheme("CN");         
            //设置标题字体        
            standardChartTheme.setExtraLargeFont(new Font("隶书",Font.BOLD,20));         
            //设置图例的字体         
            standardChartTheme.setRegularFont(new Font("宋书",Font.PLAIN,15));         
            //设置轴向的字体        
            standardChartTheme.setLargeFont(new Font("宋书",Font.PLAIN,15));         
            //应用主题样式        
            ChartFactory.setChartTheme(standardChartTheme);          
            JFreeChart chart=ChartFactory.createBarChart3D(
                    "水果产量图",    // 图表标题 
                    "水果",    // 目录轴的显示标签  
                    "水果",    // 数值轴的显示标签  
                    dataset,    // 数据集  
                    PlotOrientation.VERTICAL,    // 图表方向:水平、垂直 
                    true,    // 是否显示图例(对于简单的柱状图必须是false) 
                    true,    // 是否生成工具 
                    true     // 是否生成URL链接  
                    );   
            ChartFrame  frame=new ChartFrame ("水果产量图 ",chart,true);         
            frame.pack();         
            frame.setVisible(true);      
            
        }
    }


     

  • 相关阅读:
    poj 1328 Radar Installation (贪心)
    hdu 2037 今年暑假不AC (贪心)
    poj 2965 The Pilots Brothers' refrigerator (dfs)
    poj 1753 Flip Game (dfs)
    hdu 2838 Cow Sorting (树状数组)
    hdu 1058 Humble Numbers (DP)
    hdu 1069 Monkey and Banana (DP)
    hdu 1087 Super Jumping! Jumping! Jumping! (DP)
    必须知道的.NET FrameWork
    使用记事本+CSC编译程序
  • 原文地址:https://www.cnblogs.com/andgoo/p/2538313.html
Copyright © 2011-2022 走看看