<?php /* CAT:Plot chart */ /* pChart library inclusions */ include "../class/pData.class.php"; include "../class/pDraw.class.php"; include "../class/pImage.class.php"; /* Create and populate the pData object */ $MyData = new pData(); for ($i = 0; $i <= 20; $i++) { $MyData->addPoints(rand(0, 20), "Probe 1"); } for ($i = 0; $i <= 20; $i++) { $MyData->addPoints(rand(0, 20), "Probe 2"); } $MyData->setSerieShape("Probe 1", SERIE_SHAPE_FILLEDTRIANGLE); $MyData->setSerieWeight("Probe 1", 2); $MyData->setSerieShape("Probe 2", SERIE_SHAPE_FILLEDSQUARE); $MyData->setAxisName(0, "Temperatures"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); /* Turn of Antialiasing */ $myPicture->Antialias = FALSE; /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(150, 35, "Average temperature", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); /* Set the default font */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Define the chart area */
$PieChart->drawPieLegend($marg, $height - $marg - $font * 2, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); } } else { $nSerie = 0; if (!isset($chart_limit)) { $chart_limit = 1000; } $plotShapes = array(SERIE_SHAPE_FILLEDCIRCLE, SERIE_SHAPE_FILLEDTRIANGLE, SERIE_SHAPE_FILLEDSQUARE, SERIE_SHAPE_FILLEDDIAMOND); reset($arrFields); while (list($idx, $field) = each($arrFields)) { if (!isset($chart_cols) or $idx == 0 or in_array($idx, $chart_cols)) { $arrSeries[] = $field; $myData->addPoints(array_reverse(array_slice($arrCols[$field], 0, $chart_limit)), $field); $myData->setSerieWeight($field, $weight); if ($plotShape >= 0 and $plotShape < count($plotShapes)) { $myData->setSerieShape($field, $plotShapes[$plotShape]); } else { $myData->setSerieShape($field, $plotShapes[array_rand($plotShapes, 1)]); } if (isset($palette)) { $myData->setPalette($field, $palette['serie'][($nSerie - 1) % $palette['serie_num']]); } if ($nSerie == 0) { $abscissa = $field; $myData->setAbscissa($abscissa); } else { if (isset($chart_cols2) and in_array($idx, $chart_cols2)) { $arrSeriesY2[] = $field; $myData->setSerieOnAxis($field, 1); $myData->setSerieDescription($field, "右){$field}"); }
$startdate = explode(",", $startdate); $times = date('G:i@j/m', strtotime($startdate[0])); $startdate = $times; $enddate = end($F1); $enddate = explode(",", $enddate); $times = date('G:i@j/m', strtotime($enddate[0])); $enddate = $times; $F2 = file("data/next_mov.csv"); $nextmov = $F2[1]; $MyData->setAxisName(0, "Prices"); $MyData->addPoints($data["bids"], "Buy"); $MyData->addPoints($data["asks"], "Sell"); $MyData->addPoints($data["prices"], "BTC/USD"); $MyData->addPoints($data["emaShort"], "EMAshort"); $MyData->addPoints($data["emaLong"], "EMAlong"); $MyData->setSerieShape("Buy", SERIE_SHAPE_FILLEDTRIANGLE); $MyData->setSerieWeight("Buy", 2); $MyData->setSerieShape("Sell", SERIE_SHAPE_FILLEDSQUARE); $MyData->addPoints($data["times"], "Labels"); $MyData->setSerieDescription("Labels", "Months"); $MyData->setAbscissa("Labels"); $myPicture = new pImage(1400, 460, $MyData); $myPicture->Antialias = FALSE; $myPicture->setFontProperties(array("FontName" => "pChart/fonts/Forgotte.ttf", "FontSize" => 8, "R" => 0, "G" => 0, "B" => 0)); $myPicture->drawText(15, 22, "HAL10K by intrd", array("FontSize" => 15, "Align" => TEXT_ALIGN_BOTTOMLEFT)); //$myPicture->drawText(15,22,"HAL10K by intrd",array("FontSize"=>15,"Align"=>TEXT_ALIGN_BOTTOMLEFT)); $myPicture->drawText(450, 20, "Período: " . $startdate . " - " . $enddate . "", array("FontSize" => 13, "Align" => TEXT_ALIGN_BOTTOMLEFT)); $myPicture->drawText(651, 23, $nextmov, array("FontSize" => 13, "Align" => TEXT_ALIGN_BOTTOMLEFT)); $myPicture->setFontProperties(array("FontName" => "pChart/fonts/pf_arma_five.ttf", "FontSize" => 10, "R" => 0, "G" => 0, "B" => 0)); $myPicture->setGraphArea(20 * 2, 20, 650 * 2, 200 * 2); $scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 500, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE);