Esempio n. 1
0
            $val_dif = $max_val - $min_val;
            $yscale = 7;
            for ($i = 4; $i <= 10; ++$i) {
                // find a divisor
                if ($val_dif % $i == 0) {
                    $yscale = $i;
                    break;
                }
            }
            $graph->setProp('scale', 'date');
            $graph->setProp('pointstyle', 7);
            $graph->setColor('pointcolor', -1, 255, 0, 0);
            $graph->setProp('startdate', (int) $min_time);
            $graph->setProp('enddate', (int) $max_time);
            $graph->setProp('xsclpts', 6);
            $graph->setProp('xincpts', 6);
            $graph->setProp('ysclpts', $yscale);
            $graph->setProp('yincpts', $yscale);
            if ($max_time - $min_time <= 365 * 24 * 60 * 60) {
                $graph->setProp('dateformat', 1);
            } elseif ($max_time - $min_time > 365 * 24 * 60 * 60) {
                $graph->setProp('dateformat', 1);
            }
            $graph->setProp('showyear', true);
            $graph->graph();
            $graph->showGraph(_BASEPATH_ . '/tmp/admin/' . $type . $start_date . $end_date . '.png');
            //			$graph->showGraph();
        }
    }
    redirect2page('tmp/admin/' . $type . $start_date . $end_date . '.png');
}
Esempio n. 2
0
 function createGraph($data, $w = 400, $h = 200, $prop = "", $random = false)
 {
     global $numGraphs;
     $numGraphs++;
     $graph = new graph($w, $h);
     if (is_array($prop)) {
         $graph->storePropArr($prop);
     } else {
         $graph->setBulkProps($prop);
     }
     $data = explode(":", $data);
     $dt = $data[1];
     if (strtoupper($data[0]) == "XML") {
         $graph->importXML($dt, isset($data[2]) ? $data[2] : "i", isset($data[3]) ? $data[3] : "d", isset($data[4]) ? $data[4] : "", isset($data[5]) ? $data[5] : 0);
     } elseif (strtoupper($data[0]) == "CSV") {
         $graph->importCSV($dt, isset($data[2]) ? $data[2] : "d,i", isset($data[3]) ? $data[3] : 0);
     } elseif (strtoupper($data[0]) == "RAW") {
         $graph->addBulkPoints($dt, ';');
     } elseif (strtoupper($data[0]) == "FUN") {
         $graph->graphFunction($dt, isset($data[2]) ? $data[2] : -1, isset($data[2]) ? $data[2] : 1);
     } else {
         $graph->error("Inline data format not understood. Read the readme.");
     }
     $graph->graph();
     $name = $graph->getProp("tempfolder", "") . "graph" . substr(basename($_SERVER['PHP_SELF']), 0, 3) . $numGraphs . ($random == true ? rand(1, 100000) : "") . '.png';
     $graph->showGraph($name);
     if ($random && $graph->getProp("delold", true)) {
         $fname = $graph->getProp("tempfolder", "") . "imagehistory" . basename($_SERVER['PHP_SELF']) . ".data";
         $f = @file($fname);
         if (count($f) > $graph->getProp("cachehistory", 5)) {
             unlink($f[0]);
             unset($f[0]);
         }
         $f[] = $name;
         file_put_contents($fname, join(array_filter($f, $this->trimfilter), "\n"));
     }
     unset($graph);
     return $name;
 }