include_once "../class/pData.class.php"; include_once "../class/pDraw.class.php"; include_once "../class/pImage.class.php"; /* Create and populate the pData object */ $file = 'foundit.csv'; $handler = fopen($file, r); $string = fgets($handler); $myArray = explode(',', $string); $i = 0; while ($string = fgets($handler)) { $myArray = explode(',', $string); $components[$i] = $myArray[0]; ++$i; } $MyData = new pData(); $MyData->importFromCSV("foundit.csv", array("GotHeader" => TRUE, "SkipColumns" => array(0))); $MyData->setAxisName(0, "Bug Count"); $MyData->setAxisName(1, "Components"); $MyData->addPoints($components, "Components"); $MyData->setAbscissa("Components"); //$MyData->setSerieOnAxis("Component",1); //$MyData->setAxisXY(1,AXIS_X); /* Create the pChart object */ $myPicture = new pImage(3000, 700, $MyData); $myPicture->drawGradientArea(0, 0, 3000, 700, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100)); $myPicture->drawGradientArea(0, 0, 3000, 700, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Draw the scale and the chart */ $myPicture->setGraphArea(60, 20, 3000, 680); $myPicture->drawScale(array("DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL_START0));
<?php //ini_set('display_errors', 'On'); //error_reporting(E_ALL); // phpinfo(); /* pChart library inclusions */ include "../pChart/class/pData.class.php"; include "../pChart/class/pDraw.class.php"; include "../pChart/class/pImage.class.php"; /* Create the pData object with some random values*/ $MyData = new pData(); /* Import the data from a CSV file */ $MyData->importFromCSV("/var/ram/readings.csv", array("GotHeader" => True, "SkipColumns" => array(0))); $MyData->setPalette("Temperature", array("R" => 0, "G" => 128, "B" => 0)); $MyData->setPalette("CPU-Temp", array("R" => 128, "G" => 0, "B" => 128)); $MyData->setPalette("Pressure", array("R" => 255, "G" => 0, "B" => 0)); $MyData->setSerieOnAxis("Temperature", 0); $MyData->setSerieOnAxis("CPU-Temp", 1); $MyData->setSerieOnAxis("Pressure", 2); $MyData->setAxisName(0, "Temperature"); $MyData->setAxisName(1, "Temperature"); $MyData->setAxisName(2, "Pressure"); $MyData->setAxisPosition(1, AXIS_POSITION_RIGHT); /* Get latest value before reversing Series for plotting */ $latest = $MyData->Data['Series']['Pressure']['Data'][0]; /* Reverse series so latest value is on the right */ $MyData->reverseSerie("Temperature"); $MyData->reverseSerie("CPU-Temp"); $MyData->reverseSerie("Pressure"); $earliest = $MyData->Data['Series']['Pressure']['Data'][0]; /* Create the chart*/