-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsumption graph.js
123 lines (118 loc) · 4.21 KB
/
consumption graph.js
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
var machine_type = '{{ machine_type|json_encode()|raw }}';
mApp.block("#graph_fuel_sweeper", {
overlayColor: "#575962",
state: "brand",
opacity: .1
});
mApp.block("#graph_materials_spreader", {
overlayColor: "#575962",
state: "brand",
opacity: .1
});
$.ajax({
url:'{{ path('dashboard_graphic') }}',
type: "POST",
dataType: "json",
async: true,
success: function (data)
{
if(machine_type.includes("Spreader") || machine_type.includes("Sprayer")){
spreaderGraph(data['spreader']);
mApp.unblock("#graph_materials_spreader");
}
{# if (machine_type.includes("Sweeper")){
sweeperGraph(data['sweeper']);
mApp.unblock("#graph_fuel_sweeper");
} #}
},
error: function (data)
{
console.log("Error loading graphs");
}
});
function spreaderGraph(data)
{
var dati= JSON.parse(data);
var materiale= dati['material'];
var liquido= dati['liquid'];
var e = [
[1, materiale[0]],
[2, materiale[1]],
[3, materiale[2]],
[4, materiale[3]],
[5, materiale[4]],
[6, materiale[5]],
[7, materiale[6]],
[8, materiale[7]],
[9, materiale[8]],
[10, materiale[9]]
];
var o = [
[1, liquido[0]],
[2, liquido[1]],
[3, liquido[2]],
[4, liquido[3]],
[5, liquido[4]],
[6, liquido[5]],
[7, liquido[6]],
[8, liquido[7]],
[9, liquido[8]],
[10,liquido[9]]
];
$.plot($("#graph_materials_spreader"), [
{
data: e,
label: "Salt(kg)",
lines: {
lineWidth: 1
},
shadowSize: 0
}, {
data: o,
label: "Liquid(kg)",
lines: {
lineWidth: 1
},
shadowSize: 0
}
], {
series: {
lines: {
show: !0,
lineWidth: 2,
fill: !0,
fillColor: {
colors: [{
opacity: .05
}, {
opacity: .01
}]
}
},
points: {
show: !0,
radius: 3,
lineWidth: 1
},
shadowSize: 2
},
grid: {
hoverable: !0,
clickable: !0,
tickColor: "#eee",
borderColor: "#eee",
borderWidth: 1
},
colors: ["#d12610", "#37b7f3", "#52e136"],
xaxis: {
ticks: 11,
tickDecimals: 0,
tickColor: "#eee"
},
yaxis: {
ticks: 11,
tickDecimals: 0,
tickColor: "#eee"
}
});
}