<script> /** * 调用本地的ashx * @file 文件名 * @param get参数 (a=1&b=2&c=3) * @fn 回调函数 : 服务端返回 result=xxx; 回调函数直接处理result变量。 */ $.ashx = function (file, param, fn, er) { var sUrl = file; $.ajax({ type: "GET", contentType: "application/json", cache: false, url: sUrl, data: param, dataType: "json", success: fn, error: er }); }; var globalIndex = 0; //地图点击时间 function redoMethod(deptname) { if (!deptname) { deptname = data[globalIndex].name; globalIndex++; if (globalIndex == data.length) { globalIndex = 0; } } //alert(name); $.ashx("ajax的url地址", "action=xx&deptname=" + deptname, function (result) { if (result) { if (result.results == "") { return; } //debugger; //alert(result.results.politcal); var option = myChart.getOption(); //动态改变图形 option.series[0].data = convertData(data);//地图 option.series[0].symbolSize = function (val, params) {//标记的大小 //alert(name.name); if (deptname == params.name) { return 35;//地图闪动 } else { return 20; } }; option.series[0].itemStyle.color = function (params) { if (deptname == params.name) { return "rgba(245, 214, 251, 1)"; } else { return "#F4E925"; } }; option.series[1].data = result.results[0].politcal;//政治面貌 option.series[2].data = result.results[1].ageScale;//年龄占比 option.series[3].itemStyle.color = function (params) { if (deptname == params.name) { return "rgba(245, 214, 251, 1)"; } else { var colorList = ['#c23531', '#2f4554', '#61a0a8', '#d48265', '#91c7ae', '#749f83', '#ca8622', '#bda29a', '#6e7074', '#546570', '#c4ccd3']; return colorList[params.dataIndex]; } } option.series[4].data = [2, 7, 12, 6, 4, 6, 6, 3];//请假 option.series[5].data = [11, 5, 21, 3, 5, 10, 8, 5];//迟到 option.series[6].data = [6, 1, 11, 1, 7, 4, 3, 13];//早退 option.series[7].data = [7, 2, 22, 14, 4, 4, 6, 9];//调休 option.series[8].data = [20, 7, 23, 11, 8, 4, 4, 7];//加班 option.series[9].data = [33, 4, 24, 9, 6, 4, 1, 1];//旷工 myChart.setOption(option); } }, function (er) { //alert("请求失败"); }); } $(function () { //定时循环 var interval = setInterval("redoMethod()", 5000);//每隔一秒执行一次redoMethod() //假如有两个按钮:继续、暂停 $("#btnSet").click(function () {//点击暂停按钮 if (interval) { clearInterval(interval); interval = null; } if ($(this).attr("title") == "点击停止") { $(this).attr("title", "点击开始"); $(this).attr("class", "btnPlay"); } else { $(this).attr("title", "点击停止"); $(this).attr("class", "btnPause"); interval = setInterval("redoMethod()", 5000); } }); }); </script>
6. 总结