echarts java怎样传入数据
答案:1 悬赏:70 手机版
解决时间 2021-02-20 02:52
- 提问者网友:你挡着我发光了
- 2021-02-19 13:17
echarts java怎样传入数据
最佳答案
- 五星知识达人网友:西岸风
- 2021-02-19 14:48
function init_chart (data_list) {<br>// 基于准备好的dom,初始化echarts实例<br>var myChart = echarts.init(document.getElementById('echarts-main'));<br>var camera_names=[];<br>var data2=[];<br>var data3=[];<br>var data_all=[];<br>for ( var i = 0; i < data_list.length; i++) {<br>var o=data_list[i];<br>var camera_name="";<br>if(get_camera(o.camera_repository_id))<br>{<br>camera_name=get_camera(o.camera_repository_id).name<br>}<br>camera_names.push(camera_name)<br>data2.push(o.count_type2);<br>data3.push(o.count_type3);<br>data_all.push(o.count_type2+o.count_type3);<br>}<br>//camera_names=camera_names.reverse();<br>//data2=data2.reverse();<br>//data3=data3.reverse();<br>//data_all=data_all.reverse();<br>// 指定图表的配置项和数据<br>option = {<br> title: {<br> //text: '报警分析'<br> },<br> tooltip: {<br> trigger: 'axis',<br> axisPointer: {<br> type: 'shadow'<br> }<br> },<br> legend: {<br> data: ['白名单', '黑名单','全部']<br> },<br> grid: {<br> left: '3%',<br> right: '4%',<br> bottom: '3%',<br> containLabel: true<br> },<br> xAxis: {<br> type: 'category',<br> data: camera_names<br><br> },<br> yAxis: {<br> type: 'value',<br><br> boundaryGap: [0, 0.01]<br> },<br> series: [<br> {<br> name: '白名单',<br> type: 'bar',<br> data: data2<br> },<br> {<br> name: '黑名单',<br> type: 'bar',<br> data: data3<br> },<br> {<br> name: '全部',<br> type: 'bar',<br> data: data_all<br> }<br> ]<br>};<br>// 使用刚指定的配置项和数据显示图表。<br>myChart.setOption(option);<br>}<br><br><br><br><br><br>function getList() {<br>var cancel_timestamp1 = $('#datetimepicker1').data("date");<br>var cancel_timestamp2 = $('#datetimepicker2').data("date");<br>if (cancel_timestamp1)<br>cancel_timestamp1 = moment(cancel_timestamp1).unix();<br>if (cancel_timestamp2)<br>cancel_timestamp2 = moment(cancel_timestamp2).unix();<br>if(cancel_timestamp1=="")<br>cancel_timestamp1="0"<br>if(cancel_timestamp2=="")<br>cancel_timestamp2="9999999999"<br>$.ajax( {<br>url : 'rxt.servlet.alarm_analysis',<br>data : {<br>cancel_timestamp1 : cancel_timestamp1,<br>cancel_timestamp2 : cancel_timestamp2,<br>operat : "getList"<br>},<br>type : 'post',<br>cache : false,<br>dataType : 'json',<br>success : function(data) {<br>if (data.rtn == 0) {<br>// alert(data.list);<br>var table = $("#main tbody");<br>table.html('');<br>for ( var i = 0; i < data.list.length; i++) {<br>var o = data.list[i];<br>var camera_name="";<br>if(get_camera(o.camera_repository_id))<br>{<br>camera_name=get_camera(o.camera_repository_id).name<br>}<br>table.append('<tr><td>' +camera_name + '</td><td>'<br>+ o.count_type2 + '</td><td>' + o.count_type3<br>+ '</td><td>'+(o.count_type3+o.count_type2)+'</td></tr>');<br>}<br>init_chart(data.list);<br>} else {<br>alert(data.msg);<br>}<br>},<br>error : function() {<br>alert("网络异常!");<br>}<br>});<br>}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