Blame view
project_sensor_chart_query.html
17.3 KB
eed3c9f67 first file |
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 |
<style type="text/css"> ::-webkit-input-placeholder { color:#B9B9B9; } input:-moz-placeholder { color:fff; } .select_box{ width: 200px; height: 34px; overflow: hidden; border: 1px solid #ccc; font-size: 16px;} </style> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> <!--[if IE]><script lang="javascript" type="text/javascript" src="../../js/excanvas.js"></script><![endif]--> <hr class="noscreen" /> <!-- Content (Right Column) --> <div id="content" class="box"> <h3 class="tit"><? echo gettext('歷史曲線圖查詢'); ?></h3> <fieldset> <legend><? echo gettext('查詢參數'); ?></legend> <form method="post" enctype="multipart/form-data" action="../ajax/query/project_sensor_chart_query_edit.php"> <table class="nostyle"> <tr> <td><? echo gettext('報表名稱'); ?></td> <td colspan="2" style="text-align:left"> <input class="input-text" type="text" name="query_name" required="required" value="<?=$query_name ?>"> </td> </tr> <tr> <td><? echo gettext('選擇儀器種類'); ?></td> <td colspan="4" style="text-align:left"> <? $name = explode(',',$array['0']['sensor_name']); $totoal_sensor = count($name); /*if(device_list != ""){ foreach($device_list as $key => $value){ $state = ($value['device_code'] == $array['0']['device_code']) ? 'checked=checked':''; if($value['device_code'] == $array['0']['device_code']) { $chart_title = $value['device_name']; } echo "<input type='radio' name='device_code' value='".$value['device_code']."' ".$state." />".$value['device_name']; $sensor_name = $Device->get_sensor_data($_GET['project_number'],$value['device_code']); foreach($sensor_name as $k => $v){ if($value['device_code'] == $array['0']['device_code']) { $checked = (in_array($v['sensor_id'], $name)) ? 'checked':''; echo "<span class='sensor_name ".$value['device_code']."' ><input type='checkbox' name='".$value['device_code']."[]' style='margin:5px' value='".$v['sensor_id']."' ".$checked.">".$v['sensor_id']."</span>"; }else{ echo "<span class='sensor_name ".$value['device_code']."' style='display:none'><input type='checkbox' name='".$value['device_code']."[]' style='margin:5px' value='".$v['sensor_id']."' checked>".$v['sensor_id']."</span>"; } } echo "<br>"; } }*/ if($device_list != ""){ echo "<select name='device_code' id='select_option' class='select_box'>"; foreach($device_list as $key => $value){ if($value['device_code'] == $array['0']['device_code']) { $chart_title = $value['device_name']; } $state = ($value['device_code'] == $array['0']['device_code']) ? 'selected':''; echo "<option value='".$value['device_code']."'".$state .">".$value['device_name']."</option>"; } echo "</select>"; echo "<div style='border-width: 1px;border-style:solid;width:350px;height: 100px;display: -webkit-inline-box;float: right;overflow-y:auto;'>"; foreach($device_list as $key => $value){ $sensor_name = $Device->get_sensor_data($_GET['project_number'],$value['device_code']); foreach($sensor_name as $k => $v){ if($value['device_code'] == $array['0']['device_code']) { $checked = (in_array($v['sensor_id'], $name)) ? 'checked':''; echo "<span class='sensor_name ".$value['device_code']."' ><input type='checkbox' name='".$value['device_code']."[]' style='margin:5px' value='".$v['sensor_id']."' ".$checked.">".$v['sensor_id']."</span>"; }else{ echo "<span class='sensor_name ".$value['device_code']."' style='display:none'><input type='checkbox' name='".$value['device_code']."[]' style='margin:5px' value='".$v['sensor_id']."' checked>".$v['sensor_id']."</span>"; } } } echo "</div>"; } ?> </td> </tr> <tr> <td><? echo gettext('設定X軸間距'); ?></td> <td colspan="2" style="text-align:left"> <input class="input-text" type="text" name="x_tickInterval" value="<?=$array['0']['x_tickInterval']?>"> </td> </tr> <tr> <td><? echo gettext('設定Y軸間距'); ?></td> <td colspan="2" style="text-align:left"> <input class="input-text" type="text" name="y_tickInterval" value="<?=$array['0']['y_tickInterval'] ?>"> </td> </tr> <tr> <td><? echo gettext('設定Y軸最大值'); ?></td> <td colspan="2" style="text-align:left"> <input class="input-text" type="text" name="y_max" value="<?=$array['0']['y_max'] ?>"> </td> </tr> <tr> <td><? echo gettext('設定Y軸最小值'); ?></td> <td colspan="2" style="text-align:left"> <input class="input-text" type="text" name="y_min" value="<?=$array['0']['y_min'] ?>"> </td> <td><? echo gettext('查詢圖表類型'); ?></td> <td style="text-align:left"> <select name="chart_type" class='select_box'> <?php foreach($chart_type as $key =>$value){ ?> <option value="<?=$key?>" <? echo ($array[0]['chart_type'] == $key) ? "selected":""; ?>><?php echo $value ?></option> <?php } ?> </select> </td> </tr> <tr> <td><? echo gettext('查詢起始日'); ?></td> <td><input class="date input-text" type="date" name="query_date_start" required="required" value="<? echo date('Y-m-d',$array['0']['query_date_start']); ?>"></td> <td><? echo gettext('查詢終止日'); ?></td> <td><input class="date input-text" type="date" name="query_date_end" required="required" value="<? echo date('Y-m-d',$array['0']['query_date_end']); ?>"></td> <td class="t-right"> <input type="submit" class="input-submit buttonblue" value="<? echo gettext('更改'); ?>" /> <a href="<?=INDEX ?>sanlien/ajax/query/project_chart_del.php?project_number=<?=$_GET['project_number'] ?>&id=<?=$_GET['id'] ?>"><input type="button" class="input-submit buttonred" value="<? echo gettext('刪除'); ?>" /></a> </td> </tr> </table> <input type="hidden" name="creater" value="<?=$_SESSION['user']['manager'] ?>" /> <input type="hidden" name="project_code" value="<?=$_GET['project_number'] ?>" /> <input type="hidden" name="id" value="<?=$_GET['id'] ?>" /> </form> </fieldset> <h3 class="tit"><? echo gettext('歷史曲線圖'); ?></h3> <input type="button" id="buttonPrint" class="buttonred" value="<? echo gettext('列印曲線圖'); ?>"/> <select id="ExportOption" class="select_box" > <option value="PNG">PNG Image</option> <option value="JPEG">JPEG Image</option> <option value="PDF">PDF Document</option> <option value="SVG">SVG Vector Image</option> </select> <input type="button" id="buttonExport" class="buttongreen" value="<? echo gettext('匯出檔案'); ?>"/> <?php switch($array[0]['chart_type']){ case "0": if($device_load != ""){ foreach($device_load as $key => $value){ //echo date('Y-m-d H:i',$value['date'])."|".$value['date']."<br>"; $date_xAxis[] = "'".date('Y-m-d H:i',$value['date'])."'"; $device_date[date('Y-m-d H:i',$value['date'])][$value['name']] = ($value['formula_val'] != "") ? number_format($value['formula_val'],2,".",""):'null'; } $xAxis = implode(',',array_unique($date_xAxis)); //列軸時間換算 //將sensor的值 存為陣列 foreach($device_date as $key => $value){ foreach($name as $k => $v){ $device_name_1[$v][] = ($value[$v] != "") ? $value[$v]:'null'; } } //解析sensor的陣列 提供給圖內的查詢 $i = 0; foreach($device_name_1 as $key => $value){ if(in_array($key,$name)){ $Y_Axisp[] = "{name: '".$key."', marker: {symbol: '".$chart_symbol[$i]."'}, data: [".implode(',',$value)."]}"; $i++; } } $series = implode(',',$Y_Axisp); //值的時間換算 $unit = "'".$array['0']['unit']."'"; }else{ echo gettext('查詢內容不正確'); } $range = implode(',',$alert_range); $total_number = count($date_xAxis); $x_tickInterval = ($array['0']['x_tickInterval'] != "") ? ",tickInterval:".round($total_number/$array['0']['x_tickInterval']/$totoal_sensor):""; $y_tickInterval = ($array['0']['y_tickInterval'] != "") ? ",tickInterval:".$array['0']['y_tickInterval']:""; $y_max = ($array['0']['y_max'] != "") ? ",max:".$array['0']['y_max']:""; $y_min = ($array['0']['y_min'] != "") ? ",min:".$array['0']['y_min']:""; break; case "1": //print_r($device_load); $date_xAxis = implode("','",$name); $xAxis = "'".$date_xAxis."'"; //列軸時間換算 foreach($device_load as $key => $value){ $device_date[date('Y-m-d H:i',$value['date'])][$value['name']] = ($value['formula_val'] != "") ? number_format($value['formula_val'],2,'.',''):'null'; } foreach($device_date as $key => $value){ $totoal_number = 0; ksort($value); foreach($name as $k => $v){ $totoal_number += ($value[$v] != "") ? $value[$v]:0; $device_name_1[$key][] = $totoal_number; } } $i = 0; foreach($device_name_1 as $key => $value){ $Y_Axisp[] = "{name: '".$key."', marker: {symbol: '".$chart_symbol[$i]."'}, data: [".implode(',',$value)."]}"; $i++; } $series = implode(',',$Y_Axisp); //值的時間換算 $unit = "'".$device_name['0']['unit']."'"; break; } ?> <script type="text/javascript"> $(function () { var chart = new Highcharts.Chart({ chart: { renderTo: 'container', type: 'spline', zoomType: 'xy' }, title: { text: '<?php echo $chart_title; ?>' }, xAxis: { categories: [<?php echo $xAxis; ?>] <?php echo $x_tickInterval; ?> }, yAxis: { title: { text: <?php echo $unit; ?> }, plotLines: [{ value: <?php echo ($device_name[0]['top_alert'] != "") ? $device_name[0]['top_alert']:0; ?>, color: 'blue', width: 2, label: { text: 'T-WARRING:<?php echo ($device_name[0]['top_alert'] != "") ? $device_name[0]['top_alert']:0; ?>', align: 'left', style: { color: 'black' } } },{ value: <?php echo ($device_name[0]['down_alert'] != "") ? $device_name[0]['down_alert']:0; ?>, color: 'blue', width: 2, label: { text: 'B-WARRING:<?php echo ($device_name[0]['down_alert'] != "") ? $device_name[0]['down_alert']:0; ?>', align: 'left', style: { color: 'black' } } },{ value: <?php echo ($device_name[0]['top_active'] != "") ? $device_name[0]['top_active']:0; ?>, color: 'red', width: 2, label: { text: 'T-ACTION:<?php echo ($device_name[0]['top_active'] != "") ? $device_name[0]['top_active']:0; ?>', align: 'left', style: { color: 'gray' } } },{ value: <?php echo ($device_name[0]['down_active'] != "") ? $device_name[0]['down_active']:0; ?>, color: 'red', width: 2, label: { text: 'B-ACTION:<?php echo ($device_name[0]['down_active'] != "") ? $device_name[0]['down_active']:0; ?>', align: 'left', style: { color: 'gray' } } }], labels: { formatter: function() { return this.value } } <?php echo $y_tickInterval.$y_max.$y_min; ?> }, tooltip: { crosshairs: true, shared: true }, plotOptions: { spline: { marker: { radius: 4, lineColor: '#666666', lineWidth: 1 } } }, series: [<?php echo $series; ?>], navigation: { buttonOptions: { enabled: false } } }); $('#buttonExport').click(function() { var e = document.getElementById("ExportOption"); var ExportAs = e.options[e.selectedIndex].value; if(ExportAs == 'PNG') { chart.exportChart({type: 'image/png', filename: 'my-png'}, {subtitle: {text:''}}); } if(ExportAs == 'JPEG') { chart.exportChart({type: 'image/jpeg', filename: 'my-jpg'}, {subtitle: {text:''}}); } if(ExportAs == 'PDF') { chart.exportChart({type: 'application/pdf', filename: 'my-pdf'}, {subtitle: {text:''}}); } if(ExportAs == 'SVG') { chart.exportChart({type: 'image/svg+xml', filename: 'my-svg'}, {subtitle: {text:''}}); } }); $('#buttonPrint').click(function() { chart.setTitle(null, { text: ' ' }); chart.print(); chart.setTitle(null, { text: '' }); }); }); </script> <script src="../gui/js/chart/highcharts.js"></script> <script src="../gui/js/chart/exporting.js"></script> <script> $("#select_option").change(function (){ var device_code = $(this).val(); $('.sensor_name').hide(); $('.'+device_code).show(); }); </script> <div class="table" id='block'> <div id="container" style="min-width: 400px; height: 600px; margin: 0 auto"></div> </div> </div> </div> <!-- /content --> </div> <!-- /cols --> |