<script type="text/javascript"> var xmlhttp; function startrefresh(){ xmlhttp=new XMLHttpRequest(); xmlhttp.open(POST,"/Sentiment/Sentiment.jsp",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); //xmlhttp.send("name=wk"); --需要传输参数时增加 xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState == 4) if(xmlhttp.status == 200) document.getElementById("main1").innerHTML=xmlhttp.responseText; } } </script> @H_403_1@
<div id="main1" style="height:350px;">武开英</div>@H_403_1@以下是echarts代码
<script type="text/javascript"> var array_name = "<%=st_name.toString()%>"; var array_value ="<%=st_good.toString()%>"; // 路径配置 require.config({ paths:{ 'echarts' : './js/echarts','echarts/chart/bar' : './js/echarts','echarts/chart/line': './js/echarts','echarts/chart/pie': './js/echarts' } }); // 使用 require( [ 'echarts','echarts/chart/bar',// 使用柱状图就加载bar模块,按需加载 'echarts/chart/line','echarts/chart/pie' ],DrawCharts ); function DrawCharts(ec) { FunDraw3(ec); } function FunDraw3(ec) { // 基于准备好的dom,初始化echarts图表 var myChart = ec.init(document.getElementById('main1')); var option = { title : { text: '',subtext: '',x:'center' },tooltip : { trigger: 'item',formatter: "{a} <br/>{b} : {c} ({d}%)" },legend: { orient : 'vertical',x : 'left',data:["正面","负面","中立"],//这个一定要自己输入,学会调适程序 },toolBox: { show : true,feature : { mark : {show: true},dataView : {show: true,readOnly: false},restore : {show: true},saveAsImage : {show: true} } },calculable : true,series : [ { name:'访问来源',type:'pie',radius : '100%',center: ['50%','60%'],data:(function(){ var res = []; var len = -1; while (len++<10) { res.push({ name: array_name.split(",")[len],value:array_value.split(",")[len] }); } return res; })() } ] }; myChart.setOption(option); } </script>@H_403_1@这样可以部分刷新饼图。 原文链接:https://www.f2er.com/ajax/163947.html