189 lines
7.6 KiB
Plaintext
189 lines
7.6 KiB
Plaintext
|
|
<%@ page language="java" pageEncoding="UTF-8"%>
|
|||
|
|
<script type="text/javascript">
|
|||
|
|
var beginTimeStore = '';
|
|||
|
|
var endTimeStore = '';
|
|||
|
|
function initDate() {
|
|||
|
|
//定义locale汉化插件
|
|||
|
|
beginTimeStore = moment().subtract(1, 'days').format('YYYY-MM-DD HH:mm');;
|
|||
|
|
endTimeStore = moment().format('YYYY-MM-DD HH:mm');
|
|||
|
|
var locale = {
|
|||
|
|
"format": 'YYYY-MM-DD HH:mm',
|
|||
|
|
"separator": " ~ ",
|
|||
|
|
"applyLabel": "确定",
|
|||
|
|
"cancelLabel": "取消",
|
|||
|
|
"fromLabel": "起始时间",
|
|||
|
|
"toLabel": "结束时间'",
|
|||
|
|
"customRangeLabel": "自定义",
|
|||
|
|
"weekLabel": "W",
|
|||
|
|
"daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
|
|||
|
|
"monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
|
|||
|
|
"firstDay": 1
|
|||
|
|
};
|
|||
|
|
$('#reservationtime').daterangepicker({
|
|||
|
|
"timePicker": true,
|
|||
|
|
"timePicker24Hour": true,
|
|||
|
|
"linkedCalendars": false,
|
|||
|
|
"autoUpdateInput": false,
|
|||
|
|
"timePickerIncrement": 10,
|
|||
|
|
"locale": locale,
|
|||
|
|
//汉化按钮部分
|
|||
|
|
ranges: {
|
|||
|
|
'今日': [moment().subtract(1, 'days'), moment()],
|
|||
|
|
'昨日': [moment().subtract(2, 'days'), moment().subtract(1, 'days')],
|
|||
|
|
'最近7日': [moment().subtract(7, 'days'), moment()],
|
|||
|
|
'本月': [moment().startOf('month'), moment().endOf('month')],
|
|||
|
|
'上月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
|||
|
|
},
|
|||
|
|
startDate: beginTimeStore,
|
|||
|
|
endDate: endTimeStore
|
|||
|
|
}, function(start, end, label) {
|
|||
|
|
beginTimeStore = start.format(this.locale.format);
|
|||
|
|
endTimeStore = end.format(this.locale.format);
|
|||
|
|
if(!this.startDate){
|
|||
|
|
this.element.val('');
|
|||
|
|
}else{
|
|||
|
|
this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
|
|||
|
|
}
|
|||
|
|
searchPointFun();
|
|||
|
|
});
|
|||
|
|
$('#reservationtime').val(beginTimeStore + locale.separator + endTimeStore);
|
|||
|
|
searchPointFun();
|
|||
|
|
};
|
|||
|
|
var searchPointFun = function() {
|
|||
|
|
var labels = new Array();
|
|||
|
|
var thisIds = new Array();
|
|||
|
|
var chartData = new Array();
|
|||
|
|
clearCanvas();
|
|||
|
|
//console.info('${id}')
|
|||
|
|
$.post(ext.contextPath + '/work/mpoint/getHistory.do', {ids:'${id}',sdt:beginTimeStore,edt:endTimeStore,companyId:'${param.companyId}'} , function(data) {
|
|||
|
|
//console.info(data)
|
|||
|
|
$.each(data[0], function(index, obj) {
|
|||
|
|
//console.info(obj)
|
|||
|
|
labels.push("("+obj.measuredt.substring(8,10)+")"+obj.measuredt.substring(11,16));
|
|||
|
|
thisIds.push(obj.measuredt);
|
|||
|
|
chartData.push(parseFloat(obj.parmvalue));
|
|||
|
|
});
|
|||
|
|
//同样数据参数设置
|
|||
|
|
var data = {
|
|||
|
|
//折线图需要为每个数据点设置一标签。这是显示在X轴上。
|
|||
|
|
labels: labels,
|
|||
|
|
//这边的thisId分别对应labels的id
|
|||
|
|
thisIds : thisIds,
|
|||
|
|
//数据集(y轴数据范围随数据集合中的data中的最大或最小数据而动态改变的)
|
|||
|
|
datasets: [{
|
|||
|
|
label : '${param.id}',
|
|||
|
|
backgroundColor: "#fff",
|
|||
|
|
borderColor: "rgba(60,141,188,1)",
|
|||
|
|
pointBorderColor: "rgba(60,141,188,1)",
|
|||
|
|
pointBackgroundColor: "#fff",
|
|||
|
|
pointHoverBackgroundColor: "rgba(60,141,188,1)",
|
|||
|
|
pointHoverBorderColor: "rgba(60,141,188,1)",
|
|||
|
|
data : chartData
|
|||
|
|
}]
|
|||
|
|
};
|
|||
|
|
// Get context with jQuery - using jQuery's .get() method.
|
|||
|
|
var areaChartCanvas = $('#canvas').get(0).getContext('2d')
|
|||
|
|
// This will get the first returned node in the jQuery collection.
|
|||
|
|
var areaChart = new Chart(areaChartCanvas,{
|
|||
|
|
type:'line',
|
|||
|
|
data:data,
|
|||
|
|
options:areaChartOptions
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
},'json');
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
*擦除canvas画布
|
|||
|
|
*/
|
|||
|
|
function clearCanvas(){
|
|||
|
|
$('#canvas').remove();
|
|||
|
|
$('#container').append('<canvas id="canvas"></canvas>');
|
|||
|
|
container=document.getElementById("canvas");
|
|||
|
|
context=container.getContext("2d");
|
|||
|
|
}
|
|||
|
|
var areaChartOptions = {
|
|||
|
|
//Boolean - If we should show the scale at all
|
|||
|
|
showScale : true,
|
|||
|
|
//Boolean - Whether grid lines are shown across the chart
|
|||
|
|
scaleShowGridLines : false,
|
|||
|
|
//String - Colour of the grid lines
|
|||
|
|
scaleGridLineColor : 'rgba(0,0,0,.05)',
|
|||
|
|
//Number - Width of the grid lines
|
|||
|
|
scaleGridLineWidth : 1,
|
|||
|
|
//Boolean - Whether to show horizontal lines (except X axis)
|
|||
|
|
scaleShowHorizontalLines: true,
|
|||
|
|
//Boolean - Whether to show vertical lines (except Y axis)
|
|||
|
|
scaleShowVerticalLines : true,
|
|||
|
|
//Boolean - Whether the line is curved between points
|
|||
|
|
bezierCurve : true,
|
|||
|
|
//Number - Tension of the bezier curve between points
|
|||
|
|
bezierCurveTension : 0.3,
|
|||
|
|
//Boolean - Whether to show a dot for each point
|
|||
|
|
pointDot : false,
|
|||
|
|
//Number - Radius of each point dot in pixels
|
|||
|
|
pointDotRadius : 4,
|
|||
|
|
//Number - Pixel width of point dot stroke
|
|||
|
|
pointDotStrokeWidth : 1,
|
|||
|
|
//Number - amount extra to add to the radius to cater for hit detection outside the drawn point
|
|||
|
|
pointHitDetectionRadius : 20,
|
|||
|
|
//Boolean - Whether to show a stroke for datasets
|
|||
|
|
datasetStroke : true,
|
|||
|
|
//Number - Pixel width of dataset stroke
|
|||
|
|
datasetStrokeWidth : 2,
|
|||
|
|
//Boolean - Whether to fill the dataset with a color
|
|||
|
|
datasetFill : true,
|
|||
|
|
//Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
|
|||
|
|
maintainAspectRatio : true,
|
|||
|
|
//Boolean - whether to make the chart responsive to window resizing
|
|||
|
|
responsive : true
|
|||
|
|
}
|
|||
|
|
$(function() {
|
|||
|
|
//Create the line chart
|
|||
|
|
//areaChart.Line(areaChartData, areaChartOptions)
|
|||
|
|
initDate();
|
|||
|
|
//searchPointFun();
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
</script>
|
|||
|
|
<div class="modal fade" id="subModal">
|
|||
|
|
<div class="modal-dialog">
|
|||
|
|
<div class="modal-content">
|
|||
|
|
<div class="modal-header">
|
|||
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|||
|
|
<span aria-hidden="true">×</span></button>
|
|||
|
|
<h4 class="modal-title">历史曲线</h4>
|
|||
|
|
</div>
|
|||
|
|
<div class="modal-body">
|
|||
|
|
<!-- 新增界面formid强制为subForm -->
|
|||
|
|
<form class="form-horizontal" id="subForm">
|
|||
|
|
<div id="alertDiv"></div>
|
|||
|
|
<label>起止时间:</label>
|
|||
|
|
|
|||
|
|
<div class="input-group">
|
|||
|
|
<div class="input-group-addon">
|
|||
|
|
<i class="fa fa-clock-o"></i>
|
|||
|
|
</div>
|
|||
|
|
<input type="text" class="form-control pull-left" id="reservationtime" >
|
|||
|
|
</div>
|
|||
|
|
<div class="form-group " >
|
|||
|
|
<div class="input-group input-group-sm" >
|
|||
|
|
<!-- <div class="input-group-btn">
|
|||
|
|
<button type="button" class="btn btn-default pull-right" onclick="searchPointFun();" style="margin:15px"><i class="fa fa-search"></i> 搜索</button>
|
|||
|
|
</div> -->
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
</form>
|
|||
|
|
<div id="container">
|
|||
|
|
<canvas id="canvas"></canvas>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<div class="modal-footer">
|
|||
|
|
<button type="button" class="btn btn-default pull-right" data-dismiss="modal">关闭</button>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
<!-- /.modal-content -->
|
|||
|
|
</div>
|
|||
|
|
<!-- /.modal-dialog -->
|
|||
|
|
</div>
|