做了两组统计数据,分别用两个jfreechart控件显示,
一组是随时间变化的柱状图展示,一组是随时间变化的折线图展示现想将这两组数据整合在一个坐标系下展示,
不知道什么控件支持这个功能, jfreechart能行吗?望高手给予帮助,谢谢!

解决方案 »

  1.   

    可以的,我最近也准备用jfreechart,你看一下源代码中DualAxisDemo1.java,那个图就是柱状和折线在一起的,不过两边都有不同的纵轴。
      

  2.   

    public static JFreeChart createDualAxisChart(CategoryDataset dataset){
            JFreeChart chart=ChartFactory.createBarChart3D(
                    "标题",
                    "索引",
                    "concrete",
                    dataset,//柱图数据集
                    PlotOrientation.VERTICAL,
                    true,
                    true,
                    false);        /*********解决字体乱码*******/
            chart.getLegend().setItemFont(CHART_FONT);
            chart.getTitle().setFont(CHART_FONT);
            // 获得坐标轴对象Axis,横轴对象:
            Axis axis=chart.getCategoryPlot().getDomainAxis();
            // 纵轴对象:
            Axis axis1=chart.getCategoryPlot().getRangeAxis();
            axis.setLabelFont(CHART_FONT);
            axis.setTickLabelFont(CHART_FONT);
            axis1.setLabelFont(CHART_FONT);        //设置图片背景色
            chart.setBackgroundPaint(Color.white);        CategoryPlot plot=(CategoryPlot)chart.getPlot();        CategoryAxis categoryaxis=plot.getDomainAxis();
            // CategoryLabelPositions.DOWN_45 表示label样式 倾斜角度
            categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
            //设置标签宽度
            categoryaxis.setMaximumCategoryLabelWidthRatio(20F);        //建另一个轴
            NumberAxis numberAxis=new NumberAxis("数值");
            numberAxis.setLabelFont(CHART_FONT);
            plot.setRangeAxis(1,numberAxis);        //设置数据集索引,拆线图的数据集
            plot.setDataset(1,dataset);
            //将该索引映射到axis 第一个参数指数据集的索引,第二个参数为坐标轴的索引
            plot.mapDatasetToRangeAxis(1,1);
            LineAndShapeRenderer lineAndShapeRenderer=new LineAndShapeRenderer();        //设置某坐标轴索引上数据集的显示样式,第一个值如果为0,那柱状图就没了.
            plot.setRenderer(1,lineAndShapeRenderer);
            /*设置两个图的前后顺序 ,DatasetRenderingOrder.FORWARD表示后面的图在前者上面 ,
            DatasetRenderingOrder.REVERSE表示 表示后面的图在前者后面*/
            plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
            return chart;
        }
    能满足基本需求了
      

  3.   

     jfreechart完全可以达到你想要的效果,
    楼主想学习的话,我的资源里面有完整的项目例子,不妨下来看看http://d.download.csdn.net/down/1562713/min123456520
      

  4.   

    使用Ext3.0,非常容易实现,只要传递一个json数据就可以了,其余的交给Ext来处理!