$(document).ready(function() {
	var lineIndex=$("#lineIndex").val();
    lineIndex=filterXSS(lineIndex);
	var startTime=$("#startTime").val();
	var endTime=$("#endTime").val();
	
	if(startTime.length == 0 || endTime.length == 0 ){
		 endTime=getEndTime();
		 startTime=getStartTime("年份", endTime);
	}
	
	getEventDensity(lineIndex,startTime,endTime);
	getEventDisdip(lineIndex,startTime,endTime);
	getIEC411(lineIndex,startTime,endTime);
	getIEC28(lineIndex,startTime,endTime);
});
		
    function getEventDensity(lineIndex,startTime,endTime) {
    	jQuery.ajax({
		type : 'POST',
		dataType : "json",
		data : {
			lineIndex:lineIndex,
			startTime:startTime,
			endTime:endTime
		},
		cache : false,
		url : '/pqs9200/device/eventDensity',
		error : function() {},
		success : function(data) {
			if(data == null){
				layer.msg('加载失败！',{icon:2,time:1000});
			}else{
				var datalist=[]
			    var sydy = ['0-10', '10-20', '20-30', '30-40', '40-50', '50-60', '60-70',
			        '70-80', '80-90', '90-100'];
			    var cysj = ['1cyc', '2cyc', '3cyc',
			        '4cyc', '5cyc', '6~10cyc','10~20cyc','20~30cyc','30~60cyc'];
			    
			    for(var i=0;i<data.length;i++){
			    	xx=data[i].x;
			    	yy=data[i].y;
			    	zz=data[i].z;
			    	datalist[i]=[xx,yy,zz]
			    }
				Harmonic(sydy,cysj,datalist);
			}
		}
	});
    }

var option = null;
function Harmonic(sydy,cysj,datalist){
	 var myChart = echarts.init(document.getElementById('showeventdensity'));
	 
	 option = {
		        tooltip: {
		        	trigger:'axis'
		        },
		        title: {
		            text: '暂降密度图',
		            x: 'center'

		        },
		        toolbox: {
		            show : true,
		            feature : {
			            restore : {
							show : true
						},
		                saveAsImage : {show: true}
		            }
		        },
		        visualMap: {
		            max: 20,
		            show: false,
		            inRange: {
		                color: ['#313695', '#00BB00', '#ff8000', '#a50026']
		            }
		        },
		        xAxis3D: {
		            type: 'category',
		            name: '剩余电压(%)',
		            data: sydy
		        },
		        yAxis3D: {
		            type: 'category',
		            name: '持续时间(cyc)',
		            data: cysj
		        },
		        zAxis3D: {
		        	type: 'value',
		            splitNumber: 10,
		            minInterval: 10,
		            name: '次数'
		        },
		        grid3D: {
		            boxWidth: 200,
		            boxDepth: 100,
		            light: {
		                main: {
		                    intensity: 1.2
		                },
		                ambient: {
		                    intensity: 0.8	
		                }
		            }
		        },
		        series: [{
		            type: 'bar3D',
		            data: datalist.map(function (item) {
		                return {
		                    value: [item[0], item[1], item[2]]
		                }
		            }),
		            shading: 'realistic',

		            label: {
		                show: false,
		                textStyle: {
		                    fontSize: 16,
		                    borderWidth: 1
		                }
		            },

		            itemStyle: {
		                opacity: 1
		            },

		            emphasis: {
		                label: {
		                    textStyle: {
		                        fontSize: 20,
		                        color: '#900'
		                    }
		                },
		                itemStyle: {
		                    color: '#900'
		                }
		            }
		        }]
		    }
	 
	    // 使用刚指定的配置项和数据显示图表
	    myChart.setOption(option);
}

