/* Create the pChart object */ $myPicture = new pImage($xsize, $ysize, $MyData); $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, $xsize, $ysize, DIRECTION_VERTICAL, $Settings); /* Draw the border */ $myPicture->drawRectangle(0, 0, $xsize - 1, $ysize - 1, array("R" => 0, "G" => 0, "B" => 0)); /* Write the title */ $myPicture->setFontProperties(array("FontName" => "../../fonts/verdana.ttf", "FontSize" => 9)); $myPicture->drawText(70, 45, $title, array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMLEFT)); /* Draw the 1st scale */ $myPicture->setGraphArea(70, 60, $xsize - 40, $ysize - 30); $myPicture->drawFilledRectangle(70, 60, $xsize - 40, $ysize - 30, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10)); $AxisBoundaries = array(0 => array("Min" => $minscale, "Max" => $maxscale)); $myPicture->drawScale(array("DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "Mode" => SCALE_MODE_MANUAL, "ManualScale" => $AxisBoundaries)); /* Draw the 1st stock chart */ $mystockChart = new pStock($myPicture, $MyData); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 30)); $mystockChart->drawStockChart(); /* Reset the display mode because of the graph small size */ //$MyData->setAxisDisplay(0,AXIS_FORMAT_DEFAULT); /* Draw the 2nd scale */ //$myPicture->setShadow(FALSE); //$myPicture->setGraphArea(500,60,670,190); //$myPicture->drawFilledRectangle(500,60,670,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10)); //$myPicture->drawScale(array("Pos"=>SCALE_POS_TOPBOTTOM,"DrawSubTicks"=>TRUE)); /* Draw the 2nd stock chart */ //$mystockChart = new pStock($myPicture,$MyData); //$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>30)); //$mystockChart->drawStockChart(); /* Render the picture (choose the best way) */ //$myPicture->autoOutput("pictures/example.drawStockChart.png");
$MyData->addPoints(array(37, 32, 33, 29, 29, 25, 22, 34, 29, 31), "Max"); $MyData->addPoints(array(30, 20, 21, 24, 22, 18, 18, 24, 22, 24), "Median"); $MyData->setAxisDisplay(0, AXIS_FORMAT_CURRENCY, "\$"); $MyData->addPoints(array("Dec 13", "Dec 14", "Dec 15", "Dec 16", "Dec 17", "Dec 20", "Dec 21", "Dec 22", "Dec 23", "Dec 24"), "Time"); $MyData->setAbscissa("Time"); $MyData->setAbscissaName("Time"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); /* Retrieve the image map */ if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"])) { $myPicture->dumpImageMap("ImageMapStockChart", IMAGE_MAP_STORAGE_FILE, "StockChart", "../tmp"); } /* Set the image map name */ $myPicture->initialiseImageMap("ImageMapStockChart", IMAGE_MAP_STORAGE_FILE, "StockChart", "../tmp"); /* Turn of AAliasing */ $myPicture->Antialias = FALSE; /* Draw the border */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); $myPicture->setFontProperties(array("FontName" => FONT_PATH . "/pf_arma_five.ttf", "FontSize" => 6)); /* Define the chart area */ $myPicture->setGraphArea(60, 30, 650, 190); /* Draw the scale */ $scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE); $myPicture->drawScale($scaleSettings); /* Create the pStock object */ $mystockChart = new pStock($myPicture, $MyData); /* Draw the stock chart */ $stockSettings = array("RecordImageMap" => TRUE, "BoxUpR" => 255, "BoxUpG" => 255, "BoxUpB" => 255, "BoxDownR" => 0, "BoxDownG" => 0, "BoxDownB" => 0, "SerieMedian" => "Median"); $mystockChart->drawStockChart($stockSettings); /* Render the picture (choose the best way) */ $myPicture->autoOutput("../tmp/StockChart.png");
function buildgraph($MyData, $xsize, $ysize, $title, $minscale, $maxscale, $date, $type, $imagefilename) { //include("../cfg/nmcgraph_cfg.php"); /* Create and populate the pData object */ $MyData = new pData(); load_nmc_data($MyData, $date, $type, $minscale, $maxscale); //var_dump($MyData); //echo $minscale." ".$maxscale; exit; //printf("minscale: $minscale maxscale: $maxscale <br />\n"); //buildgraph( $MyData, $xsize, $ysize, $title ); $MyData->setAxisDisplay(0, AXIS_FORMAT_CURRENCY, "฿"); //$MyData->addPoints(array("8h","10h","12h","14h","16h","18h"),"Time"); //$MyData->setAbscissa("Months"); //$MyData->setAxisName(0,"Price in BTC"); //$MyData->setSerieDescription("Time","Hour of the day"); /* Create the pChart object */ $myPicture = new pImage($xsize, $ysize, $MyData); /* Draw the background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, $xsize, $ysize, $Settings); /* Overlay with a gradient */ $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, $xsize, $ysize, DIRECTION_VERTICAL, $Settings); /* Draw the border */ $myPicture->drawRectangle(0, 0, $xsize - 1, $ysize - 1, array("R" => 0, "G" => 0, "B" => 0)); /* Write the title */ $myPicture->setFontProperties(array("FontName" => dirname(__FILE__) . "/../../fonts/verdana.ttf", "FontSize" => 9)); $myPicture->drawText(70, 45, $title, array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMLEFT)); /* Draw the 1st scale */ $myPicture->setGraphArea(70, 60, $xsize - 40, $ysize - 30); $myPicture->drawFilledRectangle(70, 60, $xsize - 40, $ysize - 30, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10)); // Y scale $AxisBoundariesY = array(0 => array("Min" => $minscale, "Max" => $maxscale)); $myPicture->drawScale(array("DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "Mode" => SCALE_MODE_MANUAL, "ManualScale" => $AxisBoundariesY)); //X scale //$AxisBoundariesX = array("01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"); //$MyData->setSerieDescription("Labels","Months"); //$MyData->setAbscissa("Labels"); $MyData->setXAxisDisplay(0, AXIS_FORMAT_TIME, "H"); //$myPicture->drawScale(array("DrawXLines"=>array(0))); /* Draw the 1st stock chart */ $mystockChart = new pStock($myPicture, $MyData); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 30)); $mystockChart->drawStockChart(); /* Reset the display mode because of the graph small size */ //$MyData->setAxisDisplay(0,AXIS_FORMAT_DEFAULT); /* Draw the 2nd scale */ //$myPicture->setShadow(FALSE); //$myPicture->setGraphArea(500,60,670,190); //$myPicture->drawFilledRectangle(500,60,670,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10)); //$myPicture->drawScale(array("Pos"=>SCALE_POS_TOPBOTTOM,"DrawSubTicks"=>TRUE)); /* Draw the 2nd stock chart */ //$mystockChart = new pStock($myPicture,$MyData); //$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>30)); //$mystockChart->drawStockChart(); /* Render the picture (choose the best way) */ //$myPicture->autoOutput("pictures/example.drawStockChart.png"); $myPicture->render($imagefilename); $current_time = time(); $graphgendate = $current_time; return $graphgendate; }