sgworld = window.external.createSgworld(); window.onload = function () { //获取需要查询的参数 var parmType = localStorage.getItem("type"); var type = getUrlParam("Type"); if (type == "All") { //查询当前灾害点 var htmlAll = ""; $.ajax({ url: "../../../Ashx/DataDZZH.ashx", type: "post", data: { Action: "GetDZZH"},//81258c6425be4694af2575731f4e8831 dataType: "json", async: true, success: function (result) { try{ }catch(e){ alert(e); } if (result == null) { $("#container").empty(); $("#container").append("
暂无数据
"); $("#dataTable").empty(); $("#dataTable").append("
暂无数据
"); return false; } var dataX = []; var dataY = []; $.each(result, function (index, value) { var html = ""; if (value.LEIXING == "B") { dataX.push("崩塌"); html = "崩塌"; } else if (value.LEIXING == "H") { dataX.push("滑坡"); html = "滑坡"; } else if (value.LEIXING == "Q") { dataX.push("不稳定点"); html = "不稳定点" } dataY.push(value.NUMBER); htmlAll += "" + html + "" + value.NUMBER + "" }); InitChart(decodeURIComponent(getUrlParam("urlName")), dataX, dataY); $("#dataTable").empty(); $("#dataTable").append("" + htmlAll + "
类型数量
"); } }); } btnClick(); } function InitChart(title, dataX, dataY) { var minY = Math.min.apply(null, dataY); var maxY = Math.max.apply(null, dataY); var dom = document.getElementById("container"); var myChart = echarts.init(dom); var app = {}; option = null; option = { //title: { // text: title, // left: 'center', // textStyle: { // color: '#fff' // } //}, grid: { top: '10%', left: '15%', right: '5%', bottom: '12%' }, backgroundColor: '#000000', color: ["#1A88C8"], tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, xAxis: { type: 'category', data: dataX, axisLine: { lineStyle: { color: '#FFFFFF', } } }, yAxis: { type: 'value', axisLine: { lineStyle: { color: '#FFFFFF', } }, splitLine: { show: false }, max: Math.round(maxY + 50), min: ((Math.round(minY - 50) < 0) ? 0 : Math.round(minY - 50)) }, series: [{ data: dataY, type: 'bar', barMaxWidth: 30, }] };; if (option && typeof option === "object") { myChart.setOption(option, true); } } function btnClick() { $(".chartBtn").click(function () { $("#container").css("display", "block"); $("#dataTable").css("display", "none"); $(".dataBtn").css("color", "#ffffff"); $(".chartBtn").css("color", "aqua"); }); $(".dataBtn").click(function () { $("#container").css("display", "none"); $("#dataTable").css("display", "block"); $(".dataBtn").css("color", "aqua"); $(".chartBtn").css("color", "#ffffff"); }); }