fwrite($handle, "set key box horizon center tmargin\n"); fwrite($handle, "set term png\n"); fwrite($handle, "set grid\n"); fwrite($handle, "set tmargin 3.5\n"); fwrite($handle, "set output 'graphs/gnuplot/all.png'\n"); $data = "plot [0:{$lastblocknum}] 'graphs/blockdata' title \"block duration\" with dots, "; $data .= "'graphs/blockdata' using 1:6 title \"10,000 block moving average\" with lines\n"; fwrite($handle, $data); fclose($handle); exec("cat graphs/gnuplot/10.txt|gnuplot"); exec("cat graphs/gnuplot/100.txt|gnuplot"); exec("cat graphs/gnuplot/1000.txt|gnuplot"); exec("cat graphs/gnuplot/all.txt|gnuplot"); } } gnuplot(); // Provided by Insti // # Setup some fake data // for ( $i = 0; $i < 5; $i++ ) { // $block[$i] = $time; // $time += $i;#rand( 60,1 ); // } // // #print_r( $block ); // for ( $key = 0; $key < 5; $key++ ) { // $secsn = $block[$key] - $block[$key-1]; // $moving_average_buffer[] = $secsn; // print " 1: ".moving_average( $moving_average_buffer, 1 )."\n"; // print " 2: ".moving_average( $moving_average_buffer, 2 )."\n"; // print " 3: ".moving_average( $moving_average_buffer, 3 )."\n"; // }
$ret['imgtype'] = "png"; } } return $ret; } $api = get_args(); write_code($api); $arr = explode(':', $api['cht']); switch ($arr[0]) { case "gv": if (array_key_exists("1", $arr)) { $api['engine'] = $arr[1]; } else { $api['engine'] = "dot"; } $plot = graphviz($api); break; case "gp": $api['engine'] = "gnuplot"; $plot = gnuplot($api); break; defualt: error(); } $imgtype = $plot['imgtype']; $imgpath = $plot['imgpath']; $imgstrout = "image{$imgtype}(imagecreatefrom{$imgtype}('{$imgpath}'));"; if (isset($_GET['cht']) && isset($_GET['chl'])) { header("Content-Type: image/{$imgtype}; charset=UTF-8"); eval($imgstrout); }