function getEventDisdip(lineIndex,startTime,endTime) {
	jQuery.ajax({
	type : 'POST',
	dataType : "json",
	data : {
		lineIndex:lineIndex,
		startTime:startTime,
		endTime:endTime
	},
	cache : false,
	url : '/pqs9200/device/eventDisdip',
	error : function() {},
	success : function(data) {
		if(data == null){
			layer.msg('加载失败！',{icon:2,time:1000});
		}else{
			document.getElementById("T1D1R1").innerText = data[0][0];document.getElementById("T1D1R2").innerText = data[0][1];document.getElementById("T1D1R3").innerText = data[0][2];
			document.getElementById("T1D1R4").innerText = data[0][3];document.getElementById("T1D1R5").innerText = data[0][4];document.getElementById("T1D1R6").innerText = data[0][5];
			document.getElementById("T1D1R7").innerText = data[0][6];document.getElementById("T1D1R8").innerText = data[0][7];document.getElementById("T1D1R9").innerText = data[0][8];
			
			document.getElementById("T1D2R1").innerText = data[1][0];document.getElementById("T1D2R2").innerText = data[1][1];document.getElementById("T1D2R3").innerText = data[1][2];
			document.getElementById("T1D2R4").innerText = data[1][3];document.getElementById("T1D2R5").innerText = data[1][4];document.getElementById("T1D2R6").innerText = data[1][5];
			document.getElementById("T1D2R7").innerText = data[1][6];document.getElementById("T1D2R8").innerText = data[1][7];document.getElementById("T1D2R9").innerText = data[1][8];
			
			document.getElementById("T1D3R1").innerText = data[2][0];document.getElementById("T1D3R2").innerText = data[2][1];document.getElementById("T1D3R3").innerText = data[2][2];
			document.getElementById("T1D3R4").innerText = data[2][3];document.getElementById("T1D3R5").innerText = data[2][4];document.getElementById("T1D3R6").innerText = data[2][5];
			document.getElementById("T1D3R7").innerText = data[2][6];document.getElementById("T1D3R8").innerText = data[2][7];document.getElementById("T1D3R9").innerText = data[2][8];
			
			document.getElementById("T1D4R1").innerText = data[3][0];document.getElementById("T1D4R2").innerText = data[3][1];document.getElementById("T1D4R3").innerText = data[3][2];
			document.getElementById("T1D4R4").innerText = data[3][3];document.getElementById("T1D4R5").innerText = data[3][4];document.getElementById("T1D4R6").innerText = data[3][5];
			document.getElementById("T1D4R7").innerText = data[3][6];document.getElementById("T1D4R8").innerText = data[3][7];document.getElementById("T1D4R9").innerText = data[3][8];
			
			document.getElementById("T1D5R1").innerText = data[4][0];document.getElementById("T1D5R2").innerText = data[4][1];document.getElementById("T1D5R3").innerText = data[4][2];
			document.getElementById("T1D5R4").innerText = data[4][3];document.getElementById("T1D5R5").innerText = data[4][4];document.getElementById("T1D5R6").innerText = data[4][5];
			document.getElementById("T1D5R7").innerText = data[4][6];document.getElementById("T1D5R8").innerText = data[4][7];document.getElementById("T1D5R9").innerText = data[4][8];
		}
	}
	});
}

function getIEC411(lineIndex,startTime,endTime) {
	jQuery.ajax({
	type : 'POST',
	dataType : "json",
	data : {
		lineIndex:lineIndex,
		startTime:startTime,
		endTime:endTime
	},
	cache : false,
	url : '/pqs9200/device/IEC411',
	error : function() {},
	success : function(data) {
		if(data == null){
			layer.msg('加载失败！',{icon:2,time:1000});
		}else{
			document.getElementById("T2D1R1").innerText = data[0][0];document.getElementById("T2D1R2").innerText = data[0][1];document.getElementById("T2D1R3").innerText = data[0][2];
			document.getElementById("T2D1R4").innerText = data[0][3];document.getElementById("T2D1R5").innerText = data[0][4];document.getElementById("T2D1R6").innerText = data[0][5];
			document.getElementById("T2D1R7").innerText = data[0][6];
			
			document.getElementById("T2D2R1").innerText = data[1][0];document.getElementById("T2D2R2").innerText = data[1][1];document.getElementById("T2D2R3").innerText = data[1][2];
			document.getElementById("T2D2R4").innerText = data[1][3];document.getElementById("T2D2R5").innerText = data[1][4];document.getElementById("T2D2R6").innerText = data[1][5];
			document.getElementById("T2D2R7").innerText = data[1][6];
			
			document.getElementById("T2D3R1").innerText = data[2][0];document.getElementById("T2D3R2").innerText = data[2][1];document.getElementById("T2D3R3").innerText = data[2][2];
			document.getElementById("T2D3R4").innerText = data[2][3];document.getElementById("T2D3R5").innerText = data[2][4];document.getElementById("T2D3R6").innerText = data[2][5];
			document.getElementById("T2D3R7").innerText = data[2][6];
		}
	}
	});
}

