ODKL.html
8.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<style type="text/css">
.table-bordered {
border: 1px solid; }
.table-bordered > thead > tr > th,
.table-bordered > thead > tr > td,
.table-bordered > tbody > tr > th,
.table-bordered > tbody > tr > td,
.table-bordered > tfoot > tr > th,
.table-bordered > tfoot > tr > td {
border: 1px solid; }
.table-bordered > thead > tr > th,
.table-bordered > thead > tr > td {
border-bottom-width: 2px;
text-align: center; }
.table > tbody + tbody {
border-top: 1px solid; }
</style>
<div class="page-head">
<div class="page-title">
<h1>OD客流</h1>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="portlet light porttlet-fit bordered">
<div class="portlet-title">
<form class="form-inline" action="">
<div style="display: inline-block;">
<span class="item-label" style="width: 80px;">线路: </span>
<select class="form-control" name="line" id="line" style="width: 180px;"></select>
</div>
<div style="display: inline-block;margin-left: 24px;">
<span class="item-label" style="width: 80px;"> 时间: </span>
<input class="form-control" type="text" id="date" style="width: 180px;"/>
</div>
<div style="display: inline-block; margin-left: 30px;">
<div class="md-radio-inline">
<div class="md-radio">
<input type="radio" id="radio1" name="dir" class="md-radiobtn" value="0"
data-title="是" checked="checked">
<label for="radio1">
<span></span>
<span class="check"></span>
<span class="box"></span> 上行
</label>
</div>
<div class="md-radio">
<input type="radio" id="radio2" name="dir" class="md-radiobtn" value="1"
data-title="否">
<label for="radio2">
<span></span>
<span class="check"></span>
<span class="box"></span> 下行
</label>
</div>
</div>
</div>
<div class="form-group">
<input class="btn btn-default" type="button" id="query" value="查询"/>
</div>
</form>
</div>
<div class="portlet-body" style="width: 100%;height: 70vh;">
<div id="container" style="height: 100%"></div>
</div>
</div>
</div>
</div>
<script src="/metronic_v4.5.4/plugins/echarts5/echarts.min.js"></script>
<!--<script src="/metronic_v4.5.4/plugins/echarts4/echarts.min.js"></script>-->
<script>
$("#date").datetimepicker({
format : 'YYYY-MM-DD',
locale : 'zh-cn'
});
var d = new Date();
var year = d.getFullYear();
var month = d.getMonth() + 1;
var day = d.getDate();
if(month < 10)
month = "0" + month;
if(day < 10)
day = "0" + day;
$("#date").val(year + "-" + month + "-" + day);
$.get('/report/lineList',function(xlList){
var data = [];
// data.push({id: " ", text: "全部线路"});
$.get('/user/companyData', function(result){
for(var i = 0; i < result.length; i++){
var companyCode = result[i].companyCode;
var children = result[i].children;
for(var j = 0; j < children.length; j++){
var code = children[j].code;
for(var k=0;k < xlList.length;k++ ){
if(xlList[k]["fgsbm"]==code && xlList[k]["gsbm"]==companyCode){
data.push({id: xlList[k]["xlbm"], text: xlList[k]["xlname"]});
// tempData[xlList[k]["xlbm"]] = companyCode+":"+code;
}
}
}
}
initPinYinSelect2('#line',data,'');
});
});
$("#query").on("click",function(){
if($("#date").val() == null || $("#date").val().trim().length == 0){
layer.msg("请选择时间");
return;
}
var lineCode = $("#line").val();
var date = $("#date").val();
var dir = $('input[name="dir"]:checked').val();
var i = layer.load(2);
$get('/ODInfo/odTable',{lineCode:lineCode,dir:dir,date:date},function(result){
load(result.stations,result.kl);
layer.close(i);
});
});
function load(stations,kl){
var hours =stations;
var days=stations;
var dom = document.getElementById('container');
var app = {};
var option;
// prettier-ignore
const data = kl
.map(function (item) {
return [item[1], item[0], item[2] || '-'];
});
const xAxisCount = hours.length; // X轴刻度数量:9
const yAxisCount = days.length; // Y轴刻度数量:9
const cellSize = 30; // 你可以根据需要调整格子的大小(像素)
const gridWidth = 1200;
const gridHeight = gridWidth * (yAxisCount / xAxisCount);
/* dom.style.width = '1000px'; // 可以设置一个基础宽度
dom.style.height = '1000px'; // 高度大致匹配*/
var myChart = echarts.init(dom, null, {
renderer: 'canvas',
useDirtyRect: false
});
option = {
tooltip: {
position: 'top',
backgroundColor: '#282829',
borderColor : '#282829',
textStyle:{
fontWeight:600,
color:'#FFFFFFFF',
},
formatter: function (params) {
var x=params.data[0];
var y=params.data[1];
return `<div><span style="color: #ffd966;">${days[y]}</span> → <span style="color: #ffd966;">${hours[x]}</span></div>\n <div>客流人数: <span style="color: #4aa3ff; font-weight: 600;">${params.data[2]}</span> 人</div>`;
/*return `上车站点: ${days[y]} <br>下车站点: ${hours[x]} <br> 人数: ${params.data[2]}`;*/
}
},
grid: {
width: '95%',
height: '95%',
left: '0%',
right: '0%',
top: '5%',
bottom: '15%',
containLabel: true // 确保标签不会被裁剪
},
xAxis: {
type: 'category',
data: hours,
splitArea: {
show: true
},
name:'下车站点',
axisLabel: {
rotate: 45 // 设置标签旋转角度为45度
},
interval: 1
},
yAxis: {
type: 'category',
data: days,
splitArea: {
show: true
},
name:'上车站点',
axisLabel: {
interval: 0
},
interval: 1
},
visualMap: {
type: 'continuous',
min: 0,
max: 20,
calculable: true,
right: '0%',
top: '5%'
},
series: [
{
name: 'Punch Card',
type: 'heatmap',
data: data,
label: {
show: true
},
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};
option && myChart.setOption(option);
}
</script>