Blame view

chart.php 2.24 KB
cf76164e6   Ting Chan   20190709
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
  <!DOCTYPE html>
  <html>
  <?php
  	$filename = "/home/pi/Desktop/vAlert/rec/20180118130646_1001[0001]_541.csv";
  	$row = 0;
  	$i = 0;
  	if (($handle = fopen($filename, "r")) !== FALSE) {
          while (($data = fgetcsv($handle, 10000, ",")) !== FALSE) {
  			if($row == "2") $time = explode("e:",$data['0']); 
  			//find RecordLength
  			if($row == "3") $sec = explode(":",$data['0']); 	 
  			if($row >= "28"){
  				$array_z[] = $data['0'];
  				$array_x[] = $data['1'];
  				$array_y[] = $data['2'];
  			}
  			$row++;
          }
  		
          
      }
  	foreach($array_x as $key=>$value){
  		$radial[]="{x:".$key.",y:".$value."}";
  	}
  	foreach($array_z as $key=>$value){
  		$vertical[]="{x:".$key.",y:".$value."}";
  	}
  	foreach($array_y as $key=>$value){
  		$transverse[]="{x:".$key.",y:".$value."}";
  	}
  ?>
  <head>
  <script>
  	window.onload = function () {
  		var transverse = {
  			animationEnabled: true,
  			zoomEnabled: true,
  			title:{
  				text: "Transverse"
  			},
  			data: [{
  				type: "line",
  				dataPoints: [
  					<?php echo implode(",",$transverse); ?>
  				]
  			}],
  			axisY:{
  				includeZero: false
  			}
  		};
  		$("#chartContainer2").CanvasJSChart(transverse);
  		
  		var radial = {
  			animationEnabled: true,
  			zoomEnabled: true,
  			title:{
  				text: "Radial"
  			},
  			data: [{
  				type: "line",
  				color: "#FF0000",
  				dataPoints: [
  					<?php echo implode(",",$radial); ?>
  				]
  			}],
  			axisY:{
  				includeZero: false
  			}
  		};
  		$("#chartContainer").CanvasJSChart(radial);
  		
  		var vertical = {
  			animationEnabled: true,
  			zoomEnabled: true,
  			title:{
  				text: "Vertical"
  			},
  			data: [{
  				type: "line",
  				color: "#33FF33",
  				dataPoints: [
  					<?php echo implode(",",$vertical); ?>
  				]
  			}],
  			axisY:{
  				includeZero: false
  			}
  		};
  		$("#chartContainer1").CanvasJSChart(vertical);
  		
  		
  	}
  </script>
  	<h1>StartTime : <?php echo $time['1'];?> &nbsp;&nbsp;&nbsp;Record Length(sec) : <?php echo $sec['1'];?></h1>
  <div id="chartContainer2" style="height: 300px; width: 100%;"></div>
  <div id="chartContainer" style="height: 300px; width: 100%;"></div>
  <div id="chartContainer1" style="height: 300px; width: 100%;"></div>
  <script src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>
  <script src="https://canvasjs.com/assets/script/jquery.canvasjs.min.js"></script>
  </body>
  </html>