问题描述
需求描述:想通过UpdatePanel实现FusionCharts的无刷新报表数据展示。通过ltChart2接收显示脚本,chartdiv2显示报表。当选择选项一或选项二或者其它的时候,想动态从cs重新读取数据拼接成脚本,显示到chartdiv2上,可脚本就是第一次执行,后面修改选择框的时候就是不变,请大神帮忙看下!代码:Page<divid="chartdiv2"></div><asp:LiteralID="ltChart2"runat="server"></asp:Literal><divstyle="width:120px;float:left;padding-top:18px;padding-left:20px;line-height:150%;"><asp:CheckBoxID="ckb1"Checked="true"runat="server"Text="选项一"AutoPostBack="True"OnCheckedChanged="ckb2_CheckedChanged"/><asp:CheckBoxID="ckb2"Checked="true"runat="server"Text="选项二"AutoPostBack="True"OnCheckedChanged="ckb2_CheckedChanged"/><asp:CheckBoxID="ckb3"runat="server"Text="其它"AutoPostBack="True"OnCheckedChanged="ckb2_CheckedChanged"/></div>
protectedvoidckb1_CheckedChanged(objectsender,EventArgse){DataSetds=jjm.RunProcedure_MrDp("sp_Mrer_1","2016-03-21",7);DataTabledt=ds.Tables[0];StringBuilderztqk_2=newStringBuilder();ztqk_2.Append("functionshowChart2(){n");ztqk_2.Append("varchart=newFusionCharts("/FusionCharts/FCF_MSLine.swf","ChartId","600","350");n");ztqk_2.Append("chart.setTransparent(true);n");ztqk_2.Append("chart.setDataXML("<?xmlversion='1.0'encoding='GB2312'?>");ztqk_2.Append("<graphcaption=''subcaption=''xAxisName=''yAxisName=''decimalPrecision='0'formatNumberScale='0'numberPrefix=''showNames='1'rotateNames='0'showValues='1'showAlternateHGridColor='1'AlternateHGridColor='ff5904'divLineColor='ff5904'divLineAlpha='20'alternateHGridAlpha='5'baseFontSize='12'baseFont='宋体'bgAlpha='0'>");ztqk_2.Append("<categories>");StringBuilderlx0=newStringBuilder(),lx1=newStringBuilder(),lx2=newStringBuilder(),lx3=newStringBuilder();for(inti=0;i<dt.Rows.Count-1;i++){DataRowdr=dt.Rows[i];ztqk_2.Append("<categoryname='"+dt.Rows[i][0]+"'/>");if(ckb1.Checked)lx1.Append("<setvalue='"+dr[1]+"'/>");if(ckb2.Checked)lx2.Append("<setvalue='"+dr[2]+"'/>");if(ckb3.Checked)lx3.Append("<setvalue='"+dr[3]+"'/>");}ztqk_2.Append("</categories>");if(ckb1.Checked){ztqk_2.Append("<datasetseriesName='选项一'color='008000'anchorBorderColor='008000'anchorSides='20'anchorRadius='3'anchorBorderThickness='1'anchorBgColor='ffffff'>");ztqk_2.Append(lx1);ztqk_2.Append("</dataset>");}if(ckb2.Checked){ztqk_2.Append("<datasetseriesName='选项二'color='0000FF'anchorBorderColor='0000FF'anchorSides='20'anchorRadius='3'anchorBorderThickness='1'anchorBgColor='ffffff'>");ztqk_2.Append(lx2);ztqk_2.Append("</dataset>");}if(ckb3.Checked){ztqk_2.Append("<datasetseriesName='其它'color='FF0000'anchorBorderColor='FF0000'anchorSides='20'anchorRadius='3'anchorBorderThickness='1'anchorBgColor='ffffff'>");ztqk_2.Append(lx3);ztqk_2.Append("</dataset>");}ztqk_2.Append("</graph>");n");ztqk_2.Append("chart.render("chartdiv2");n");ztqk_2.Append("}n");ltChart2.Text="<scripttype="text/javascript">n"+ztqk_2+"showChart2();n</script>n";}
解决方案
解决方案二:
昨天赶在下班的时候发帖,活该没大牛回复,顶一下让看见