DATE_SUB(CURDATE(),INTERVAL 90 DAY) '); $sWhere .= ' and keyword="'.addslashes($sTicker).'"'; //get ticker data $sql = 'SELECT * FROM gi_stock '.$sWhere.' GROUP BY date ORDER BY date ASC '; $res = mysql_query($sql); $aOpen = array(); $aClose = array(); $aHigh = array(); $aLow = array(); while($row = mysql_fetch_array($res)) { $sStamp = strtotime($row['date']); $aOpen[] = $row['open']; $aClose[] = $row['close']; $aHigh[] = $row['high']; $aLow[] = $row['low']; $aDate[] = date('m.d',$sStamp); } $iMin = min($aLow)-round(min($aLow)*0.1); $iMax = max($aHigh)+round(max($aHigh)*0.1); /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints($aOpen,"Open"); $MyData->addPoints($aClose,"Close"); $MyData->addPoints($aHigh,"Min"); $MyData->addPoints($aLow,"Max"); $MyData->setAxisDisplay(0,AXIS_FORMAT_CURRENCY,"$"); $MyData->addPoints($aDate,"Time"); $MyData->setAbscissa("Time"); /* Create the pChart object */ $myPicture = new pImage(1000,600,$MyData); /* Turn of AAliasing */ $myPicture->Antialias = FALSE; /* Draw the border */ $myPicture->drawRectangle(0,0,999,599,array("R"=>0,"G"=>0,"B"=>0)); /* Set the default font settings */ $myPicture->setFontProperties(array("FontName"=>"fonts/pf_arma_five.ttf","FontSize"=>6)); /* Define the chart area */ $myPicture->setGraphArea(60,10,990,580); /* Draw the scale */ $AxisBoundaries = array(0=>array("Min"=>$iMin,"Max"=>$iMax)); $scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE,"Mode"=>SCALE_MODE_MANUAL,"ManualScale"=>$AxisBoundaries); $myPicture->drawScale($scaleSettings); /* Create the pStock object */ $mystockChart = new pStock($myPicture,$MyData); /* Draw the stock chart */ $stockSettings = array("ExtremityLength"=>0,"BoxUpBorderR"=>0, "BoxUpBorderG"=>0, "BoxUpBorderB"=>0,"BoxUpR"=>255,"BoxUpG"=>255,"BoxUpB"=>255,"BoxDownR"=>0,"BoxDownG"=>0,"BoxDownB"=>0); $mystockChart->drawStockChart($stockSettings); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawStockChart.simple.png"); ?>