-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistory_graph.html
735 lines (664 loc) · 23.4 KB
/
history_graph.html
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
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
<!DOCTYPE html>
<html lang="de">
<head>
<title>G-Analysis</title>
<meta charset="UTF-8">
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.png">
<!-- Bootstrap Scripts-->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link id="mainStyle" type="text/css" rel="stylesheet" href="src/css/main_style.css" media="all">
<link type="text/css" rel="stylesheet" href="dist/js/jqueryui/jquery-ui.min.css">
<link type="text/css" rel="stylesheet" href="dist/js/jqueryui/jquery-ui.structure.min.css">
<link type="text/css" rel="stylesheet" href="dist/js/jqueryui/jquery-ui.theme.css">
<link type="text/css" rel="stylesheet" href="dist/js/mathquill/mathquill.css"/>
<link type="text/css" rel="stylesheet" href="dist/css/jquery.dataTables.min.css">
<link type="text/css" rel="stylesheet" href="dist/css/buttons.dataTables.min.css">
<link type="text/css" rel="stylesheet" href="dist/css/colReorder.dataTables.min.css">
<link href="dist/css/pace-theme.min.css" rel="stylesheet"/>
<!-- Tree View Script -->
<link href="src/css/jquery.treeview.css" rel="stylesheet">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<link rel="stylesheet" href="dashboard/css/style.css">
<link rel="stylesheet" href="dashboard/css/custom.css">
<!-- Dsashboard css -->
<!-- plugins:css -->
<link rel="stylesheet" href="dashboard/vendors/ti-icons/css/themify-icons.css">
<link rel="stylesheet" href="dashboard/vendors/base/vendor.bundle.base.css">
<!-- endinject -->
<!-- plugin css for this page -->
<!-- End plugin css for this page -->
<!-- inject:css -->
<link rel="stylesheet" href="dashboard/css/style.css">
<link rel="stylesheet" href="dashboard/css/custom.css">
<!-- endinject -->
<link rel="shortcut icon" href="dashboard/images/G-Analysis/favicon.png" />
<link rel="stylesheet" href="dashboard/css/jquery.multiselect.css" />
<!-- 7-9-2021-- -->
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link href="https://cdn.jsdelivr.net/gh/gitbrent/[email protected]/css/bootstrap4-toggle.min.css" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet"/>
<style>
.ui-dialog .ui-dialog-content {
position: relative;
padding: .5em 1em;
background: #B9C0C7;
}
.ui-dialog .ui-dialog-titlebar {
background: #6B6F73;
}
.ui-widget-content {
border: 3px solid black;
background: #CED6DE;
}
.custom {
font-size: 10px;
}
th {
text-align: left;
background: transparent;
}
.text-muted {
color: #0a0a0a !important;
}
body{
font-family: Calibri,Arial, Helvetica, sans-serif !important;
}
</style>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css" rel="stylesheet" />
<link rel="stylesheet" href="production_dashboard/css/bootstrap-duallistbox.min.css">
<link rel="stylesheet" href="production_dashboard/css/new.css">
</head>
<body>
<style>
.table thead tr th {
border: 1px solid black !important;
color: black;
}
#messstelle1IDAnl_key_filter{
margin-left: 346px !important;
margin-top: -15px !important;
}
#messstelle1IDAnl_key_paginate{
margin-left: 217px !important;
}
#messstelle2IDAnl_key_filter{
margin-left: 346px !important;
margin-top: -15px !important;
}
#messstelle2IDAnl_key_paginate{
margin-left: 217px !important;
}
.table tbody tr td {
border: 1px solid black !important;
color: black;
}
#chartdiv {
width: 100%;
height: 500px;
max-width: 100%;
}
</style>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<div class="container-fluid">
<div class="offset-md-1 row mb-2">
<div class="col-sm-4">
</div>
</div>
</div><!-- /.container-fluid -->
</section>
<!-- Main content -->
<section class="content">
<div class="container-fluid">
<div class="row">
<div class="offset-md-1 col-md-10">
<!-- AREA CHART -->
<div class="card card-primary">
<div class="card-header">
<h3 class="card-title dynamic_title">History Chart</h3>
</div>
<div class="card-body">
<div class="chart">
<div id="accordion">
<div class="chart" id="chartdiv">
</div>
</div>
</div>
</div>
<!-- /.card-body -->
</div>
</div>
<!-- /.card -->
<!-- /.col (RIGHT) -->
</div>
<div class="row">
<div class="offset-md-1 col-md-10 measuringPointsTable">
</div>
</div>
<!-- /.row -->
</div>
</section>
<!-- /.content -->
</div>
<script type="text/javascript" src="dist/js/jquery.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.amcharts.com/lib/5/index.js"></script>
<script src="https://cdn.amcharts.com/lib/5/xy.js"></script>
<script src="https://cdn.amcharts.com/lib/5/themes/Animated.js"></script>
<script src="production_dashboard/production_js/datatables/jquery.dataTables.min.js"></script>
<script src="production_dashboard/production_js/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="production_dashboard/production_js/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="production_dashboard/production_js/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="production_dashboard/production_js/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="production_dashboard/production_js/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="production_dashboard/production_js/jszip/jszip.min.js"></script>
<script src="production_dashboard/production_js/pdfmake/pdfmake.min.js"></script>
<script src="production_dashboard/production_js/pdfmake/vfs_fonts.js"></script>
<script src="production_dashboard/production_js/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="production_dashboard/production_js/datatables-buttons/js/buttons.print.min.js"></script>
<script src="production_dashboard/production_js/datatables-buttons/js/buttons.colVis.min.js"></script>
<script src="dist/js/ej.web.all.min.js" type="text/javascript"></script>
<script type="text/javascript" src="dist/js/fpCore.min.js"></script>
<script type="text/javascript" src="dist/js/fpGeometry.min.js"></script>
<script type="text/javascript" src="src/js/formula.js"></script>
<script src="dist/js/math.min.js" type="text/javascript"></script>
<script src="Syncfusion/scripts/properties.js" type="text/javascript"></script>
<!-- Page specific script -->
<script type="text/javascript" language="javascript">
const [ frm, geo ] = [ scpFormula, scpGeometry ] ;
let root = "#chartdiv";
const createAmChart = async (root, chartsData, dispose, xtype="date") => {
let graphSeries = [];
let maxArray = [];
console.log('chartsData.amData',root);
for (const property of chartsData) {
let series = {
dataSource: [],
xName: 'x', yName: 'y',
name: property.name, type: 'Line',
tooltip :
{ visible :true,
format: " #series.name# <br/> #point.x# : #point.y#"
},
marker:
{
shape: 'circle',
size:
{
height: 6, width: 6
},
visible: true
},
};
for (const graphValues of property.amData) {
series.dataSource.push(
{
x : new Date(graphValues?.date),
y : graphValues?.value
}
)
maxArray.push(graphValues?.value);
}
graphSeries.push(series);
}
console.log(graphSeries,'graphSeries');
$(`${root}`).ejChart({
//Initializing Primary X Axis
primaryXAxis:
{
title: { text: "Time" },
interval: 15,
valueType: 'DateTime',
//interval type as years in primary x axis
intervalType: 'Minutes'
},
//Initializing Primary Y Axis
primaryYAxis:
{
labelFormat: '{value}',
// minimum: 0,
// maximum: Math.max(...maxArray),
// axisLine: { visible: false },
name: 'yAxis',
title: { text: "Energy" }
},
series:graphSeries,
//Initializing Common Properties for all the series
commonSeriesOptions :
{
enableAnimation :true
},
//Initializing Series
load:"loadTheme",
canResize:true,
title :{text: 'Energy Charts'},
legend: { visible: true }
});
}
/*let root = am5.Root.new("chartdiv");
//historic data start
const createAmChart = (root, chartsData, dispose) => {
console.log(chartsData);
if (dispose) {
root.container.children.clear();
}
// Set themes
// https://www.amcharts.com/docs/v5/concepts/themes/
root.setThemes([
am5themes_Animated.new(root)
]);
// Create chart
// https://www.amcharts.com/docs/v5/charts/xy-chart/
var chart = root.container.children.push(
am5xy.XYChart.new(root, {
focusable: true,
panX: true,
panY: true,
wheelX: "panX",
wheelY: "zoomX",
layout: root.verticalLayout
})
);
var easing = am5.ease.linear;
chart.get("colors").set("step", 3);
// Create axes
// https://www.amcharts.com/docs/v5/charts/xy-chart/axes/
var xAxis = chart.xAxes.push(
am5xy.DateAxis.new(root, {
maxDeviation: 0.1,
groupData: false,
baseInterval: {
timeUnit: "minutes",
count: 15
},
renderer: am5xy.AxisRendererX.new(root, {}),
tooltip: am5.Tooltip.new(root, {})
})
);
// https://www.amcharts.com/docs/v5/charts/xy-chart/cursor/
var cursor = chart.set("cursor", am5xy.XYCursor.new(root, {
xAxis: xAxis,
behavior: "none"
})
);
cursor.lineY.set("visible", false);
// add scrollbar
chart.set("scrollbarX", am5.Scrollbar.new(root, {
orientation: "horizontal"
}));
let count = 0;
let opposite;
for (const key in chartsData) {
opposite = (count == 0)?false:true;
let graphName = chartsData[key]['name'] !== undefined?chartsData[key]['name']:key;
createAxisAndSeries(chartsData[key]['amData'], opposite, graphName, root, chart, xAxis);
count++;
}
var legend = chart.children.push(am5.Legend.new(root, {
}));
legend.data.setAll(chart.series.values);
// Make stuff animate on load
// https://www.amcharts.com/docs/v5/concepts/animations/
chart.appear(1000, 100);
}*/
function createAxisAndSeries(startValue, opposite, name, root, chart, xAxis) {
var yRenderer = am5xy.AxisRendererY.new(root, {
opposite: opposite
});
var yAxis = chart.yAxes.push(
am5xy.ValueAxis.new(root, {
maxDeviation: 1,
renderer: yRenderer
})
);
if (chart.yAxes.indexOf(yAxis) > 0) {
yAxis.set("syncWithAxis", chart.yAxes.getIndex(0));
}
// Add series
// https://www.amcharts.com/docs/v5/charts/xy-chart/series/
var series = chart.series.push(
am5xy.LineSeries.new(root, {
xAxis: xAxis,
yAxis: yAxis,
valueYField: "value",
valueXField: "date",
legendLabelText: name,
tooltip: am5.Tooltip.new(root, {
pointerOrientation: "horizontal",
labelText: "{valueY}"
})
})
);
//series.fills.template.setAll({ fillOpacity: 0.2, visible: true });
series.strokes.template.setAll({ strokeWidth: 1 });
yRenderer.grid.template.set("strokeOpacity", 0.05);
yRenderer.labels.template.set("fill", series.get("fill"));
yRenderer.setAll({
stroke: series.get("fill"),
strokeOpacity: 1,
opacity: 1
});
// Set up data processor to parse string dates
// https://www.amcharts.com/docs/v5/concepts/data/#Pre_processing_data
series.data.processor = am5.DataProcessor.new(root, {
dateFormat: "yyyy-MM-dd",
dateFields: ["date"]
});
series.data.setAll(startValue);
}
const createAmChartCategory = (root, chartsData, dispose, name, type) => {
console.log('type', type);
// console.log('chartData', chartsData);
// return false;
csOptions = {
tooltip: {
visible : true
},
border : {width: 0},
stroke : {width: 0},
marker: {
shape: 'circle',
size: {
height: 6, width: 6
},
visible: true,
border :{width : 2,color : "black"},
},
tooltip: {visible: true, format: "#point.x# <br/> #series.name# : #point.y#"}
}
if(type == 'double') {
console.log('herer is mixed charts');
$(`#chartdiv`).ejChart({
palette: [ "black", "blue", "red", "green", "yellow", "purple"],
legend: {
position: "top"
},
//Initializing Primary X Axis
primaryXAxis: {
title: {
text: name
},
labelIntersectAction : "rotate45"
},
//Initializing Primary Y Axis
primaryYAxis: {
title: {
text: name
}
},
axes:
[
{
orientation: 'Vertical',
hidePartialLabels: false,
rowIndex: 0,
majorGridLines: { visible: true },
axisLine: { visible: false },
name: 'Energy',
labelFormat: '{value}',
title: { text: "Energy Consuption" },
opposedPosition: true
}
],
commonSeriesOptions: csOptions,
series: [],
pointRegionClick: function (args) {
console.log("Clicked on point! PointIndex: " + args.data.region.Region.PointIndex);
console.log(args.data);
}
});
} else {
$(`#chartdiv`) .ejChart({
palette: [ "black", "blue", "red", "green", "yellow", "purple"],
legend: {
position: "top"
},
//Initializing Primary X Axis
primaryXAxis: {
title: {
text: name
},
labelIntersectAction : "rotate45"
},
//Initializing Primary Y Axis
primaryYAxis: {
title: {
text: ""
}
},
commonSeriesOptions: csOptions,
series: [],
pointRegionClick: function (args) {
console.log("Clicked on point! PointIndex: " + args.data.region.Region.PointIndex);
console.log(args.data);
}
});
}
createGraphDataSet(chartsData, name, root, type);
}
const createGraphDataSet = (newData, chartName, root, type) => {
const chartData =
newData
.map(
(data,i)=>
({
name: chartName,
x: "A" + (i + 1) + "-" + data.date,
y: data.value,
y1: data.value2
})
),
[startingPoint, endingPoint] =
[geo.point(head(chartData).x), geo.point(last(chartData).x)]
indicator =
geo
.horizontalLine(startingPoint)(endingPoint);
const indicators =
arr =>
arr
.map(
a => updateChartScript(indicator(head(tail(a))))(head(a))(0.3)(root)
)
const drawChart =
() => {
updateChartScript (chartData) (chartName) (1.0) (root) (type);
}
console.log('chartPoint', chartData);
const pointsChart =
chartData
.map(a => a.y);
const minPointsChart =
math.min(pointsChart)
const maxPointsChart =
math.max(pointsChart)
drawChart();
return;
}
const updateChartScript =
newDataSeries =>
nameSeries =>
opacity => root => type => {
let chart = $(`#chartdiv`).ejChart("instance");
chart.model.series.push({
type: 'line',
dataSource: newDataSeries,
name: nameSeries,
xName: "x",
yName: "y",
opacity
});
if(type == 'double') {
chart.model.series.push({
type: 'line',
dataSource: newDataSeries,
name: 'Energy',
yAxisName: 'Energy',
xName: "x",
yName: "y1",
opacity
});
}
chart.redraw();
}
/*const createAmChartCategory = (root, chartsData, dispose, name, type) => {
let graphName = name !== undefined?name:0;
if (dispose) {
root.container.children.clear();
}
// Set themes
// https://www.amcharts.com/docs/v5/concepts/themes/
root.setThemes([
am5themes_Animated.new(root)
]);
// Create chart
// https://www.amcharts.com/docs/v5/charts/xy-chart/
var chart = root.container.children.push(
am5xy.XYChart.new(root, {
focusable: true,
panX: true,
panY: true,
wheelX: "panX",
wheelY: "zoomX",
layout: root.verticalLayout
})
);
var easing = am5.ease.linear;
// chart.get("colors").set("step", 3);
// Create axes
// https://www.amcharts.com/docs/v5/charts/xy-chart/axes/
var xAxis = chart.xAxes.push(
am5xy.CategoryAxis.new(root, {
categoryField: "date",
renderer: am5xy.AxisRendererX.new(root, {})
})
);
xAxis.data.setAll(chartsData);
var yRenderer = am5xy.AxisRendererY.new(root, {
opposite: false
});
var yAxis = chart.yAxes.push(
am5xy.ValueAxis.new(root, {
maxDeviation: 1,
renderer: yRenderer
})
);
if (chart.yAxes.indexOf(yAxis) > 0) {
yAxis.set("syncWithAxis", chart.yAxes.getIndex(0));
}
console.log('graph_type', type);
if(type == 'double') {
var series = chart.series.push(
am5xy.ColumnSeries.new(root, {
name: graphName,
xAxis: xAxis,
yAxis: yAxis,
logarithmic: true,
valueYField: "value",
categoryXField: "date"
})
);
series.data.setAll(chartsData);
var series2 = chart.series.push(
am5xy.ColumnSeries.new(root, {
name: "Energy",
xAxis: xAxis,
yAxis: yAxis,
logarithmic: true,
valueYField: "value2",
categoryXField: "date"
})
);
series2.data.setAll(chartsData);
} else {
var series = chart.series.push(
am5xy.ColumnSeries.new(root, {
name: graphName,
xAxis: xAxis,
yAxis: yAxis,
valueYField: "value",
categoryXField: "date"
})
);
series.data.setAll(chartsData);
series.tooltipText = "{categoryX}: {valueY}";
}
var legend = chart.children.push(
am5.Legend.new(root, {
centerX: am5.p50,
x: am5.p50
})
);
legend.data.setAll(chart.series.values);
// Make stuff animate on load
// https://www.amcharts.com/docs/v5/concepts/animations/
chart.appear(1000, 100);
}*/
//blade code for measuring points data start
function createTable(chartsData) {
let cardhtml = '';
for (const key in chartsData) {
cardhtml += `<div class="card">
<div class="card-header collapsed" id="headingThree">
<div class="col-sm-6" >
<h5 class="mb-0">
${chartsData[key]['name']}
</h5>
</div>
</div>
<div id="${chartsData[key]['name']}">
<div class="card-body">
<table class="table table-bordered table-striped dataTable dtr-inline" id="${chartsData[key]['name']}_key">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Value</th>
<th>Date</th>
</tr>
</thead>
<tbody>`;
let tableData = chartsData[key]['tableData'];
for (const len in tableData) {
cardhtml += `<tr><td>${len}</td>
<td>${chartsData[key]['name']}</td>
<td>${tableData[len]['Value']}</td>
<td>${tableData[len]['Time']}</td></tr>`;
}
cardhtml += `</tbody></table></div></div>
</div>
</div>
</div>`;
setTimeout(function(){
$(`#${chartsData[key]['name']}_key`).DataTable({
"responsive": true, "lengthChange": false, "autoWidth": false,
"buttons": ["csv", "excel", "pdf", "print"]
}).buttons().container().appendTo(`#${chartsData[key]['name']}_key_wrapper .col-md-6:eq(0)`);
}, 500);
}
$('.measuringPointsTable').append(cardhtml);
}
const createCategoryGraph = (graph_name, graphData, type) => {
for (const key in graphData) {
if(graph_name == graphData[key]['name']) {
createAmChartCategory(root, graphData[key]['amData'], true, graph_name, type);
return false;
}
}
}
//historic data end
if(localStorage.getItem('graphData')) {
let graphData = JSON.parse(localStorage.getItem('graphData'));
let graphType = localStorage.getItem('graphType');
let graph_name = localStorage.getItem('graph_name');
if(graphType == 'production') {
createCategoryGraph(graph_name, graphData, 'single');
} else if(graphType == 'mixed') {
createCategoryGraph(graph_name, graphData, 'double');
} else if(graphType == 'energy') {
createAmChart(root, graphData, false);
createTable(graphData);
}
}
</script>
</body>
</html>