fusionchart在SSH中的使用

1.导入fusionchart的包

2.action中的写法

/**
     * 环比
     * @return
     */
    public String hb_chart(){
        String econIndexId=firstTeconIndexId;//getRequest().getParameter("econIndexId");
        //System.out.println("同比指标"+econIndexId);
        Integer year = Integer.valueOf(selectyear);
        
        String econName = sysEconIndexManager.getNameByindexid(econIndexId);
        List<Object[]> list= serviceEconIndexDatasManager.computeRate(econIndexId, year);
        String strXML="<graph caption='"+econName+" "+year+"年环比增长统计' PYAxisName='total' SYAxisName='rate'" +
            " showPercentValues='1'  showPercentInToolTip='1' showLabels='1' " +
            "showValues='1' numDivLines='10'  decimalPrecision='0'" +
            " anchorSides='10' anchorRadius='3' anchorBorderColor='009900' decimalPrecision='4' >";
       /* String strXML="<graph caption='生产总值 季度统计' baseSize='10' PYAxisName='价格' SYAxisName='rate' showPercentValues='1'" +
        " showPercentInToolTip='1' showLabels='1' showValues='1' numDivLines='10'  decimalPrecision='4'" +
        
        " anchorSides='10' anchorRadius='3' anchorBorderColor='009900' decimalPrecision='0'>"; */
        strXML=strXML+"<categories>";
        for(int i=0;i<list.size();i++){
            Object[] oc =list.get(i);
             strXML= strXML+"<category name='"+oc[2]+"月'/>";  
        }
         strXML= strXML+"</categories>";
         strXML=strXML+"<dataset seriesName='上月' renderAs='Line' parentYAxis='P'  color='AFD8F8' showValues='0'>";
        
          for(int i=0;i<list.size();i++){
                Object[] oc =list.get(i);
                
                 strXML= strXML+"<set value='"+oc[4]+"' />";  
            }
             strXML= strXML+"</dataset>";
            
             strXML=strXML+"<dataset seriesName='"+year+"' renderAs='Line' parentYAxis='P' color='F6BD0F' showValues='0'>";
            
              for(int i=0;i<list.size();i++){
                    Object[] oc =list.get(i);
                    
                     strXML= strXML+"<set value='"+oc[3]+"' />";  
                }
                 strXML= strXML+"</dataset>";
          strXML=strXML+"<dataset seriesName='环比增长率%' lineThickness='1' parentYAxis='S'  color='8BBA00' showValues='0' numberSuffix='%25' >";
                
                  for(int i=0;i<list.size();i++){
                        Object[] oc =list.get(i);
                        
                         strXML= strXML+"<set value='"+oc[5]+"' />";  
                    }
                     strXML= strXML+"</dataset>";
                     strXML= strXML+"</graph>";

                     xmlStr=strXML;
                  
        return SUCCESS;
    }


3.jsp中的使用


    function createTB(strXML) {
        var chart1 = new FusionCharts(
                "/EconWarn/scripts/FusionChartsFree/Charts/MSCombiDY2D.swf",
                "ChartId", "1030", "380");
        chart1.setDataXML(strXML); //这里是从后台拿到的那个字符串
        chart1.render("divtb"); //显示位置
    }


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值