有这样一个需求,根据数据库中数据形成相应的饼图(可能还要有直方图),我运用了JFreeChar,但是还有一个问题
点击相应的块(形成的饼图的块)要执行一个代码,例如弹出不同的页面,貌似这个功能实现不了~~
最好不是运用Flex的,对Flex并不是很了解
请问有什么好的解决
方案么?

解决方案 »

  1.   

    你的问题jfreechart是可以解决的参考http://topic.csdn.net/u/20090506/17/e688a7d2-d207-4e1d-9ce9-99e574e9fcb7.html
      

  2.   

    JFREECHAT支持hotpoint,你查一下资料
      

  3.   

    http://pfwang.javaeye.com/blog/88927
      

  4.   

    你可以看看 FusionChart,有免费的版本。
      

  5.   

    JFreeChart chart = ChartFactory.createBarChart(chartTitle, // 图表标题 
            xName, // 目录轴的显示标签 
            yName, // 数值轴的显示标签 
            dataset, // 数据集 
            PlotOrientation.VERTICAL, // 图表方向:水平、垂直 
            true, // 是否显示图例(对于简单的柱状图必须是false) 
            true, // 是否生成工具 
            true // 是否生成URL链接 
            ); JFreeChart 的构造方法有很多重载,基本上你想要实现的东西都有的。呵呵、。
      

  6.   

    我找了几个例子,但是始终没弄好,清大家帮忙看看
    DAO//map与DefaultPieDataset互相转换
    private PieDataset createDataset(Map<String,Number> map)
    {
    DefaultPieDataset defaultpiedataset = new DefaultPieDataset();

      Set<String> set=map.keySet();
     
      for(String s:set)
      {
      if(s==null||s.equals(null)||s.equals(""))
      {
     
      }else
      {
      defaultpiedataset.setValue(s, map.get(s));
      }
      } 
    return defaultpiedataset;
    } //2d饼图
    public JFreeChart secondMap(JFCBean jfcb)
     {
    //利用本类方法讲map转换为PieDataset
        PieDataset piedata=this.createDataset(jfcb.getMap());
        
        //获得2d饼图
        JFreeChart jfreechart=ChartFactory.createPieChart(jfcb.getTitle(), piedata, true, true, true);
        
        //获取图形状态
    PiePlot pieplot=(PiePlot) jfreechart.getPlot();

    //设置字体 
        pieplot.setLabelFont(new Font("宋体", 0, 12));
        
        pieplot.setURLGenerator(new StandardPieURLGenerator("view.jsp")) ;
        
        //设置没有数据时,显示的字
        pieplot.setNoDataMessage("暂时没有您可以查看的数据");
        
        //设置没有数据时的字体
        pieplot.setNoDataMessageFont(new Font("宋体", Font.PLAIN, 30)) ;
        
        //饼图是否一定是正圆
        pieplot.setCircular(true);
        
        pieplot.setLabelGap(0.02D);
        
        pieplot.setBackgroundPaint(new Color(199,237,204));
        
        
         pieplot.setSectionPaint(0,new Color(7,233,6)) ;
             pieplot.setSectionPaint(1,new Color(248,16,0)) ;
             pieplot.setSectionPaint(2,new Color(252,144,0)) ;
             pieplot.setSectionPaint(3,new Color(91,169,227)) ;
        
        //分类标签的格式,设置成null则整个标签包括连接线都不显示
            pieplot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} {2}",NumberFormat.getNumberInstance(),new DecimalFormat("0.00%")));         return jfreechart ;
     }JSP<body>
        <img src="<%=request.getContextPath()%>/ShowImg" usemap="map0">
      </body>Servletpublic void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    {
    JFreeChartUtil jfcu = new JFreeChartUtilImpl() ; 

    JFCBean jfcb = new JFCBean() ; Map<String,Number> m = new HashMap() ;
    m.put("高中以下",370) ;
    m.put("高中",1530) ;
    m.put("大专",5700) ;
    m.put("本科",8280) ;
    m.put("硕士",4420) ;
    m.put("博士",80) ;

    jfcb.setTitle("测试用图") ;
    jfcb.setMap(m) ;

    StandardEntityCollection sec = new StandardEntityCollection() ; 
    ChartRenderingInfo info = new ChartRenderingInfo(sec) ;

    ServletUtilities.saveChartAsPNG(jfcu.secondMap(jfcb), 500, 300, info, request.getSession()) ; 

    ChartUtilities.writeImageMap(new PrintWriter(response.getWriter()), "map0", info, false) ;
    //ChartUtilities.writeChartAsPNG(response.getOutputStream(),jfcu.secondMap(jfcb), 500,300) ; }
    我将JFreeChart的一些属性进行了封装,封装成了一个Beanpublic class JFCBean
    {
    private String title ; //图片名,公用
    private String xMsg ;  //x轴名字,柱状图
    private String yMsg ;  //y轴名字,柱状图
    private DefaultCategoryDataset dataSet ; //数据集,要显示的数据,,柱状图,必填
    private Map<String,Number> map ;// 数据集,饼图,必填
    private boolean showFont = true ; //柱状图上面的字,是否显示,true显示,false不显示
    }基本就这么多代码。请大家帮忙看看
      

  7.   


    对,我们现在就是用的fusionChart,客户还当面说过效果比freechart的好,呵呵
      

  8.   

    fusionChart确实很不错,但是我也想了解一下JFreeChart的热点功能。