web_gnuplot のソースリスト
001 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 002 <html lang="ja"> 003 004 <head> 005 <META HTTP-EQUIV = "Content-Type" CONTENT = "text/html; charset=EUC-JP"> 006 <META http-equiv="Pragma" content="no-cache"> 007 <META http-equiv="Cache-Control" content="no-cache"> 008 <META http-equiv="Expires" content="0"> 009 <meta http-equiv="Content-Script-Type" content="text/javascript"> 010 <link rel="stylesheet" href="../../../stylesheet.css" type="text/css"> 011 <TITLE>webを使った gnuplot グラフ作成</TITLE> 012 <STYLE TYPE="text/css"> 013 <!-- 014 BLOCKQUOTE {margin:3px 20px 5px 100px} 015 .list {margin:4px 20px 4px 20px} 016 .enumerate {margin:7px 40px 7px 50px} 017 .CommandName {font-size:12pt; color:#1F6f1F} 018 .discriptin {padding-bottom : 20px} 019 a.help:link {color:#00FFFF;text-decoration:none} 020 a.help:visited {color:#00FFFF;text-decoration:none} 021 a.help:hover {color:#ffffff;text-decoration:none} 022 --> 023 </STYLE> 024 </HEAD> 025 026 027 <body class="frame"> 028 029 <?PHP 030 mb_http_output("EUC_JP"); 031 mb_internal_encoding("EUC_JP"); 032 ob_start("mb_output_handler"); 033 $side_web_gnuplot=TRUE; 034 include "../../../head_menu.php"; 035 include "../begin_side_menu_gnuplot.php"; 036 ob_end_flush(); 037 ?> 038 039 <div class="page_top"> 040 041 <div class="path"> 042 <span class="parent"><a href="../../index.html">コンピューター</a></span> 043 <span class="parent"><a href="../about/index.php">gnuplot</a></span> 044 <span class="self">web_gnuplot</span> 045 </div> 046 047 <h1 class="title">web_gnuplot<span class="subtitle">ブラウザから gnuplot の実行</span></h1> 048 049 </div> 050 051 <hr> 052 053 <!-- ========================================================= --> 054 <h2 class="body" id="introduction">webを使ったグラフ作成ツール</h2> 055 <!-- ========================================================= --> 056 057 <P>webのインターフェースを使ったグラフ作成ツールです.グラフはgnuplotで作成します.</P> 058 059 <p>簡単な例を<a href="help/example_1.png">ここ</a>に載せておきます.<a href="help/example_1.png">この例</a>のように記述して,プロットボタンをクリックするとグラフができます.いろいろな機能がありますので,使ってください.</p> 060 061 <p>グラフデータ入力画面の項目をクリックするとヘルプがあらわれます.作図するときの参考にしてください.</p> 062 063 <p>また,<a href="source.php">ソースリスト</a>を載せておきます.汚いプログラムですが,何かの参考になると思います.</p> 064 065 <!-- --------------------------------------------------------- --> 066 <h3 class="body" id="input_form">グラフデータ入力画面</h3> 067 <!-- --------------------------------------------------------- --> 068 069 <?PHP 070 if(isset($_GET["status"]) && $_GET["status"]=="clear"){ 071 setcookie("webgp_data[plot_data]","",0); 072 }else{ 073 $_GET["status"]="keep"; 074 } 075 076 $x_low=array("1列","2列","3列","4列","5列","6列","7列","8列","9列"); 077 $y_low=array("1列","2列","3列","4列","5列","6列","7列","8列","9列"); 078 $line=array("","折線","スプライン","指数","対数","定数","1次関数","2次関数","3次関数","4次関数","5次関数","6次関数", 079 "7次関数","8次関数","9次関数", 080 "1次関数(原点通過)","2次関数(原点通過)","3次関数(原点通過)", 081 "4次関数(原点通過)","5次関数(原点通過)","6次関数(原点通過)", 082 "7次関数(原点通過)","8次関数(原点通過)","9次関数(原点通過)"); 083 $g_file=array("emf","eps","png","png(透明)"); 084 ?> 085 086 <FORM method="POST" action="mk_graph.php"> 087 <TABLE border="1" style="background-color:indianred;"> 088 <TBODY> 089 090 <!-- ---------- タイトル ------------- --> 091 <TD><a href="help/title.php" class="help">タイトル</a></TD> 092 <TD><INPUT size="60" type="text" name="title" <?php 093 if(isset($_COOKIE['webgp_data']['title'])){ 094 print "value=\"".$_COOKIE['webgp_data']['title']."\"> \n"; 095 }else{ 096 print "> \n"; 097 }?> 098 </TR> 099 <TR> 100 101 <!-- ---------- x軸 ------------- --> 102 <TR> 103 <TD><a href="help/x_axis.php" class="help">x軸</a></TD> 104 <TD>最小 <INPUT size="8" type="text" name="x_min" <?PHP 105 if(isset($_COOKIE['webgp_data']['x_min'])){ 106 print "value=\"".$_COOKIE['webgp_data']['x_min']."\">\n"; 107 }else{ 108 print ">\n"; 109 } 110 print " 最大 <INPUT size=\"8\" type=\"text\" name=\"x_max\""; 111 if(isset($_COOKIE['webgp_data']['x_max'])){ 112 print "value=\"".$_COOKIE['webgp_data']['x_max']."\">\n"; 113 }else{ 114 print ">\n"; 115 } 116 117 if(isset($_COOKIE['webgp_data']['x_axis'])){ 118 print '<INPUT type="checkbox" name="x_axis" value="checked"'.$_COOKIE['webgp_data']['x_axis'].">対数\n"; 119 }else{ 120 print '<INPUT type="checkbox" name="x_axis" value="checked"'.">対数\n"; 121 } 122 123 print " ラベル <INPUT size=\"15\" type=\"text\" name=\"x_label\""; 124 if(isset($_COOKIE['webgp_data']['x_label'])){ 125 print "value=\"".$_COOKIE['webgp_data']['x_label']."\">\n"; 126 }else{ 127 print ">\n"; 128 } 129 ?> 130 </TD> 131 </TR> 132 133 <!-- ---------- y軸 ------------- --> 134 <TR> 135 <TD><a href="/yamamoto/comp/graph/web_gnuplot/help/y_axis.php" class="help">y軸</a></TD> 136 <TD>最小 <INPUT size="8" type="text" name="y_min" <?PHP 137 if(isset($_COOKIE['webgp_data']['y_min'])){ 138 print "value=\"".$_COOKIE['webgp_data']['y_min']."\">\n"; 139 }else{ 140 print ">\n"; 141 } 142 print " 最大 <INPUT size=\"8\" type=\"text\" name=\"y_max\""; 143 if(isset($_COOKIE['webgp_data']['y_max'])){ 144 print "value=\"".$_COOKIE['webgp_data']['y_max']."\">\n"; 145 }else{ 146 print ">\n"; 147 } 148 if(isset($_COOKIE['webgp_data']['y_axis'])){ 149 print '<INPUT type="checkbox" name="y_axis" value="checked"'.$_COOKIE['webgp_data']['y_axis'].">対数\n"; 150 }else{ 151 print '<INPUT type="checkbox" name="y_axis" value="checked"'.">対数\n"; 152 } 153 154 print " ラベル <INPUT size=\"15\" type=\"text\" name=\"y_label\""; 155 if(isset($_COOKIE['webgp_data']['y_label'])){ 156 print "value=\"".$_COOKIE['webgp_data']['y_label']."\">\n"; 157 }else{ 158 print ">\n"; 159 } 160 ?> 161 </TD> 162 </TR> 163 164 <!-- ---------- 表示 ------------- --> 165 <TR> 166 <TD><a href="/yamamoto/comp/graph/web_gnuplot/help/hyoji.php" class="help">表示</a></TD> 167 <TD>グリッド <?PHP 168 if(isset($_COOKIE['webgp_data']['x_grid'])){ 169 print "<INPUT type=\"checkbox\" name=\"x_grid\" value=\"checked\" ". 170 $_COOKIE['webgp_data']['x_grid'].">x\n"; 171 }else{ 172 print "<INPUT type=\"checkbox\" name=\"x_grid\" value=\"checked\" ".">x\n"; 173 } 174 175 if(isset($_COOKIE['webgp_data']['y_grid'])){ 176 print "<INPUT type=\"checkbox\" name=\"y_grid\" value=\"checked\" ". 177 $_COOKIE['webgp_data']['y_grid'].">y\n"; 178 }else{ 179 print "<INPUT type=\"checkbox\" name=\"y_grid\" value=\"checked\" ".">y\n"; 180 } 181 182 print " \n"; 183 if(isset($_COOKIE['webgp_data']['monochrome'])){ 184 print '<INPUT type="checkbox" name="monochrome" value="checked" '. 185 $_COOKIE['webgp_data']['monochrome'].">白黒\n"; 186 }else{ 187 print '<INPUT type="checkbox" name="monochrome" value="checked" '.">白黒\n"; 188 } 189 190 ?> 191 192 193 </TR> 194 195 <!-- ---------- xデータ ------------- --> 196 <TR> 197 <TD><a href="/yamamoto/comp/graph/web_gnuplot/help/x_data.php" class="help">xデータ</a></TD> 198 <TD><?PHP 199 if(isset($_COOKIE['webgp_data']['x_row'])){ 200 set_select("x_row",$x_low,$_COOKIE['webgp_data']['x_row']); 201 }else{ 202 set_select("x_row",$x_low,0); 203 } 204 ?> 205 </TD> 206 </TR> 207 208 <!-- ---------- yデータ ------------- --> 209 <TR> 210 <TD><a href="/yamamoto/comp/graph/web_gnuplot/help/y_data.php" class="help">yデータ</a></TD> 211 <TD><?PHP 212 if(isset($_COOKIE['webgp_data']['y_row'])){ 213 set_select("y_row",$y_low,$_COOKIE['webgp_data']['y_row']); 214 }else{ 215 set_select("y_row",$y_low,1); 216 } 217 218 print " \n"; 219 ?> 220 ポイントサイズ <INPUT size="4" type="text" name="psize" <?PHP 221 if(isset($_COOKIE['webgp_data']['psize'])){ 222 print "value=\"".$_COOKIE['webgp_data']['psize']."\">\n"; 223 }else{ 224 print "value=1.0>\n"; 225 } 226 227 print " ライン\n"; 228 229 if(isset($_COOKIE['webgp_data']['line'])){ 230 set_select("line",$line,$_COOKIE['webgp_data']['line']); 231 }else{ 232 set_select("line",$line,0); 233 } 234 ?> 235 </TD> 236 </TR> 237 238 <!-- ---------- データエリア ------------- --> 239 <TR> 240 <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> 241 </TR> 242 <TR> 243 <TD colspan=2><textarea name="plot_data" cols=60 rows=20><?PHP 244 if(isset($_COOKIE['webgp_data']['plot_data']) && $_GET['status']!="clear"){ 245 print "\n".$_COOKIE['webgp_data']['plot_data']."\n"; 246 } 247 ?></textarea></TD> 248 </TR> 249 <TR> 250 251 252 <!-- ---------- 描画 ------------- --> 253 <TR> 254 <TD><a href="/yamamoto/comp/graph/web_gnuplot/help/byoga.php" class="help">描画</a></TD> 255 256 <TD> 257 <?PHP 258 print "ファイル "; 259 if(isset($_COOKIE['webgp_data']['g_file'])){ 260 set_select("g_file",$g_file,$_COOKIE['webgp_data']['g_file']); 261 }else{ 262 set_select("g_file",$g_file,0); 263 } 264 265 ?> 266 267 <INPUT TYPE="submit" value="プロット"> 268 </TD> 269 </TR> 270 271 </TBODY> 272 </TABLE> 273 </FORM> 274 275 <!-- ---------------- 関数 ----------------------- --> 276 <?php 277 //================================================================= 278 // setting of radio button 279 // 1st argument:name 280 // 2nd argument:label 281 // 3rd argument:checked number 282 //================================================================= 283 function set_radio($name,$label,$on){ 284 for($i=0; isset($label[$i]); $i++){ 285 if($i==$on){ 286 print "<INPUT type=\"radio\" name=\"".$name."\" value=\"".$i. 287 "\" checked>".$label[$i]."\n"; 288 }else{ 289 print "<INPUT type=\"radio\" name=\"".$name."\" value=\"".$i. 290 "\">".$label[$i]."\n"; 291 } 292 } 293 } 294 295 //================================================================= 296 // setting of select 297 // 1st argument:name 298 // 2nd argument:label 299 // 3rd argument:selected number 300 //================================================================= 301 function set_select($name,$label,$on=1){ 302 print "<select name=\"".$name."\">\n"; 303 for($i=0; isset($label[$i]); $i++){ 304 if($i==$on){ 305 print "<option value=".$i." selected>".$label[$i]."\n"; 306 }else{ 307 print "<option value=".$i.">".$label[$i]."\n"; 308 } 309 } 310 print "</select>\n"; 311 } 312 313 ?> 314 315 <!-- ---------------- 本文はここまで ---------------- --> 316 <?PHP 317 $show_counter=FALSE; 318 $show_update=TRUE; 319 include "../../../end_process.php"; 320 ?> 321 322 323 </BODY> 324 </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 }