historyProtectChart_frm.html
16.4 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>保护动作历史报表_frm</title>
<link rel="stylesheet" type="text/css" href="../../css/api.css"/>
<link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
<link rel="stylesheet" type="text/css" href="../../css/statistic/statistic.css"/>
<link rel="stylesheet" type="text/css" href="../../css/style.css"/>
<link rel="stylesheet" type="text/css" href="../../css/history/history.css"/>
<style>
html,
body{
background-color: #F4F6F9;
}
</style>
</head>
<body>
<div style="background-color:#FFFFFF;">
<div class="measure-title">
<div style="margin-left:15px;margin-right:15.5px;">
<div class="aui-row aui-row-flex top-14">
<div class="aui-col aui-col-span-1" style="margin-top: 1rem;">
<div class="title-sign"></div>
</div>
<div class="aui-col aui-col-span-23">
<span class="device-name" id="device_imei">设备编号:</span>
</div>
</div>
<div style="margin-top:17.5px;margin-bottom:12px;height:1px;background:#F0F5FF;"></div>
</div>
</div>
<div class="search-view-inline">
<div class="select-list aui-ellipsis-1" style="width:25%;" tapmode id="select-date" onclick="selectDay();">
<span class="choose-device-title" id="choose_history_day">按日</span>
<i></i>
</div>
<!-- <label style="background-color:rgba(240,245,255,1);"></label> -->
<div class="select-list aui-ellipsis-1" style="width:40%;" tapmode id="select-time" onclick="selectTime();">
<span class="choose-device-title" id="choose_history_time">选择开始日期</span>
<i></i>
</div>
<!-- <label style="background-color:rgba(240,245,255,1);"></label> -->
<div class="select-list aui-ellipsis-1" style="width:35%;" tapmode id="select-time" onclick="selectType();">
<span class="choose-device-title" id="choose_history_type">动作类型</span>
<i></i>
</div>
</div>
</div>
<div class="history-alarm-title">
<div class="aui-row aui-row-flex top-14">
<div class="aui-col aui-col-span-12 aui-row-flex-start alarm-title">
<span id="currentT">该日</span><span>保护动作数据分析</span>
</div>
<div class="aui-col aui-col-span-12 aui-row-flex-end alarm-tip">
数据来自实时采集
</div>
</div>
</div>
<div class="echart-area">
<div class="inside-echart-area" id="echart_area">
</div>
<div style="margin-top:20px;height:10px;margin-bottom:15px;"></div>
</div>
<div class="echart-area" id="circle_echart">
<div class="inside-echart-area" id="echart_area_circle">
</div>
<div style="margin-top:20px;height:10px;margin-bottom:15px;"></div>
</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/echarts.min.js"></script>
<script type="text/javascript" src="../../script/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
var defaultImei;
var token;
var userId;
var select_day = 1; //1.按日2.按月3.按年
var select_time = '';
var select_pt = 'all';
apiready = function(){
api.parseTapmode();
defaultImei = $api.getStorage('defaultDevice');
token = $api.getStorage('userToken');
userId = $api.getStorage('userID');
$api.html($api.byId("device_imei"), '设备编号:'+ defaultImei);
select_time = parseTime(new Date(),'{y}-{m}-{d}');
$api.html($api.byId("choose_history_time"), select_time);
api.addEventListener({
name: 'changeHistoryChartType'
}, function(ret, err){
if( ret ){
switch (ret.value.curSelect) {
case 1:
$api.html($api.byId("choose_history_day"), '按日');
$api.html($api.byId("currentT"), '该日');
select_day = 1;
break;
case 2:
$api.html($api.byId("choose_history_day"), '按月');
$api.html($api.byId("currentT"), '该月');
select_day = 2;
break;
case 3:
$api.html($api.byId("choose_history_day"), '按年');
$api.html($api.byId("currentT"), '该年');
select_day = 3;
break;
default:
$api.html($api.byId("choose_history_day"), '按日');
$api.html($api.byId("currentT"), '该日');
select_day = 3;
}
loadChartInfo();
}
});
api.addEventListener({
name: 'changeHistoryProtectType'
}, function(ret, err){
if( ret ){
if (ret.value.curSelect == 'all') {
$api.html($api.byId('choose_history_type'), '动作类型');
}else {
$api.html($api.byId('choose_history_type'), ret.value.curSelect);
}
}
select_pt = ret.value.curSelect;
loadChartInfo();
});
loadChartInfo();
};
function selectDay() {
api.openFrame({
name: 'historyDaliySelecter',
url: './historyChartDaliySelecter.html',
rect: {
x: 0,
y: api.pageParam.h,
w: api.frameWidth,
h: api.winHeight-api.pageParam.h
},
pageParam: {
selected: select_day,
},
bounces: false,
animation: {
type:"fade", //动画类型(详见动画类型常量)
subType:"from_bottom", //动画子类型(详见动画子类型常量)
duration:300 //动画过渡时间,默认300毫秒
}
});
}
function selectType() {
api.openFrame({
name: 'protectTypeSelect_frm',
url: '../protect/protectTypeSelect_frm.html',
rect: {
x: 0,
// y: api.winHeight-203,
y: api.pageParam.h,
w: api.winWidth,
h: api.winHeight-api.pageParam.h
},
pageParam: {
selected: select_pt,
historyPage: true
},
bounces: false,
animation: {
type:"fade", //动画类型(详见动画类型常量)
subType:"from_bottom", //动画子类型(详见动画子类型常量)
duration:300 //动画过渡时间,默认300毫秒
}
});
}
function selectTime() {
api.openPicker({
type: 'date',
date: 'yyyy',
title: '选择日期',
}, function(ret, err) {
if (ret) {
var select_time_ = parseTime(new Date(timeFormater(ret.year,ret.month,ret.day)),'{y}-{m}-{d}');
select_time = select_time_;
if (select_day == 1) {
$api.html($api.byId("choose_history_time"), select_time_.slice(0,11));
}else if (select_day == 2) {
$api.html($api.byId("choose_history_time"), select_time_.slice(0,7));
}else if (select_day == 3) {
$api.html($api.byId("choose_history_time"), select_time_.slice(0,4));
}
loadChartInfo();
}
});
}
function loadChartInfo() {
if (select_day == 1) {
select_time = select_time.slice(0,11);
}else if (select_day == 2) {
select_time = select_time.slice(0,7);
}else if (select_day == 3) {
select_time = select_time.slice(0,4);
}
$api.html($api.byId("choose_history_time"), select_time);
console.log(HOST + '/iot_api/v1/app/chart_report?time=' + select_time + '&type=' + select_day + '&imei=' + defaultImei + '&action_type=' + select_pt);
$.ajax({
url: HOST + '/iot_api/v1/app/chart_report?time=' + select_time + '&type=' + select_day + '&imei=' + defaultImei + '&action_type=' + select_pt,
type: 'GET',
dataType: 'json',
headers: {
'Content-Type': 'application/json;charset=utf-8',
'token': token
},
success: function(ret) {
if (ret.code == 0) {
//饼状图
showCircleChart(ret.data);
//柱状图
var dom1 = $api.byId("echart_area");
var myChart = echarts.init(dom1);
var dom1DataX = ret.data.xdata;
var dom1DataY = ret.data.y_action_data;
option = {
title: {
left: 'center',
text: '历史保护动作',
},
color: ['#5B7FF8'],
tooltip : {
trigger: 'axis',
axisPointer : { // 坐标轴指示器,坐标轴触发有效
type : 'line' // 默认为直线,可选为:'line' | 'shadow'
}
},
grid: {
left: '0%',
right: '5%',
bottom: '20%',
containLabel: true
},
xAxis : [
{
type : 'category',
data : dom1DataX,
axisTick: {
alignWithLabel: true
},
axisLine: {
lineStyle: {
color: '#818295'
}
},
axisLabel: {
textStyle: {
color: function (value, index) {
return '#818295';
},
fontSize: 8,
},
rotate:330
}
}
],
yAxis : [
{
type : 'value',
axisLine: {
lineStyle: {
color: '#fff'
}
},
axisLabel: {
textStyle: {
color: function (value, index) {
return value >= 10 ? 'red' : '#818295';
}
}
},
splitLine:{
show:true ,
lineStyle:{
color:'#F0F5FF',
width: 1
}
}
}
],
series : [
{
name:'动作总数',
type:'line',
barWidth: '60%',
data:dom1DataY,
showSymbol: true,
hoverAnimation: false,
symbol: 'path://M30.9,53.2C16.8,53.2,5.3,41.7,5.3,27.6S16.8,2,30.9,2C45,2,56.4,13.5,56.4,27.6S45,53.2,30.9,53.2z M30.9,3.5C17.6,3.5,6.8,14.4,6.8,27.6c0,13.3,10.8,24.1,24.101,24.1C44.2,51.7,55,40.9,55,27.6C54.9,14.4,44.1,3.5,30.9,3.5z M36.9,35.8c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H36c0.5,0,0.9,0.4,0.9,1V35.8z M27.8,35.8 c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H27c0.5,0,0.9,0.4,0.9,1L27.8,35.8L27.8,35.8z',
symbolSize: 8,
// 折线颜色
itemStyle: {
normal: {
color: '#5B7FF8',
lineStyle: {
color: '#5B7FF8'
}
}
},
},
],
dataZoom: [
{
type: 'slider',
fillerColor: '#B0C8FF',
backgroundColor: '#F0F5FF',
start: 0,
end: 100,
handleIcon: "M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z",
handleSize: '90%',
handleStyle: {
color: '#5B7FF8',
},
dataBackground:{
lineStyle:{
color:'#F0F5FF'
},
areaStyle:{
color:'#F0F5FF',
opacity:1,
}
},
bottom:'0%'
},{
type: 'inside',//这个 dataZoom 组件是 inside 型 dataZoom 组件(能在坐标系内进行拖动,以及用滚轮(或移动触屏上的两指滑动)进行缩放)
xAxisIndex: 0,//控制x轴
}
],
};
if (option && typeof option === "object") {
myChart.setOption(option, true);
}
}
},
error: function() {
api.toast({msg: ERR_MSG,duration: 2000,location: 'bottom'});
}
});
}
function showCircleChart(data) {
var dom2 = $api.byId("echart_area_circle");
var circleAreaDom = $api.byId("circle_echart");
if (select_pt != 'all') {
$api.addCls(circleAreaDom, 'aui-hide');
}else {
$api.removeCls(circleAreaDom, 'aui-hide');
}
var data_ = data.action_round_ydata;
var allZero = true;
for (var i = 0; i < data_.length; i++) {
if (data_[i].value != 0) {
allZero = false;
}
}
var myChart2 = echarts.init(dom2);
option = {
title : {
text: '保护动作占比',
x:'center'
},
tooltip : {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
color : ['#87a7ff','#88d1ea','#88d1ea','#82dfbe','#91cf6d'],
toolbox: {
show : true,
feature : {
mark : {show: true},
magicType : {
show: true,
type: ['pie', 'funnel']
},
}
},
calculable : true,
series : [
{
name:'历史保护信息',
type:'pie',
radius : [20, 80],
center : ['50%', '50%'],
roseType : 'angle',
data: data_.map(function(item){
// console.log(JSON.stringify(item));
if (allZero) { //allZero T:全都是0 要都显示 F:有不是0的 单独显示几个。
return item
}else {
if (item.value != 0) {
return item
}
}
}),
}
]
};
if (option && typeof option === "object") {
myChart2.setOption(option, true);
}
}
</script>
</html>