368 lines
11 KiB
Plaintext
368 lines
11 KiB
Plaintext
<%@ page contentType="text/html;charset=UTF-8"%>
|
|
<%@ include file="/WEB-INF/include/taglib.jsp"%>
|
|
<html>
|
|
<head>
|
|
<title>
|
|
|
|
</title>
|
|
</head>
|
|
|
|
<body >
|
|
|
|
<div class="page-content">
|
|
<div class="theme-panel hidden-xs hidden-sm">
|
|
</div>
|
|
<div class="row" >
|
|
<form:form id="searchForm" action="${ctx}/dashboard/traffic/" method="get" class="form-search">
|
|
<input id="beginDate" type="hidden" value="${beginDate}"/>
|
|
<input id="endDate" type="hidden" value="${endDate}"/>
|
|
<input id="protocolId" type="hidden" value="${protocolId}"/>
|
|
<input id="protocolType" type="hidden" value="${protocolType}"/>
|
|
<input id="timeSize" type="hidden" value="${timeSize}"/>
|
|
<%-- <input id="chartType_1" type="hidden" value="${chartType_1}"/> --%>
|
|
<input id="area" type="hidden" value="${area}"/>
|
|
<input id="operator" type="hidden" value="${operator}"/>
|
|
<input id="dimension" type="hidden" value="${dimension}"/>
|
|
<input id="total" type="hidden"/>
|
|
<div class="pull-left" style="padding-top: 6px;padding-left: 10px;">
|
|
<div class="input-group">
|
|
<div class="input-group-btn">
|
|
<span class="selectpicker form-control" ><spring:message code="chart_type"/></span>
|
|
</div>
|
|
<select id="chartType" class="selectpicker select2 input-small">
|
|
<option value ="line" selected><spring:message code="line_chart"/></option>
|
|
<option value ="bar"><spring:message code="bar_chart"/></option>
|
|
<option value ="pie"><spring:message code="pie_chart"/></option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</form:form>
|
|
</div>
|
|
<div id="chart" style="width:95%;height:500px;"></div>
|
|
|
|
</div>
|
|
<script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/highcharts.js"></script>
|
|
<script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/exporting.js"></script>
|
|
<script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/series-label.js"></script>
|
|
<script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/offline-exporting.js"></script>
|
|
<%-- <script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/themes/grid.js"></script> --%>
|
|
<script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/exporting-data.js"></script>
|
|
<script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/no-data-to-display.js"></script>
|
|
<script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/standalone.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){
|
|
//给图表类型下拉框设置默认值
|
|
// $("#chartType option[value='"+ $("#chartType_1").val()+"'] ").attr("selected",true);
|
|
// $("#chartType").val($("#chartType_1").val());
|
|
protocolsTrans();
|
|
$("#chartType").on("change",function(){
|
|
protocolsTrans();
|
|
});
|
|
|
|
});
|
|
//
|
|
function protocolsTrans(){
|
|
loading();
|
|
var beginDate=$("#beginDate").val();
|
|
var endDate=$("#endDate").val();
|
|
var protocolId=$("#protocolId").val();
|
|
var protocolType=$("#protocolType").val();
|
|
var timeSize=$("#timeSize").val();
|
|
var chartType = $("#chartType").val();
|
|
var area = $("#area").val();
|
|
if(area =="astana"){
|
|
area="1";
|
|
}else if(area =="almaty"){
|
|
area="2";
|
|
}else{
|
|
area="";
|
|
}
|
|
var dimension = $("#dimension").val();
|
|
var operator = $("#operator").val();
|
|
if(operator == "null" || operator == ""){
|
|
operator = "";
|
|
}
|
|
$.ajax({
|
|
url: '${ctx}/dashboard/traffic/ajaxProtocolsStatistic',
|
|
type : "get" ,
|
|
dataType:"json",
|
|
data:{"beginDate":beginDate,"endDate":endDate,"operator":operator,"timeSize":timeSize,"protocolId":protocolId,"protocolType":protocolType,"area":area,"dimension":dimension},
|
|
async:true,
|
|
timeout:50000,
|
|
success:function (rs) {
|
|
$("#tbodyData").html("");
|
|
var xData=new Array();
|
|
var series=new Array();
|
|
var total = 0;
|
|
if(rs!=null&&rs.length>0){
|
|
total=rs[0].sum;
|
|
series.push({
|
|
name: dimension,
|
|
data: rs[0].result,
|
|
marker: {
|
|
enabled: false
|
|
}
|
|
});
|
|
}else{
|
|
series.push({
|
|
name: ' ',
|
|
data: []
|
|
});
|
|
}
|
|
$("#total").val(JSON.stringify(total));
|
|
showProtocolsTrans(chartType,xData,series);
|
|
closeTip();
|
|
},
|
|
error: function(data, textStatus, errorThrown){
|
|
closeTip();
|
|
},
|
|
complete:function(XMLHttpRequest,status){//超时设置
|
|
closeTip();
|
|
}
|
|
});
|
|
|
|
}
|
|
function showProtocolsTrans(chartType,xData,series){
|
|
var nowDate=new Date();
|
|
var protocols=$("#protocolType").val();
|
|
if(protocols == undefined || protocols == null || protocols == "undefined"){
|
|
protocols="";
|
|
}
|
|
Highcharts.setOptions({ global: { useUTC: false } });
|
|
var chart = {
|
|
chart:{
|
|
type: 'area',
|
|
zoomType: 'x'
|
|
},
|
|
exporting: {
|
|
filename:'<spring:message code="protocol_type"/>'+nowDate.getFullYear()+(nowDate.getMonth()+1)+nowDate.getDate()+nowDate.getHours()+nowDate.getMinutes()+nowDate.getSeconds(),
|
|
scale:1,
|
|
sourceWidth: 1280,
|
|
sourceHeight: 500,
|
|
buttons: {
|
|
contextButton: {
|
|
menuItems: [
|
|
Highcharts.getOptions().exporting.buttons.contextButton.menuItems[0],// 打印
|
|
Highcharts.getOptions().exporting.buttons.contextButton.menuItems[1],// jpeg
|
|
'downloadPNG','downloadPDF',
|
|
Highcharts.getOptions().exporting.buttons.contextButton.menuItems[4],// excel
|
|
Highcharts.getOptions().exporting.buttons.contextButton.menuItems[3],// cvs
|
|
]
|
|
}
|
|
}
|
|
},
|
|
noData:{
|
|
style: {//设置字体颜色
|
|
color: '#413333',
|
|
fontFamily:'Microsoft YaHei',
|
|
fontWeight:"unset",
|
|
},
|
|
},
|
|
title: {
|
|
text: protocols
|
|
},
|
|
xAxis: {
|
|
type:'datetime',
|
|
dateTimeLabelFormats: {
|
|
second: '%H:%M:%S',
|
|
minute: '%H:%M',
|
|
hour: '%H:%M',
|
|
day: '%m-%d',
|
|
week: '%m-%d',
|
|
month: '%Y-%m',
|
|
year: '%Y'
|
|
},
|
|
title: {
|
|
text: 'time',
|
|
align:'high',
|
|
},
|
|
|
|
},
|
|
yAxis: {
|
|
title: {
|
|
text: ''
|
|
}
|
|
},
|
|
credits:{//是否有highcharts水印
|
|
enabled:false
|
|
},
|
|
legend: {
|
|
enabled:false
|
|
},
|
|
tooltip: {
|
|
dateTimeLabelFormats: {
|
|
millisecond: '%Y-%m-%d %H:%M:%S',
|
|
second: '%Y-%m-%d %H:%M:%S',
|
|
minute: '%Y-%m-%d %H:%M:%S',
|
|
hour: '%Y-%m-%d %H:%M:%S',
|
|
day: '%Y-%m-%d %H:%M:%S',
|
|
week: '%Y-%m-%d %H:%M:%S',
|
|
month: '%Y-%m-%d %H:%M:%S',
|
|
year: '%Y-%m-%d %H:%M:%S'
|
|
}
|
|
},
|
|
plotOptions: {
|
|
series: {
|
|
lineWidth:1,
|
|
marker: {
|
|
radius: 2,
|
|
hover: {
|
|
enabled: true,
|
|
radius: 7,
|
|
radiusPlus: 5
|
|
}
|
|
}
|
|
}
|
|
},
|
|
// pie
|
|
plotOptions: {
|
|
pie: {
|
|
allowPointSelect: true,
|
|
cursor: 'pointer',
|
|
dataLabels: {
|
|
enabled: true,
|
|
format: '<br>{point.name}</br>: {point.percentage:.1f} %',
|
|
style: {
|
|
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
|
|
}
|
|
},
|
|
showInLegend: true
|
|
}
|
|
},
|
|
|
|
series: series,
|
|
}
|
|
|
|
if(typeof chartType != "undefined"){
|
|
chart.chart.type = chartType;
|
|
if(chartType == "pie"){
|
|
var oldSeries = chart.series;
|
|
var pieSeries = [];
|
|
var pieSeries2 = {};
|
|
|
|
var pieData = [];
|
|
for(var ind in oldSeries){
|
|
|
|
var pieDataObj = {};
|
|
var countY = 0;
|
|
|
|
var dataArray = oldSeries[ind].data;
|
|
for(var index in dataArray){
|
|
var num = dataArray[index][1];
|
|
countY += num;
|
|
}
|
|
/* if(){ 数据列项为空处理
|
|
|
|
} */
|
|
pieDataObj.name = oldSeries[ind].name;
|
|
pieDataObj.y = countY;
|
|
pieData.push(pieDataObj);
|
|
}
|
|
|
|
pieSeries2.name = 'Brands';
|
|
pieSeries2.colorByPoint = true;
|
|
pieSeries2.data = pieData;
|
|
pieSeries.push(pieSeries2);
|
|
|
|
chart.series = pieSeries;
|
|
chart.tooltip.pointFormat = "{point.y}| <b>{point.percentage:.1f}%</br>";
|
|
}else{
|
|
chart.tooltip.pointFormat = "<span style='color:{point.color}'>\u25CF</span> {series.name}: <b>{point.y}</b><br/>";
|
|
}
|
|
}
|
|
$("#chart").highcharts(chart);
|
|
}
|
|
(function(H) {
|
|
H.Chart.prototype.downloadXLS = function() {
|
|
var start = $("#beginDate").val();
|
|
var end = $("#endDate").val();
|
|
var div = document.createElement('div'), xlsxRows = [], xlsxColumns = [];
|
|
var nowDate=new Date();
|
|
div.style.display = 'none';
|
|
document.body.appendChild(div);
|
|
rows = this.getDataRows(true);
|
|
/* 调用后台接口导出 */
|
|
var total=[];
|
|
var totalValue = JSON.parse($("#total").val());
|
|
total.push(totalValue)
|
|
var map={};
|
|
$(rows).each(function(i,d){
|
|
// 去掉多余属性
|
|
delete d.name;
|
|
delete d.x;
|
|
delete d.xValues;
|
|
})
|
|
rows.shift(); // 删除一个重复行
|
|
var heard = rows.shift(); // 删除一个重复行
|
|
total.unshift('<spring:message code="report_total"/>');
|
|
var title=[];
|
|
rows.push(total)
|
|
title.push('<spring:message code="protocol_type"></spring:message>',start+"--"+end);
|
|
map["titleTime"]=title;
|
|
map["heard"]=heard;
|
|
map["book"]=rows;
|
|
map["titleCode"]='<spring:message code="protocol_type"></spring:message>'+nowDate.getFullYear()+(nowDate.getMonth()+1)+nowDate.getDate()+nowDate.getHours()+nowDate.getMinutes()+nowDate.getSeconds();
|
|
var exports = JSON.stringify(map);
|
|
aJaxImportPost("${ctx}/export/ajaxExport",{"exports":exports});
|
|
|
|
|
|
};
|
|
}(Highcharts));
|
|
|
|
(function(H) {
|
|
H.Chart.prototype.downloadCSV = function() {
|
|
var rows = this.getDataRows(true);
|
|
var data=new Array();
|
|
var total = total = JSON.parse($("#total").val());
|
|
$(rows).each(function (i,d){
|
|
if(d!=null&&i>0){
|
|
data.push({
|
|
num1:d,
|
|
})
|
|
}
|
|
})
|
|
data.push({
|
|
num1:"<spring:message code='total'/>",
|
|
num2:total
|
|
})
|
|
var start = $("#beginDate").val();
|
|
var end = $("#endDate").val();
|
|
exportCsv({
|
|
title:["<spring:message code='protocol_type'/>",start+"--"+end],
|
|
titleForKey:["num1","num2"],
|
|
data:data
|
|
});
|
|
};
|
|
}(Highcharts));
|
|
|
|
function exportCsv(obj){
|
|
var nowDate=new Date();
|
|
//title ["","",""]
|
|
var title = obj.title;
|
|
//titleForKey ["","",""]
|
|
var titleForKey = obj.titleForKey;
|
|
var data = obj.data;
|
|
var str = [];
|
|
str.push(obj.title.join(",")+"\n");
|
|
for(var i=0;i<data.length;i++){
|
|
var temp = [];
|
|
for(var j=0;j<titleForKey.length;j++){
|
|
temp.push(data[i][titleForKey[j]]);
|
|
}
|
|
str.push(temp.join(",")+"\n");
|
|
}
|
|
str = "\uFEFF"+str.join(""); //
|
|
var blob = new Blob([str], {type: 'text/plain'});
|
|
var uri = 'data:text/csv;charset=utf-8,' + encodeURIComponent(blob);
|
|
var downloadLink = document.createElement("a");
|
|
downloadLink.href = window.URL.createObjectURL(blob);
|
|
downloadLink.download = "<spring:message code='protocol_type'/>"+nowDate.getFullYear()+(nowDate.getMonth()+1)+nowDate.getDate()+nowDate.getHours()+nowDate.getMinutes()+nowDate.getSeconds()+".csv";
|
|
downloadLink.style.display = 'none';
|
|
document.body.appendChild(downloadLink);
|
|
downloadLink.click();
|
|
document.body.removeChild(downloadLink);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |