window.onload = function () {
|
GetDataBingChuan();
|
btnClick();
|
}
|
|
function GetDataBingChuan() {
|
;
|
var type = "All"; //getUrlParam("Type");
|
if (type == "All") {
|
$.ajax({
|
url: "../../../Ashx/Firstcommon.ashx",
|
type: "post",
|
data: { Action: "GetAllSumData", tableName: "STBC" },//81258c6425be4694af2575731f4e8831
|
dataType: "json",
|
async: true,
|
success: function (result) {
|
if (result == null) {
|
$("#container").empty();
|
$("#container").append("<table><tr><td>暂无数据</td></tr></table>");
|
$("#dataTable").empty();
|
$("#dataTable").append("<table><tr><td>暂无数据</td></tr></table>");
|
|
return false;
|
}
|
var firstHtml = "";
|
var secondHtml = "";
|
var dataX = [];
|
var dataY = [];
|
$.each(result, function (index, value) {
|
firstHtml += "<td>" + value.time + "</td>";
|
secondHtml += "<td>" + value.simName + "</td><td>" + value.lakeArea + "</td>";
|
dataX.push(value.time);
|
dataY.push(value.lakeArea);
|
});
|
InitChart("冰川面积", dataX, dataY);
|
$("#dataTable").empty();
|
$("#dataTable").append("<table><tr><td>名称/时间</td>" + firstHtml + "</tr>" + "<tr>" + secondHtml + "</tr></table>");
|
}
|
});
|
} else if (type == "choose") {
|
var objParm = localStorage.getItem("openShp");
|
//alert(objParm);
|
$.ajax({
|
url: "../../../Ashx/Firstcommon.ashx",
|
type: "post",
|
data: { Action: "GetAllChooseData", pathName: objParm, tableName: "STBC" },//81258c6425be4694af2575731f4e8831
|
dataType: "json",
|
async: true,
|
success: function (result) {
|
if (result == null) {
|
$("#container").empty();
|
$("#container").append("<table><tr><td>暂无数据</td></tr></table>");
|
$("#dataTable").empty();
|
$("#dataTable").append("<table><tr><td>暂无数据</td></tr></table>");
|
|
return false;
|
}
|
var html = "";
|
var dataX = [];
|
var dataY = [];
|
$.each(result, function (index, value) {
|
html += "<tr><td>" + value.Year + "</td><td>" + value.Area + "</td></tr>"
|
dataX.push(value.Year);
|
dataY.push(value.Area);
|
});
|
InitChart("冰川面积", dataX, dataY);
|
$("#dataTable").empty();
|
$("#dataTable").append("<table>" + html + "</table>");
|
}
|
});
|
}
|
|
|
|
}
|
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: '10%',
|
right: '5%',
|
bottom: '8%'
|
},
|
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',
|
barWidth: 50,
|
|
}]
|
};;
|
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");
|
});
|
}
|