JFREECHART我试了好像不行吧,好像能用于JSP,但我需要在JPANEL里画个柱状图,要六个柱子,两个一组要相互比较高度,要画出X和Y轴,Y轴时时间,X轴是三组个名称,三个STRING就行,我自己添

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【lsjlovebm】截止到2008-06-23 12:29:51的历史汇总数据(不包括此帖):
    发帖数:7                  发帖分:85                 
    结贴数:7                  结贴分:85                 
    未结数:0                  未结分:0                  
    结贴率:100.00%            结分率:100.00%            
    敬礼!
      

  2.   

    当然可以啊Jfreechart的demo不就很多都是基于swing的吗
      

  3.   


    去看demo, 没有源代码就用 dj 反编译看!
      

  4.   

    我将下面的代码下入一个BUTTON 的MOUSECLICKED 的事件里,可是点击该BUTTON 无反应,怎么改呀public class BarCharts extends ApplicationFrame {  public BarCharts(String s) {
      super(s);
      setContentPane(createDemoBar());
     }  // 生成显示图表的面板
     public static JPanel createDemoBar() {
      JFreeChart jfreechart = createChart(createDataset());
      return new ChartPanel(jfreechart);
     }  // 生成图表主对象JFreeChart
     public static JFreeChart createChart(CategoryDataset dataset) {
      JFreeChart chart = ChartFactory.createBarChart3D("水果销量统计图", //建立3D柱状图
        "水果",//横轴名称
        "销量",//纵轴名称
        dataset,//数据集
        PlotOrientation.VERTICAL,//纵向显示
        true,//显示每个颜色柱子的柱名
        false, false);
      CategoryPlot plot = chart.getCategoryPlot();//设置图的高级属性
      BarRenderer3D renderer = new BarRenderer3D();//3D属性修改
      renderer.setBaseOutlinePaint(Color.BLACK);//设置边框颜色为black
      renderer.setWallPaint(Color.gray); //设置wall的颜色为gray
      renderer
        .setItemLabelGenerator(new StandardCategoryItemLabelGenerator());//设置柱顶数据,API中居然没有StandardCategoryItemLabelGenerator这个类
      //renderer.setItemLabelFont(new Font("黑体",Font.PLAIN,12));//设置柱顶数据字体
      renderer.setItemLabelsVisible(true);//打开ItemLabel开关
      plot.setRenderer(renderer);//将修改后的属性值保存到图中
      plot.setForegroundAlpha(0.6f);//柱的透明度   return chart;
     }  // 生成数据
     public static CategoryDataset createDataset() {   double[][] data = new double[][] { { 672, 766, 223, 540, 126 },
        { 325, 521, 210, 340, 106 }, { 332, 256, 523, 240, 526 } };// 设置数据
      String[] rowKeys = { "苹果", "梨子", "葡萄" };// 行标志
      String[] columnKeys = { "北京", "上海", "广州", "成都", "深圳" };// 列标志
      CategoryDataset linedataset = DatasetUtilities.createCategoryDataset(
        rowKeys, columnKeys, data); // 建立数据集   return linedataset;
     }  public static void main(String[] args) {
      BarCharts fjc = new BarCharts("柱状图");
      fjc.pack();
      RefineryUtilities.centerFrameOnScreen(fjc);
      fjc.setVisible(true);  } } 
      

  5.   

    我将下面的代码下入一个BUTTON 的MOUSECLICKED 的事件里,可是点击该BUTTON 无反应,怎么改呀 public class BarCharts extends ApplicationFrame { public BarCharts(String s) { 
      super(s); 
      setContentPane(createDemoBar()); 
    } // 生成显示图表的面板 
    public static JPanel createDemoBar() { 
      JFreeChart jfreechart = createChart(createDataset()); 
      return new ChartPanel(jfreechart); 
    } // 生成图表主对象JFreeChart 
    public static JFreeChart createChart(CategoryDataset dataset) { 
      JFreeChart chart = ChartFactory.createBarChart3D("水果销量统计图", //建立3D柱状图 
        "水果",//横轴名称 
        "销量",//纵轴名称 
        dataset,//数据集 
        PlotOrientation.VERTICAL,//纵向显示 
        true,//显示每个颜色柱子的柱名 
        false, false); 
      CategoryPlot plot = chart.getCategoryPlot();//设置图的高级属性 
      BarRenderer3D renderer = new BarRenderer3D();//3D属性修改 
      renderer.setBaseOutlinePaint(Color.BLACK);//设置边框颜色为black 
      renderer.setWallPaint(Color.gray); //设置wall的颜色为gray 
      renderer 
        .setItemLabelGenerator(new StandardCategoryItemLabelGenerator());//设置柱顶数据,API中居然没有StandardCategoryItemLabelGenerator这个类 
      //renderer.setItemLabelFont(new Font("黑体",Font.PLAIN,12));//设置柱顶数据字体 
      renderer.setItemLabelsVisible(true);//打开ItemLabel开关 
      plot.setRenderer(renderer);//将修改后的属性值保存到图中 
      plot.setForegroundAlpha(0.6f);//柱的透明度   return chart; 
    } // 生成数据 
    public static CategoryDataset createDataset() {   double[][] data = new double[][] { { 672, 766, 223, 540, 126 }, 
        { 325, 521, 210, 340, 106 }, { 332, 256, 523, 240, 526 } };// 设置数据 
      String[] rowKeys = { "苹果", "梨子", "葡萄" };// 行标志 
      String[] columnKeys = { "北京", "上海", "广州", "成都", "深圳" };// 列标志 
      CategoryDataset linedataset = DatasetUtilities.createCategoryDataset( 
        rowKeys, columnKeys, data); // 建立数据集   return linedataset; 
    } public static void main(String[] args) { 
      BarCharts fjc = new BarCharts("柱状图"); 
      fjc.pack(); 
      RefineryUtilities.centerFrameOnScreen(fjc); 
      fjc.setVisible(true); } } 
      

  6.   

    我将下面的代码下入一个BUTTON 的MOUSECLICKED 的事件里,可是点击该BUTTON 无反应,怎么改呀 
    什么意思?