web_gnuplot のソースリスト
001 <!-- -*- coding:euc-jp -*- --> 002 003 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 004 <html lang="ja"> 005 006 <head> 007 <META HTTP-EQUIV = "Content-Type" CONTENT = "text/html; charset=EUC-JP"> 008 <META http-equiv="Pragma" content="no-cache"> 009 <META http-equiv="Cache-Control" content="no-cache"> 010 <META http-equiv="Expires" content="0"> 011 <meta http-equiv="Content-Script-Type" content="text/javascript"> 012 <link rel="stylesheet" href="../../../stylesheet.css" type="text/css"> 013 <TITLE>webを使った gnuplot グラフ作成</TITLE> 014 <STYLE TYPE="text/css"> 015 <!-- 016 BLOCKQUOTE {margin:3px 20px 5px 100px} 017 .list {margin:4px 20px 4px 20px} 018 .enumerate {margin:7px 40px 7px 50px} 019 .CommandName {font-size:12pt; color:#1F6f1F} 020 .discriptin {padding-bottom : 20px} 021 a.help:link {color:#00FFFF;text-decoration:none} 022 a.help:visited {color:#00FFFF;text-decoration:none} 023 a.help:hover {color:#ffffff;text-decoration:none} 024 --> 025 </STYLE> 026 </HEAD> 027 028 029 <body class="frame"> 030 031 <?PHP 032 mb_http_output("EUC_JP"); 033 mb_internal_encoding("EUC_JP"); 034 ob_start("mb_output_handler"); 035 $side_webgnuplot=TRUE; 036 include "../../../head_menu.php"; 037 include "../begin_side_menu_graph.php"; 038 ob_end_flush(); 039 ?> 040 041 <div class="page_top"> 042 043 <div class="path"> 044 <span class="parent"><a href="../../index.html">コンピューター</a></span> 045 <span class="parent"><a href="../index.php">グラフ作成</a></span> 046 <span class="self">web_gnuplot</span> 047 </div> 048 049 <h1 class="title">web_gnuplot<span class="subtitle">ブラウザから gnuplot の実行</span></h1> 050 051 </div> 052 053 <hr> 054 055 <!-- ========================================================= --> 056 <h2 class="body" id="introduction">webを使ったグラフ作成ツール</h2> 057 <!-- ========================================================= --> 058 059 <P>webのインターフェースを使ったグラフ作成ツールです.グラフはgnuplotで作成します.</P> 060 061 <p>簡単な例を<a href="help/example_1.png">ここ</a>に載せておきます.<a href="help/example_1.png">この例</a>のように記述して,プロットボタンをクリックするとグラフができます.いろいろな機能がありますので,使ってください.</p> 062 063 <p>グラフデータ入力画面の項目をクリックするとヘルプがあらわれます.作図するときの参考にしてください.</p> 064 065 <p>また,<a href="source.php">ソースリスト</a>を載せておきます.汚いプログラムですが,何かの参考になると思います.</p> 066 067 <!-- --------------------------------------------------------- --> 068 <h3 class="body" id="input_form">グラフデータ入力画面</h3> 069 <!-- --------------------------------------------------------- --> 070 071 <?PHP 072 if(isset($_GET["status"]) && $_GET["status"]=="clear"){ 073 setcookie("webgp_data[plot_data]","",0); 074 }else{ 075 $_GET["status"]="keep"; 076 } 077 078 $x_low=array("1列","2列","3列","4列","5列","6列","7列","8列","9列"); 079 $y_low=array("1列","2列","3列","4列","5列","6列","7列","8列","9列"); 080 $line=array("","折線","スプライン","指数","対数","定数","1次関数","2次関数","3次関数","4次関数","5次関数","6次関数", 081 "7次関数","8次関数","9次関数", 082 "1次関数(原点通過)","2次関数(原点通過)","3次関数(原点通過)", 083 "4次関数(原点通過)","5次関数(原点通過)","6次関数(原点通過)", 084 "7次関数(原点通過)","8次関数(原点通過)","9次関数(原点通過)"); 085 $g_file=array("emf","eps","png","png(透明)"); 086 ?> 087 088 <FORM method="POST" action="mk_graph.php"> 089 <TABLE border="1" style="background-color:indianred;"> 090 <TBODY> 091 092 <!-- ---------- タイトル ------------- --> 093 <TD><a href="help/title.php" class="help">タイトル</a></TD> 094 <TD><INPUT size="60" type="text" name="title" <?php 095 if(isset($_COOKIE['webgp_data']['title'])){ 096 print "value=\"".$_COOKIE['webgp_data']['title']."\"> \n"; 097 }else{ 098 print "> \n"; 099 }?> 100 </TR> 101 <TR> 102 103 <!-- ---------- x軸 ------------- --> 104 <TR> 105 <TD><a href="help/x_axis.php" class="help">x軸</a></TD> 106 <TD>最小 <INPUT size="8" type="text" name="x_min" <?PHP 107 if(isset($_COOKIE['webgp_data']['x_min'])){ 108 print "value=\"".$_COOKIE['webgp_data']['x_min']."\">\n"; 109 }else{ 110 print ">\n"; 111 } 112 print " 最大 <INPUT size=\"8\" type=\"text\" name=\"x_max\""; 113 if(isset($_COOKIE['webgp_data']['x_max'])){ 114 print "value=\"".$_COOKIE['webgp_data']['x_max']."\">\n"; 115 }else{ 116 print ">\n"; 117 } 118 119 if(isset($_COOKIE['webgp_data']['x_axis'])){ 120 print '<INPUT type="checkbox" name="x_axis" value="checked"'.$_COOKIE['webgp_data']['x_axis'].">対数\n"; 121 }else{ 122 print '<INPUT type="checkbox" name="x_axis" value="checked"'.">対数\n"; 123 } 124 125 print " ラベル <INPUT size=\"15\" type=\"text\" name=\"x_label\""; 126 if(isset($_COOKIE['webgp_data']['x_label'])){ 127 print "value=\"".$_COOKIE['webgp_data']['x_label']."\">\n"; 128 }else{ 129 print ">\n"; 130 } 131 ?> 132 </TD> 133 </TR> 134 135 <!-- ---------- y軸 ------------- --> 136 <TR> 137 <TD><a href="/yamamoto/comp/graph/web_gnuplot/help/y_axis.php" class="help">y軸</a></TD> 138 <TD>最小 <INPUT size="8" type="text" name="y_min" <?PHP 139 if(isset($_COOKIE['webgp_data']['y_min'])){ 140 print "value=\"".$_COOKIE['webgp_data']['y_min']."\">\n"; 141 }else{ 142 print ">\n"; 143 } 144 print " 最大 <INPUT size=\"8\" type=\"text\" name=\"y_max\""; 145 if(isset($_COOKIE['webgp_data']['y_max'])){ 146 print "value=\"".$_COOKIE['webgp_data']['y_max']."\">\n"; 147 }else{ 148 print ">\n"; 149 } 150 if(isset($_COOKIE['webgp_data']['y_axis'])){ 151 print '<INPUT type="checkbox" name="y_axis" value="checked"'.$_COOKIE['webgp_data']['y_axis'].">対数\n"; 152 }else{ 153 print '<INPUT type="checkbox" name="y_axis" value="checked"'.">対数\n"; 154 } 155 156 print " ラベル <INPUT size=\"15\" type=\"text\" name=\"y_label\""; 157 if(isset($_COOKIE['webgp_data']['y_label'])){ 158 print "value=\"".$_COOKIE['webgp_data']['y_label']."\">\n"; 159 }else{ 160 print ">\n"; 161 } 162 ?> 163 </TD> 164 </TR> 165 166 <!-- ---------- 表示 ------------- --> 167 <TR> 168 <TD><a href="/yamamoto/comp/graph/web_gnuplot/help/hyoji.php" class="help">表示</a></TD> 169 <TD>グリッド <?PHP 170 if(isset($_COOKIE['webgp_data']['x_grid'])){ 171 print "<INPUT type=\"checkbox\" name=\"x_grid\" value=\"checked\" ". 172 $_COOKIE['webgp_data']['x_grid'].">x\n"; 173 }else{ 174 print "<INPUT type=\"checkbox\" name=\"x_grid\" value=\"checked\" ".">x\n"; 175 } 176 177 if(isset($_COOKIE['webgp_data']['y_grid'])){ 178 print "<INPUT type=\"checkbox\" name=\"y_grid\" value=\"checked\" ". 179 $_COOKIE['webgp_data']['y_grid'].">y\n"; 180 }else{ 181 print "<INPUT type=\"checkbox\" name=\"y_grid\" value=\"checked\" ".">y\n"; 182 } 183 184 print " \n"; 185 if(isset($_COOKIE['webgp_data']['monochrome'])){ 186 print '<INPUT type="checkbox" name="monochrome" value="checked" '. 187 $_COOKIE['webgp_data']['monochrome'].">白黒\n"; 188 }else{ 189 print '<INPUT type="checkbox" name="monochrome" value="checked" '.">白黒\n"; 190 } 191 192 ?> 193 194 195 </TR> 196 197 <!-- ---------- xデータ ------------- --> 198 <TR> 199 <TD><a href="/yamamoto/comp/graph/web_gnuplot/help/x_data.php" class="help">xデータ</a></TD> 200 <TD><?PHP 201 if(isset($_COOKIE['webgp_data']['x_row'])){ 202 set_select("x_row",$x_low,$_COOKIE['webgp_data']['x_row']); 203 }else{ 204 set_select("x_row",$x_low,0); 205 } 206 ?> 207 </TD> 208 </TR> 209 210 <!-- ---------- yデータ ------------- --> 211 <TR> 212 <TD><a href="/yamamoto/comp/graph/web_gnuplot/help/y_data.php" class="help">yデータ</a></TD> 213 <TD><?PHP 214 if(isset($_COOKIE['webgp_data']['y_row'])){ 215 set_select("y_row",$y_low,$_COOKIE['webgp_data']['y_row']); 216 }else{ 217 set_select("y_row",$y_low,1); 218 } 219 220 print " \n"; 221 ?> 222 ポイントサイズ <INPUT size="4" type="text" name="psize" <?PHP 223 if(isset($_COOKIE['webgp_data']['psize'])){ 224 print "value=\"".$_COOKIE['webgp_data']['psize']."\">\n"; 225 }else{ 226 print "value=1.0>\n"; 227 } 228 229 print " ライン\n"; 230 231 if(isset($_COOKIE['webgp_data']['line'])){ 232 set_select("line",$line,$_COOKIE['webgp_data']['line']); 233 }else{ 234 set_select("line",$line,0); 235 } 236 ?> 237 </TD> 238 </TR> 239 240 <!-- ---------- データエリア ------------- --> 241 <TR> 242 <TD colspan=2><a href="help/data_area.php" class="help">データエリア</a> <INPUT TYPE=button VALUE="データクリア" onClick="location.href='/yamamoto/comp/graph/web_gnuplot/index.php?status=clear'"></TD> 243 </TR> 244 <TR> 245 <TD colspan=2><textarea name="plot_data" cols=60 rows=20><?PHP 246 if(isset($_COOKIE['webgp_data']['plot_data']) && $_GET['status']!="clear"){ 247 print "\n".$_COOKIE['webgp_data']['plot_data']."\n"; 248 } 249 ?></textarea></TD> 250 </TR> 251 <TR> 252 253 254 <!-- ---------- 描画 ------------- --> 255 <TR> 256 <TD><a href="/yamamoto/comp/graph/web_gnuplot/help/byoga.php" class="help">描画</a></TD> 257 258 <TD> 259 <?PHP 260 print "ファイル "; 261 if(isset($_COOKIE['webgp_data']['g_file'])){ 262 set_select("g_file",$g_file,$_COOKIE['webgp_data']['g_file']); 263 }else{ 264 set_select("g_file",$g_file,0); 265 } 266 267 ?> 268 269 <INPUT TYPE="submit" value="プロット"> 270 </TD> 271 </TR> 272 273 </TBODY> 274 </TABLE> 275 </FORM> 276 277 <!-- ---------------- 関数 ----------------------- --> 278 <?php 279 //================================================================= 280 // setting of radio button 281 // 1st argument:name 282 // 2nd argument:label 283 // 3rd argument:checked number 284 //================================================================= 285 function set_radio($name,$label,$on){ 286 for($i=0; isset($label[$i]); $i++){ 287 if($i==$on){ 288 print "<INPUT type=\"radio\" name=\"".$name."\" value=\"".$i. 289 "\" checked>".$label[$i]."\n"; 290 }else{ 291 print "<INPUT type=\"radio\" name=\"".$name."\" value=\"".$i. 292 "\">".$label[$i]."\n"; 293 } 294 } 295 } 296 297 //================================================================= 298 // setting of select 299 // 1st argument:name 300 // 2nd argument:label 301 // 3rd argument:selected number 302 //================================================================= 303 function set_select($name,$label,$on=1){ 304 print "<select name=\"".$name."\">\n"; 305 for($i=0; isset($label[$i]); $i++){ 306 if($i==$on){ 307 print "<option value=".$i." selected>".$label[$i]."\n"; 308 }else{ 309 print "<option value=".$i.">".$label[$i]."\n"; 310 } 311 } 312 print "</select>\n"; 313 } 314 315 ?> 316 317 <!-- ---------------- 本文はここまで ---------------- --> 318 <?PHP 319 $show_counter=FALSE; 320 $show_update=TRUE; 321 include "../../../end_process.php"; 322 ?> 323 324 325 </BODY> 326 </HTML>
mk_grpaht.php のソースリスト
001 <!-- -*- coding:euc-jp -*- --> 002 003 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 004 <html lang="ja"> 005 006 <HEAD> 007 <META HTTP-EQUIV = "Content-Type" CONTENT = "text/html; charset=EUC-JP"> 008 <META http-equiv="Pragma" content="no-cache"> 009 <META http-equiv="Cache-Control" content="no-cache"> 010 <META http-equiv="Expires" content="0"> 011 <meta http-equiv="Content-Script-Type" content="text/javascript"> 012 <link rel="stylesheet" href="../../../stylesheet.css" type="text/css"> 013 <TITLE>グラフの作成</TITLE> 014 <STYLE TYPE="text/css"> 015 <!-- 016 h4 {margin-left:20px;} 017 p {margin-left:40px; margin-right:40px} 018 --> 019 </STYLE> 020 </HEAD> 021 022 <BODY class="frame"> 023 024 <?PHP 025 mb_http_output("EUC_JP"); 026 mb_internal_encoding("EUC_JP"); 027 ob_start("mb_output_handler"); 028 include "../../../head_menu.php"; 029 ob_end_flush(); 030 031 // ----------------- クッキーの設定 ---------------------------------- 032 $save_time=60*60*24; 033 SET_COOKIE("webgp_data", "title", $save_time); 034 SET_COOKIE("webgp_data", "x_min", $save_time); 035 SET_COOKIE("webgp_data", "x_max", $save_time); 036 SET_COOKIE("webgp_data", "x_axis", $save_time); 037 SET_COOKIE("webgp_data", "x_label", $save_time); 038 SET_COOKIE("webgp_data", "y_min", $save_time); 039 SET_COOKIE("webgp_data", "y_max", $save_time); 040 SET_COOKIE("webgp_data", "y_axis", $save_time); 041 SET_COOKIE("webgp_data", "y_label", $save_time); 042 SET_COOKIE("webgp_data", "x_grid", $save_time); 043 SET_COOKIE("webgp_data", "y_grid", $save_time); 044 SET_COOKIE("webgp_data", "color", $save_time); 045 SET_COOKIE("webgp_data", "x_row", $save_time); 046 SET_COOKIE("webgp_data", "y_row", $save_time); 047 SET_COOKIE("webgp_data", "y_withline", $save_time); 048 SET_COOKIE("webgp_data", "y_spline", $save_time); 049 SET_COOKIE("webgp_data", "y_exp", $save_time); 050 SET_COOKIE("webgp_data", "y_log", $save_time); 051 SET_COOKIE("webgp_data", "psize", $save_time); 052 SET_COOKIE("webgp_data", "line", $save_time); 053 SET_COOKIE("webgp_data", "plot_data", $save_time); 054 SET_COOKIE("webgp_data", "g_file", $save_time); 055 SET_COOKIE("webgp_data", "monochrome", $save_time); 056 057 058 //------------- 古いファイルの削除 --------------------------------------------- 059 $tmp_dir="tmp/"; 060 $handle = opendir($tmp_dir); 061 while(false !== ($file = readdir($handle))){ 062 if($file != "." && $file != ".." && $file != "data.txt" && $file != "gp_error.txt"){ 063 $file = $tmp_dir.$file; 064 $fst = stat($file); 065 $age = time()-$fst["mtime"]; 066 if(3600<$age)unlink($file); 067 } 068 } 069 070 // ----------------- パイプを開く ---------------------------------- 071 072 $fp=fopen("tmp/data.txt","w"); 073 fwrite($fp,$_POST["plot_data"]); 074 fclose($fp); 075 076 077 $error=0; 078 079 $descriptorspec = array( 080 0 => array("pipe", "r"), // stdin 081 1 => array("pipe", "w"), // stdout 082 2 => array("file", "tmp/gp_error.txt", "a") // stderr 083 ); 084 085 086 $gnuplot = proc_open('gnuplot', $descriptorspec, $pipes); 087 088 if ( ! is_resource($gnuplot) ) { 089 print "proc_open error\n"; 090 exit(1); 091 } 092 093 094 // ----------------- グラフ作成 ---------------------------------- 095 $stdout_file="tmp/stdout.txt"; 096 097 fwrite($pipes[0],"reset\n"); 098 fwrite($pipes[0],"set print \"".$stdout_file."\"\n"); 099 if(isset($_POST["monochrome"])){ 100 fwrite($pipes[0],"set terminal postscript eps enhanced monochrome dashed font 'CenturySchL-Roma,18'\n"); 101 }else{ 102 fwrite($pipes[0],"set terminal postscript eps enhanced solid color font 'CenturySchL-Roma,18'\n"); 103 } 104 fwrite($pipes[0],"set output \"tmp/graph.eps\"\n"); 105 fwrite($pipes[0],"unset key\n"); 106 fwrite($pipes[0],"set samples 2048\n"); 107 fwrite($pipes[0],"set tics scale 2,1\n"); 108 fwrite($pipes[0],"set style line 1 lt 4 lw 3 pt 7 ps ".$_POST["psize"]."\n"); 109 110 if(isset($_POST["title"])){ 111 fwrite($pipes[0],"set title \"".$_POST["title"]."\"\n"); 112 fwrite($pipes[0],"show title\n"); 113 } 114 115 if(isset($_POST["x_label"])){ 116 fwrite($pipes[0],"set xlabel \"".$_POST["x_label"]."\"\n"); 117 } 118 119 if(isset($_POST["y_label"])){ 120 fwrite($pipes[0],"set ylabel \"".$_POST["y_label"]."\"\n"); 121 } 122 123 if(isset($_POST["x_min"]) && isset($_POST["x_max"])){ 124 if($_POST["x_min"] < $_POST["x_max"]){ 125 fwrite($pipes[0],"set xrange [".$_POST["x_min"].":".$_POST["x_max"]."]\n"); 126 }else{ 127 $message[$error]="x軸:最大は,最小より大きくする必要があります."; 128 $error++; 129 } 130 } 131 132 if(isset($_POST["y_min"]) && isset($_POST["y_max"])){ 133 if($_POST["y_min"] < $_POST["y_max"]){ 134 fwrite($pipes[0],"set yrange [".$_POST["y_min"].":".$_POST["y_max"]."]\n"); 135 }else{ 136 $message[$error]="y軸:最大は,最小より大きくする必要があります."; 137 $error++; 138 } 139 } 140 141 if(isset($_POST["x_axis"])){ 142 if($_POST["x_min"]<=0){ 143 $message[$error]="x軸:対数目盛の場合,最小はゼロより大きくする必要があります."; 144 $error++; 145 }else{ 146 fwrite($pipes[0],"set logscale x\n"); 147 } 148 } 149 150 if(isset($_POST["y_axis"])){ 151 if($_POST["y_min"]<=0){ 152 $message[$error]="y軸:対数目盛の場合,最小はゼロより大きくする必要があります."; 153 $error++; 154 }else{ 155 fwrite($pipes[0],"set logscale y\n"); 156 } 157 } 158 159 if(isset($_POST['x_grid']) && $_POST['x_grid']=="checked"){ 160 fwrite($pipes[0],"set grid xtics mxtics\n"); 161 } 162 163 if(isset($_POST['y_grid']) && $_POST['y_grid']=="checked"){ 164 fwrite($pipes[0],"set grid ytics mytics\n"); 165 } 166 167 //------------- 最小自乗法 --------------------------------------------- 168 169 $xxx=$_POST["x_row"]+1; 170 $yyy=$_POST["y_row"]+1; 171 $x_y=$xxx.":".$yyy; 172 173 174 if(2 < $_POST["line"]){ 175 176 if($_POST["line"]==3){ 177 $fit_func="a*exp(b*x)"; 178 $para="a,b"; 179 }else if($_POST["line"]==4){ 180 $fit_func="a*log(b*x)"; 181 $para="a,b"; 182 }else if(4<$_POST["line"] && $_POST["line"]<15){ 183 $fit_func = "a0"; 184 $para = "a0"; 185 for($i=1; $i<=$_POST["line"]-5;$i++){ 186 if($i==1){ 187 $fit_func .= "+a".abs($i)."*x"; 188 }else{ 189 $fit_func .= "+a".abs($i)."*x**".abs($i); 190 } 191 $para .= ",a".abs($i); 192 } 193 }else if(14<$_POST["line"] && $_POST["line"]<24){ 194 $fit_func = "a1*x"; 195 $para = "a1"; 196 for($i=2; $i<=$_POST["line"]-14;$i++){ 197 $fit_func .= "+a".abs($i)."*x**".abs($i); 198 $para .= ",a".abs($i); 199 } 200 } 201 202 fwrite($pipes[0],"f(x)=".$fit_func."\n"); 203 fwrite($pipes[0],"fit f(x) \"tmp/data.txt\" using ".$x_y." via ".$para."\n"); 204 fwrite($pipes[0],"print ".$para."\n"); 205 } 206 207 //------------- グラフファイル作成 --------------------------------------------- 208 209 if($_POST["line"]!=1){ 210 fwrite($pipes[0],"plot \"tmp/data.txt\" using ".$x_y." with points ls 1"); 211 }else{ 212 fwrite($pipes[0],"plot \"tmp/data.txt\" using ".$x_y." with linespoints ls 1"); 213 } 214 215 if($_POST["line"]==2){ 216 fwrite($pipes[0],",\"tmp/data.txt\" using ".$x_y." smooth csplines with lines"); 217 }else if($_POST["line"]==3){ 218 fwrite($pipes[0],",f(x)"); 219 }else if($_POST["line"]==4){ 220 fwrite($pipes[0],",f(x)"); 221 }else if(4<$_POST["line"] && $_POST["line"]<23){ 222 fwrite($pipes[0],",f(x)"); 223 } 224 225 fwrite($pipes[0],"\n"); 226 227 //------------- グラフファイル作成 --------------------------------------------- 228 229 srand((double)microtime()*1000000); 230 $gf_name=rand(100000,999999); 231 232 $f_type="eps"; 233 $g_file="tmp/".$gf_name; 234 235 if(isset($_POST["monochrome"])){ 236 $term_set = "postscript eps enhanced monochrome dashed font 'CenturySchL-Roma,18'"; 237 }else{ 238 $term_set = "postscript eps enhanced solid color font 'CenturySchL-Roma,18'"; 239 } 240 241 fwrite($pipes[0],"set terminal ".$term_set."\n"); 242 fwrite($pipes[0],"set output \"".$g_file.".eps"."\"\n"); 243 fwrite($pipes[0],"replot\n"); 244 245 246 if(isset($_POST["monochrome"])){ 247 $term_set = "emf monochrome dashed enhanced font 'CenturySchL-Roma,18'"; 248 }else{ 249 $term_set = "emf color solid enhanced font 'CenturySchL-Roma,18'"; 250 } 251 252 fwrite($pipes[0],"set terminal ".$term_set."\n"); 253 fwrite($pipes[0],"set output \"".$g_file.".emf"."\"\n"); 254 fwrite($pipes[0],"replot\n"); 255 256 //------------- クローズ --------------------------------------------- 257 258 fclose($pipes[0]); 259 proc_close($gnuplot); 260 261 $sys_cmd = sprintf("convert -density 100 -units PixelsPerInch %s %s", $g_file.".eps", "tmp/graph.png"); 262 system ($sys_cmd); 263 264 if(isset($_POST["g_file"]) && $_POST["g_file"]==0){ 265 $f_type = "emf"; 266 $plot_file = $g_file.".".$f_type; 267 }else if(isset($_POST["g_file"]) && $_POST["g_file"]==1){ 268 $f_type = "eps"; 269 $plot_file = $g_file.".".$f_type; 270 }else if(isset($_POST["g_file"]) && $_POST["g_file"]==2){ 271 $f_type = "png"; 272 $plot_file = $g_file.".".$f_type; 273 $sys_cmd = sprintf("convert -density 600 -units PixelsPerInch %s %s", $g_file.".eps", $g_file.".png"); 274 system ($sys_cmd); 275 }else if(isset($_POST["g_file"]) && $_POST["g_file"]==3){ 276 $f_type = "png"; 277 $plot_file = $g_file.".".$f_type; 278 $sys_cmd = sprintf("convert -density 600 -units PixelsPerInch %s %s", $g_file.".eps", $g_file.".png"); 279 system ($sys_cmd); 280 } 281 282 283 284 //------------- ディスプレイ表示 --------------------------------------------- 285 286 print '<h4>グラフ</h4>'."\n"; 287 288 print "<p><a href=\"".$g_file.".".$f_type."\">グラフのファイル(".$f_type.")</a>ができましたので,右クリックによりダウンロードしてください.</p>\n"; 289 290 291 if($error == 0){ 292 print "<div style=\"width:640px;padding:10px 30px 30px 30px;margin:40px;background-color:#CEE0FF;\">\n"; 293 print "<div style=\"margin-top:0px;margin-left:20px;margin-bottom:10px;\">\n"; 294 print "<INPUT TYPE=button VALUE=\"グラフの修正\" onClick=\"location.href='/yamamoto/comp/graph/web_gnuplot/index.php'\">\n"; 295 print "</div>\n"; 296 print "<img src=\"tmp/graph.png\">\n"; 297 print "</div>\n"; 298 }else{ 299 print $error."個の入力にエラーがあります.<BR>\n"; 300 print "<ol>\n"; 301 foreach($message as $txt){ 302 print "<li>".$txt."</li><BR>\n"; 303 } 304 print "</ol>\n"; 305 } 306 307 //------------- フィッティングの結果表示 --------------------------------------------- 308 if(2<$_POST["line"]){ 309 $fh = fopen($stdout_file, "r"); 310 $fit_line = fgets($fh, 4096); 311 fclose($fh); 312 $fit = split(" ", $fit_line); 313 $p = split(",", $para); 314 print '<h4>フィッティング結果</h4>'."\n"; 315 print '<p>フィッティング関数は,</P>'; 316 print '<p><span style="padding-left:50px;color:red;">f(x)='.$fit_func."</span></P>"; 317 print "<p>です.フィッティングのパラメーターは次のようになります.</p>\n"; 318 $i=0; 319 foreach($fit as $value){ 320 print "<P style=\"padding-left:80px;color:red;\">".$p[$i]." = ".$value."</p>"; 321 $i++; 322 } 323 324 325 326 } 327 328 ?> 329 330 <!-- ---------------- 本文はここまで ---------------- --> 331 <?PHP 332 $show_counter=FALSE; 333 $show_update=TRUE; 334 include "../../../end_process.php"; 335 ?> 336 337 338 339 <!-- ---------------- 関数 ----------------------- --> 340 <?php 341 //================================================================= 342 // setting of radio button 343 // 1st argument:name 344 // 2nd argument:label 345 // 3rd argument:checked number 346 //================================================================= 347 function SET_COOKIE($cn,$arg,$time){ 348 if(isset($_POST[$arg])){ 349 setcookie("webgp_data[$arg]", $_POST[$arg], time()+$time); 350 } 351 }