-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcranks_mostrar.js
More file actions
executable file
·196 lines (181 loc) · 4.3 KB
/
Copy pathcranks_mostrar.js
File metadata and controls
executable file
·196 lines (181 loc) · 4.3 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
var grafica;
var datosGrafVol=[];
var datosGrafAmp=[];
var graficaDoble;
function cargaJS(){
//alert(JSON.stringify(dataVoltajeMostrar, "", " "));
$("#btn-sensor").attr("sensor", 1);
//selecciono grafica a mostrar
if(cranksSelec.length == 1){
traerDatosDoble(cranksSelec[0]);
crearGrafDoble();
}else{
crearGraf();
}
}
function rompoJS(){
grafica = null;
}
/* DIBUJO GRAFICA */
var colorLinea=["#fce94f","#13E2E0","#73d216", "#FA1717", "#EC96FE"];
var j = cranksSelec.length-1;
for (var i = 0; i <cranksSelec.length; i++) {
$("#cranks-iconos").append('<span id="crank-'+i+'" class="glyph-icon flaticon-graphic cranks-iconos" style="color:'+colorLinea[i]+'">'+parseInt(i+1)+'</span>');
$('#crank-'+[i]).attr("indice",j);
$('#crank-'+[i]).click(function(){
$('#crank-observacion').text(cranksObservaciones[$(this).attr("indice")]);
});
j--;
}
function crearGraf(){
//creo la grafica
grafica = new CanvasJS.Chart("graf-cranks",{
theme: 'cranks',
width:910,
height:365,
zoomEnabled: true,
title:{
text: ""
},
animationEnabled: false,
axisX:{
},
axisY :{
includeZero:false
},
ToolTip: {
enabled: false
},
//hola mami
data: datosGrafica(colorLinea)
});
grafica.render();
}
function datosGrafica(colorLinea){
/* traer Cranks */
var enviarDatos;
$.ajax({
url: 'cranks_data.php?accion=traerCranksDatos',
type: 'post',
async: false,
data:{
id_avion: id_avion
,sensor: $("#btn-sensor").attr("sensor")
,cranksSelec: cranksSelec
},
success: function (datos) {
//parseo nuevos datos
var crank = JSON.parse(datos);
vector=[];
for (var i=0; i<crank.length; i++) {
var crank = JSON.parse(datos);
for (var i=0; i<crank.length; i++) {
puntos = crank[i].puntos;
datos={};
datos.type="spline";
datos.markerSize=0,
datos.lineThickness=1.5;
datos.dataPoints= puntos;
datos.color=colorLinea[i];
vector.push(datos);
}
}
vector.push(datos);
enviarDatos= vector;
}
});
return enviarDatos;
}
function crearGrafDoble(){
//creo la grafica
graficaDoble = new CanvasJS.Chart("graf-cranks",
{
theme: 'voltaje',
width:910,
height:365,
zoomEnabled: true,
title:{
text: ""
},
animationEnabled: false,
axisX:{
valueFormatString: "mm:ss",
},
axisY :{
title: "AMP",
titleFontFamily:"lato",
titleFontWeight: "bold",
titleFontSize: 15,
titleFontColor: "#14E9FF",
labelFontFamily: "lato",
labelFontWeight: "bold",
labelFontSize: 12,
labelFontColor: "#14E9FF",
includeZero:false
},
axisY2 :{
title: "VOLT",
titleFontFamily:"lato",
titleFontWeight: "bold",
titleFontSize: 15,
titleFontColor: "#14E900",
labelFontFamily: "lato",
labelFontWeight: "bold",
labelFontSize: 12,
labelFontColor: "#14E900",
includeZero:false
},
ToolTip: {
enabled: false
},
data: [
{
type: "spline",
color: "#14E9FF",
dataPoints: datosGrafAmp,
markerSize: "0"
},
{
type: "spline",
color: "#14E900",
axisYType: "secondary",
dataPoints: datosGrafVol,
markerSize: "0"
}
]
});
}
function traerDatosDoble(id_rec) {
//console.log(JSON.stringify(valores, "", " "));
$.ajax({
url: 'cranks_data.php?accion=traerDatosDoble',
type: 'post',
data: {
id_rec : id_rec
},
success: function (datos) {
//console.log("Se guardo Ok: " + datos); //para debug de como va el arreglo
var datos = JSON.parse(datos);
for (var i=0; i<datos.length; i++) {
sensores= JSON.parse(datos[i].sensores);
datosGrafVol.push({x: new Date((datos[i].fyh+"."+datos[i].mseg)), y: sensores.vol});
datosGrafAmp.push({x: new Date((datos[i].fyh+"."+datos[i].mseg)), y: sensores.amp});
}
graficaDoble.render();
}
});
}
/* DIBUJO GRAFICA */
$('#btn-sensor').click(function(){
if($("#btn-sensor").attr("sensor") == 1){
$("#btn-sensor").attr("sensor", 2);
$("#btn-sensor").text('Amp');
$("#btn-sensor").css('background-color','#13E2E0');
}else{
$("#btn-sensor").attr("sensor", 1);
$("#btn-sensor").text('Volt');
$("#btn-sensor").css('background-color','#73d216');
}
crearGraf();
});
cargaJS();