$MyData = new pData(); $MyData->addPoints(array(10, 20, 30, 40, 50, 60, 70, 80, 90), "ScoreA"); $MyData->addPoints(array(20, 40, 50, 12, 10, 30, 40, 50, 60), "ScoreB"); $MyData->setSerieDescription("ScoreA", "Coverage A"); $MyData->setSerieDescription("ScoreB", "Coverage B"); /* Define the absissa serie */ $MyData->addPoints(array(40, 80, 120, 160, 200, 240, 280, 320, 360), "Coord"); $MyData->setAbscissa("Coord"); /* Create the pChart object */ $myPicture = new pImage(300, 300, $MyData); /* Retrieve the image map */ if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"])) { $myPicture->dumpImageMap("ImageMapPolarChart", IMAGE_MAP_STORAGE_FILE, "PolarChart", "../tmp"); } /* Set the image map name */ $myPicture->initialiseImageMap("ImageMapPolarChart", IMAGE_MAP_STORAGE_FILE, "PolarChart", "../tmp"); /* Draw the background */ $myPicture->drawGradientArea(0, 0, 300, 300, DIRECTION_VERTICAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 240, "EndG" => 240, "EndB" => 240, "Alpha" => 100)); /* Add a border to the picture */ $RectangleSettings = array("R" => 180, "G" => 180, "B" => 180, "Alpha" => 100); $myPicture->drawRectangle(0, 0, 299, 299, array("R" => 0, "G" => 0, "B" => 0)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => FONT_PATH . "/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80)); /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Create the pRadar object */ $SplitChart = new pRadar(); /* Draw a radar chart */ $myPicture->setGraphArea(10, 10, 290, 290); $Options = array("RecordImageMap" => TRUE, "LabelPos" => RADAR_LABELS_HORIZONTAL, "BackgroundGradient" => array("StartR" => 255, "StartG" => 255, "StartB" => 255, "StartAlpha" => 50, "EndR" => 32, "EndG" => 109, "EndB" => 174, "EndAlpha" => 30), "AxisRotation" => 0, "DrawPoly" => TRUE, "PolyAlpha" => 50, "FontName" => FONT_PATH . "/pf_arma_five.ttf", "FontSize" => 6); $SplitChart->drawPolar($myPicture, $MyData, $Options);
$MyData->addPoints(array(20, 17, 25, 20, 25, 23, 16, 29, 26, 17), "Close"); $MyData->addPoints(array(10, 11, 14, 11, 9, 4, 3, 7, 9, 5), "Min"); $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);
/* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(array(150, 220, 300, 250, 420, 200, 300, 200, 100), "Server A"); $MyData->addPoints(array(140, VOID, 340, 300, 320, 300, 200, 100, 50), "Server B"); $MyData->setAxisName(0, "Hits"); $MyData->addPoints(array("January", "February", "March", "April", "May", "Juin", "July", "August", "September"), "Months"); $MyData->setSerieDescription("Months", "Month"); $MyData->setAbscissa("Months"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); /* Retrieve the image map */ if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"])) { $myPicture->dumpImageMap("ImageMapBarChart", IMAGE_MAP_STORAGE_FILE, "BarChart.labels", "../tmp"); } /* Set the image map name */ $myPicture->initialiseImageMap("ImageMapBarChart", IMAGE_MAP_STORAGE_FILE, "BarChart.labels", "../tmp"); /* Turn of Antialiasing */ $myPicture->Antialias = FALSE; /* Draw the background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 700, 230, $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, 700, 230, DIRECTION_VERTICAL, $Settings); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Set the default font */ $myPicture->setFontProperties(array("FontName" => FONT_PATH . "/pf_arma_five.ttf", "FontSize" => 6)); /* Define the chart area */ $myPicture->setGraphArea(60, 40, 650, 200); /* Draw the scale */
<?php /* Library settings */ define("CLASS_PATH", "../../../class"); define("FONT_PATH", "../../../fonts"); /* pChart library inclusions */ include CLASS_PATH . "/pDraw.class.php"; include CLASS_PATH . "/pImage.class.php"; /* Create the pChart object */ $myPicture = new pImage(700, 230); /* Retrieve the image map */ if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"])) { $myPicture->dumpImageMap("ImageMap1", IMAGE_MAP_STORAGE_FILE, "Shapes", "../tmp"); } /* Set the image map name */ $myPicture->initialiseImageMap("ImageMap1", IMAGE_MAP_STORAGE_FILE, "Shapes", "../tmp"); /* Turn of Antialiasing */ $myPicture->Antialias = FALSE; /* Draw the background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 700, 230, $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, 700, 230, DIRECTION_VERTICAL, $Settings); $myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80)); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Write the picture title */ $myPicture->setFontProperties(array("FontName" => FONT_PATH . "/Silkscreen.ttf", "FontSize" => 6)); $myPicture->drawText(10, 13, "drawFilledRectangle() - Transparency & colors", array("R" => 255, "G" => 255, "B" => 255)); /* Turn on shadow computing */
public function buildChartImage(array $reportData, array $fields, $asDataURI = true, $generateImageMapId = false) { global $current_user; require_once 'modules/AOR_Charts/lib/pChart/pChart.php'; if ($generateImageMapId !== false) { $generateImageMapId = $current_user->id . "-" . $generateImageMapId; } $html = ''; if (!in_array($this->type, $this->getValidChartTypes())) { return $html; } $x = $fields[$this->x_field]; $y = $fields[$this->y_field]; if (!$x || !$y) { //Malformed chart object - missing an axis field return ''; } $xName = str_replace(' ', '_', $x->label) . $this->x_field; $yName = str_replace(' ', '_', $y->label) . $this->y_field; $chartData = new pData(); $chartData->loadPalette("modules/AOR_Charts/lib/pChart/palettes/navy.color", TRUE); $labels = array(); foreach ($reportData as $row) { $chartData->addPoints($row[$yName], 'data'); $chartData->addPoints($row[$xName], 'Labels'); $labels[] = $row[$xName]; } $chartData->setSerieDescription("Months", "Month"); $chartData->setAbscissa("Labels"); $imageHeight = 700; $imageWidth = 700; $chartPicture = new pImage($imageWidth, $imageHeight, $chartData); if ($generateImageMapId) { $imageMapDir = create_cache_directory('modules/AOR_Charts/ImageMap/' . $current_user->id . '/'); $chartPicture->initialiseImageMap($generateImageMapId, IMAGE_MAP_STORAGE_FILE, $generateImageMapId, $imageMapDir); } $chartPicture->Antialias = True; $chartPicture->drawFilledRectangle(0, 0, $imageWidth - 1, $imageHeight - 1, array("R" => 240, "G" => 240, "B" => 240, "BorderR" => 0, "BorderG" => 0, "BorderB" => 0)); $chartPicture->setFontProperties(array("FontName" => "modules/AOR_Charts/lib/pChart/fonts/verdana.ttf", "FontSize" => 14)); $chartPicture->drawText($imageWidth / 2, 20, $this->name, array("R" => 0, "G" => 0, "B" => 0, 'Align' => TEXT_ALIGN_TOPMIDDLE)); $chartPicture->setFontProperties(array("FontName" => "modules/AOR_Charts/lib/pChart/fonts/verdana.ttf", "FontSize" => 6)); $chartPicture->setGraphArea(60, 60, $imageWidth - 60, $imageHeight - 100); switch ($this->type) { case 'radar': $this->buildChartImageRadar($chartPicture, $chartData, !empty($generateImageMapId)); break; case 'pie': $this->buildChartImagePie($chartPicture, $chartData, $reportData, $imageHeight, $imageWidth, $xName, !empty($generateImageMapId)); break; case 'line': $this->buildChartImageLine($chartPicture, !empty($generateImageMapId)); break; case 'bar': default: $this->buildChartImageBar($chartPicture, !empty($generateImageMapId)); break; } if ($generateImageMapId) { $chartPicture->replaceImageMapTitle("data", $labels); } ob_start(); $chartPicture->render(''); $img = ob_get_clean(); if ($asDataURI) { return 'data:image/png;base64,' . base64_encode($img); } else { return $img; } }
$myData->setScatterSerie("Probe 1", "Probe 3", 0); $myData->setScatterSerieDescription(0, "This year"); $myData->setScatterSerieColor(0, array("R" => 0, "G" => 0, "B" => 0)); /* Create the 2nd scatter chart binding */ $myData->setScatterSerie("Probe 2", "Probe 3", 1); $myData->setScatterSerieDescription(1, "Last Year"); /* Create the pChart object */ $myPicture = new pImage(400, 400, $myData); /* Turn of Antialiasing */ $myPicture->Antialias = FALSE; /* Retrieve the image map */ if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"])) { $myPicture->dumpImageMap("ImageMapScatterPlotChart", IMAGE_MAP_STORAGE_FILE, "ScatterPlotChart", "../tmp"); } /* Set the image map name */ $myPicture->initialiseImageMap("ImageMapScatterPlotChart", IMAGE_MAP_STORAGE_FILE, "ScatterPlotChart", "../tmp"); /* Draw the background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 400, 400, $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, 400, 400, DIRECTION_VERTICAL, $Settings); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 399, 399, array("R" => 0, "G" => 0, "B" => 0)); /* Set the default font */ $myPicture->setFontProperties(array("FontName" => FONT_PATH . "/pf_arma_five.ttf", "FontSize" => 6)); /* Set the graph area */ $myPicture->setGraphArea(50, 30, 350, 330); /* Create the Scatter chart object */ $myScatter = new pScatter($myPicture, $myData); /* Draw the scale */
include CLASS_PATH . "/pPie.class.php"; /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(array(40, 60, 15, 10, 6, 4), "ScoreA"); $MyData->setSerieDescription("ScoreA", "Application A"); /* Define the absissa serie */ $MyData->addPoints(array("<10", "10<>20", "20<>40", "40<>60", "60<>80", ">80"), "Labels"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(300, 260, $MyData); /* Retrieve the image map */ if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"])) { $myPicture->dumpImageMap("ImageMap2DPieChart", IMAGE_MAP_STORAGE_FILE, "2DPieChart", "../pChart2.1.4/tmp"); } /* Set the image map name */ $myPicture->initialiseImageMap("ImageMap2DPieChart", IMAGE_MAP_STORAGE_FILE, "2DPieChart", "../pChart2.1.4/tmp"); /* Draw a solid background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 300, 300, $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, 300, 260, DIRECTION_VERTICAL, $Settings); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 299, 259, array("R" => 0, "G" => 0, "B" => 0)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => FONT_PATH . "/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80)); /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 50)); /* Create the pPie object */ $Settings = array("RecordImageMap" => TRUE); $PieChart = new pPie($myPicture, $MyData, $Settings);
include CLASS_PATH . "/pPie.class.php"; /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(array(40, 60, 15, 10, 6, 4), "ScoreA"); $MyData->setSerieDescription("ScoreA", "Application A"); /* Define the absissa serie */ $MyData->addPoints(array("<10", "10<>20", "20<>40", "40<>60", "60<>80", ">80"), "Labels"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(300, 260, $MyData); /* Retrieve the image map */ if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"])) { $myPicture->dumpImageMap("ImageMap3DPieChart", IMAGE_MAP_STORAGE_FILE, "3DPieChart", "../tmp"); } /* Set the image map name */ $myPicture->initialiseImageMap("ImageMap3DPieChart", IMAGE_MAP_STORAGE_FILE, "3DPieChart", "../tmp"); /* Draw a solid background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 300, 300, $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, 300, 260, DIRECTION_VERTICAL, $Settings); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 299, 259, array("R" => 0, "G" => 0, "B" => 0)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => FONT_PATH . "/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80)); /* Create the pPie object */ $Settings = array("RecordImageMap" => TRUE); $PieChart = new pPie($myPicture, $MyData, $Settings); /* Draw an AA pie chart */ $PieSettings = array("DrawLabels" => TRUE, "LabelStacked" => TRUE, "Border" => TRUE, "RecordImageMap" => TRUE);
include CLASS_PATH . "/pPie.class.php"; /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(array(40, 60, 15, 10, 6, 4), "ScoreA"); $MyData->setSerieDescription("ScoreA", "Application A"); /* Define the absissa serie */ $MyData->addPoints(array("<10", "10<>20", "20<>40", "40<>60", "60<>80", ">80"), "Labels"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(300, 260, $MyData); /* Retrieve the image map */ if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"])) { $myPicture->dumpImageMap("ImageMap2DRingChart", IMAGE_MAP_STORAGE_FILE, "2DRingChart", "../tmp"); } /* Set the image map name */ $myPicture->initialiseImageMap("ImageMap2DRingChart", IMAGE_MAP_STORAGE_FILE, "2DRingChart", "../tmp"); /* Draw a solid background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 300, 300, $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, 300, 260, DIRECTION_VERTICAL, $Settings); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 299, 259, array("R" => 0, "G" => 0, "B" => 0)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => FONT_PATH . "/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80)); /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 50)); /* Create the pPie object */ $Settings = array("RecordImageMap" => TRUE); $PieChart = new pPie($myPicture, $MyData, $Settings);