function getIEC28(lineIndex,startTime,endTime) {
	jQuery.ajax({
	type : 'POST',
	dataType : "json",
	data : {
		lineIndex:lineIndex,
		startTime:startTime,
		endTime:endTime
	},
	cache : false,
	url : '/pqs9200/device/IEC28',
	error : function() {},
	success : function(data) {
		if(data == null){
			layer.msg('加载失败！',{icon:2,time:1000});
		}else{
			document.getElementById("T3D1R1").innerText = data[0][0];document.getElementById("T3D1R2").innerText = data[0][1];document.getElementById("T3D1R3").innerText = data[0][2];
			document.getElementById("T3D1R4").innerText = data[0][3];document.getElementById("T3D1R5").innerText = data[0][4];document.getElementById("T3D1R6").innerText = data[0][5];
			document.getElementById("T3D1R7").innerText = data[0][6];document.getElementById("T3D1R8").innerText = data[0][7];document.getElementById("T3D1R9").innerText = data[0][8];
			
			document.getElementById("T3D2R1").innerText = data[1][0];document.getElementById("T3D2R2").innerText = data[1][1];document.getElementById("T3D2R3").innerText = data[1][2];
			document.getElementById("T3D2R4").innerText = data[1][3];document.getElementById("T3D2R5").innerText = data[1][4];document.getElementById("T3D2R6").innerText = data[1][5];
			document.getElementById("T3D2R7").innerText = data[1][6];document.getElementById("T3D2R8").innerText = data[1][7];document.getElementById("T3D2R9").innerText = data[1][8];
			
			document.getElementById("T3D3R1").innerText = data[2][0];document.getElementById("T3D3R2").innerText = data[2][1];document.getElementById("T3D3R3").innerText = data[2][2];
			document.getElementById("T3D3R4").innerText = data[2][3];document.getElementById("T3D3R5").innerText = data[2][4];document.getElementById("T3D3R6").innerText = data[2][5];
			document.getElementById("T3D3R7").innerText = data[2][6];document.getElementById("T3D3R8").innerText = data[2][7];document.getElementById("T3D3R9").innerText = data[2][8];
			
			document.getElementById("T3D4R1").innerText = data[3][0];document.getElementById("T3D4R2").innerText = data[3][1];document.getElementById("T3D4R3").innerText = data[3][2];
			document.getElementById("T3D4R4").innerText = data[3][3];document.getElementById("T3D4R5").innerText = data[3][4];document.getElementById("T3D4R6").innerText = data[3][5];
			document.getElementById("T3D4R7").innerText = data[3][6];document.getElementById("T3D4R8").innerText = data[3][7];document.getElementById("T3D4R9").innerText = data[3][8];
			
			document.getElementById("T3D5R1").innerText = data[4][0];document.getElementById("T3D5R2").innerText = data[4][1];document.getElementById("T3D5R3").innerText = data[4][2];
			document.getElementById("T3D5R4").innerText = data[4][3];document.getElementById("T3D5R5").innerText = data[4][4];document.getElementById("T3D5R6").innerText = data[4][5];
			document.getElementById("T3D5R7").innerText = data[4][6];document.getElementById("T3D5R8").innerText = data[4][7];document.getElementById("T3D5R9").innerText = data[4][8];
	
			document.getElementById("T3D6R1").innerText = data[5][0];document.getElementById("T3D6R2").innerText = data[5][1];document.getElementById("T3D6R3").innerText = data[5][2];
			document.getElementById("T3D6R4").innerText = data[5][3];document.getElementById("T3D6R5").innerText = data[5][4];document.getElementById("T3D6R6").innerText = data[5][5];
			document.getElementById("T3D6R7").innerText = data[5][6];document.getElementById("T3D6R8").innerText = data[5][7];document.getElementById("T3D6R9").innerText = data[5][8];
	
			document.getElementById("T3D7R1").innerText = data[6][0];document.getElementById("T3D7R2").innerText = data[6][1];document.getElementById("T3D7R3").innerText = data[6][2];
			document.getElementById("T3D7R4").innerText = data[6][3];document.getElementById("T3D7R5").innerText = data[6][4];document.getElementById("T3D7R6").innerText = data[6][5];
			document.getElementById("T3D7R7").innerText = data[6][6];document.getElementById("T3D7R8").innerText = data[6][7];document.getElementById("T3D7R9").innerText = data[6][8];
	
			document.getElementById("T3D8R1").innerText = data[7][0];document.getElementById("T3D8R2").innerText = data[7][1];document.getElementById("T3D8R3").innerText = data[7][2];
			document.getElementById("T3D8R4").innerText = data[7][3];document.getElementById("T3D8R5").innerText = data[7][4];document.getElementById("T3D8R6").innerText = data[7][5];
			document.getElementById("T3D8R7").innerText = data[7][6];document.getElementById("T3D8R8").innerText = data[7][7];document.getElementById("T3D8R9").innerText = data[7][8];
	
			document.getElementById("T3D9R1").innerText = data[8][0];document.getElementById("T3D9R2").innerText = data[8][1];document.getElementById("T3D9R3").innerText = data[8][2];
			document.getElementById("T3D9R4").innerText = data[8][3];document.getElementById("T3D9R5").innerText = data[8][4];document.getElementById("T3D9R6").innerText = data[8][5];
			document.getElementById("T3D9R7").innerText = data[8][6];document.getElementById("T3D9R8").innerText = data[8][7];document.getElementById("T3D9R9").innerText = data[8][8];

			document.getElementById("T3D10R1").innerText = data[9][0];document.getElementById("T3D10R2").innerText = data[9][1];document.getElementById("T3D10R3").innerText = data[9][2];
			document.getElementById("T3D10R4").innerText = data[9][3];document.getElementById("T3D10R5").innerText = data[9][4];document.getElementById("T3D10R6").innerText = data[9][5];
			document.getElementById("T3D10R7").innerText = data[9][6];document.getElementById("T3D10R8").innerText = data[9][7];document.getElementById("T3D10R9").innerText = data[9][8];

			document.getElementById("T3D11R1").innerText = data[10][0];document.getElementById("T3D11R2").innerText = data[10][1];document.getElementById("T3D11R3").innerText = data[10][2];
			document.getElementById("T3D11R4").innerText = data[10][3];document.getElementById("T3D11R5").innerText = data[10][4];document.getElementById("T3D11R6").innerText = data[10][5];
			document.getElementById("T3D11R7").innerText = data[10][6];document.getElementById("T3D11R8").innerText = data[10][7];document.getElementById("T3D11R9").innerText = data[10][8];

			document.getElementById("T3D12R1").innerText = data[11][0];document.getElementById("T3D12R2").innerText = data[11][1];document.getElementById("T3D12R3").innerText = data[11][2];
			document.getElementById("T3D12R4").innerText = data[11][3];document.getElementById("T3D12R5").innerText = data[11][4];document.getElementById("T3D12R6").innerText = data[11][5];
			document.getElementById("T3D12R7").innerText = data[11][6];document.getElementById("T3D12R8").innerText = data[11][7];document.getElementById("T3D12R9").innerText = data[11][8];

			document.getElementById("T3D13R1").innerText = data[12][0];document.getElementById("T3D13R2").innerText = data[12][1];document.getElementById("T3D13R3").innerText = data[12][2];
			document.getElementById("T3D13R4").innerText = data[12][3];document.getElementById("T3D13R5").innerText = data[12][4];document.getElementById("T3D13R6").innerText = data[12][5];
			document.getElementById("T3D13R7").innerText = data[12][6];document.getElementById("T3D13R8").innerText = data[12][7];document.getElementById("T3D13R9").innerText = data[12][8];

			document.getElementById("T3D14R1").innerText = data[13][0];document.getElementById("T3D14R2").innerText = data[13][1];document.getElementById("T3D14R3").innerText = data[13][2];
			document.getElementById("T3D14R4").innerText = data[13][3];document.getElementById("T3D14R5").innerText = data[13][4];document.getElementById("T3D14R6").innerText = data[13][5];
			document.getElementById("T3D14R7").innerText = data[13][6];document.getElementById("T3D14R8").innerText = data[13][7];document.getElementById("T3D14R9").innerText = data[13][8];

			document.getElementById("T3D15R1").innerText = data[14][0];document.getElementById("T3D15R2").innerText = data[14][1];document.getElementById("T3D15R3").innerText = data[14][2];
			document.getElementById("T3D15R4").innerText = data[14][3];document.getElementById("T3D15R5").innerText = data[14][4];document.getElementById("T3D15R6").innerText = data[14][5];
			document.getElementById("T3D15R7").innerText = data[14][6];document.getElementById("T3D15R8").innerText = data[14][7];document.getElementById("T3D15R9").innerText = data[14][8];

			document.getElementById("T3D16R1").innerText = data[15][0];document.getElementById("T3D16R2").innerText = data[15][1];document.getElementById("T3D16R3").innerText = data[15][2];
			document.getElementById("T3D16R4").innerText = data[15][3];document.getElementById("T3D16R5").innerText = data[15][4];document.getElementById("T3D16R6").innerText = data[15][5];
			document.getElementById("T3D16R7").innerText = data[15][6];document.getElementById("T3D16R8").innerText = data[15][7];document.getElementById("T3D16R9").innerText = data[15][8];

			document.getElementById("T3D17R1").innerText = data[16][0];document.getElementById("T3D17R2").innerText = data[16][1];document.getElementById("T3D17R3").innerText = data[16][2];
			document.getElementById("T3D17R4").innerText = data[16][3];document.getElementById("T3D17R5").innerText = data[16][4];document.getElementById("T3D17R6").innerText = data[16][5];
			document.getElementById("T3D17R7").innerText = data[16][6];document.getElementById("T3D17R8").innerText = data[16][7];document.getElementById("T3D17R9").innerText = data[16][8];
		}
	}
	});
}