b)在b"> b)在b" />
ID:34722780
大小:85.68 KB
页数:8页
时间:2019-03-10
2、置echarts的路径,从当前页面链接到echarts.js,定义所需图标路径require.config({paths:{'echarts':'js/echarts','echarts/chart/pies':'js/echarts'}});2>动态加载echarts然后再回调函数中开始使用,注意保持按需加载结构定义图表路径require(['echarts','echarts/chart/pie'//使用类似方法加载pie],function(ec){varmyChart=ec.init(document.getElementById('chartAr
3、ea'));varoption={…………calculable:true,series:[{name:'访问来源',type:'pie',radius:'55%',center:['50%',225],data:[{value:a,name:'已婚'},{value:b,name:'未婚'},]}]};myChart.setOption(option);});3>使用动态数据,因为是在head
4、为void无返回方法,所以要将dao查询到的数据用字符串连接起来,然后out.println();out.flush();publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{Stringresult="";StatisticsDaodao=newStatisticsDao();try{Stringmarraige1=dao.count1();result=marraige1+","+marraige2
5、;}catch(Exceptione){e.printStackTrace();}PrintWriterout=response.getWriter();out.println(result);out.flush();out.close();}ii).ajax获取值$.get()得到的是字符串,所以要用data.indexOf(",")方法将字符串分割得到数据。$(function(){$.get("test1",function(data){if(data!=""){varm=data.indexOf(",");a=parseInt(data.subst
6、ring(0,m));b=parseInt(data.substring(m+1));});另外,画图函数要写在ajax方法里面。运行的时候会优先绘制图形,导致ajax数据没有读到。下面附完整jsp页面代码:<%@pagelanguage="java"import="java.util.*,bean.StatisticsDao"pageEncoding="utf-8"%><%Stringpath=request.getContextPath();StringbasePath=request.getScheme()+"://"+request.getServ
7、erName()+":"+request.getServerPort()+path+"/";%> 8、ref="style.css"media="all"/>
此文档下载收益归作者所有