Example #1
0
 public function testDrawRadar()
 {
     // Dataset definition
     $DataSet = new pData();
     $DataSet->addPoints(array("Memory", "Disk", "Network", "Slots", "CPU"), "Label");
     $DataSet->addPoints(array(1, 2, 3, 4, 3), "Serie1");
     $DataSet->addPoints(array(1, 4, 2, 6, 2), "Serie2");
     $DataSet->AddSeries("Serie1");
     $DataSet->AddSeries("Serie2");
     $DataSet->SetAbscissaLabelSeries("Label");
     $DataSet->SetSeriesName("Reference", "Serie1");
     $DataSet->SetSeriesName("Tested computer", "Serie2");
     // Initialise the graph
     $canvas = new TestCanvas();
     $Test = new pChart(400, 400, $canvas);
     $Test->setFontProperties("Fonts/tahoma.ttf", 8);
     $Test->setGraphArea(30, 30, 370, 370);
     // Draw the radar graph
     $Test->drawRadarAxis($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE, 20, new Color(120), new Color(230));
     $Test->drawRadar($DataSet->GetData(), $DataSet->GetDataDescription(), 50);
     // Finish the graph
     $Test->drawLegend(15, 15, $DataSet->GetDataDescription(), new Color(255));
     $Test->setFontProperties("Fonts/tahoma.ttf", 10);
     $Test->drawTitle(0, 22, "Example 8", new Color(50), 400);
     $this->assertEquals('be9f2fb9cb890e3ffdae443376d80be9', md5($canvas->getActionLog()));
 }
 private function getRadar($localGraphId, $title, $xLabels, $sery1, $legend, $r = "208", $g = "2", $b = "57")
 {
     // Dataset definition
     if (count($sery1) == 0) {
         throw common_exception_ClientException("Empty data set");
     }
     $dataSet = new \pData();
     $dataSet->AddPoint($xLabels, "Label");
     $dataSet->AddPoint($sery1, "Serie1");
     $dataSet->AddSerie("Serie1");
     $dataSet->SetAbsciseLabelSerie("Label");
     $dataSet->SetSerieName($legend, "Serie1");
     // Initialise the graph
     $graph = new \pChart(500, 500);
     $graph->createColorGradientPalette($r, $g, $b, $r, $g, $b, 5);
     // aa is way too slow here
     $graph->Antialias = false;
     $graph->setFontProperties(fontName, 8);
     $graph->drawFilledRoundedRectangle(7, 7, 493, 493, 5, 240, 240, 240);
     $graph->drawRoundedRectangle(5, 5, 493, 493, 5, 230, 230, 230);
     $graph->setGraphArea(120, 70, 420, 420);
     $graph->drawFilledRoundedRectangle(30, 30, 470, 470, 5, 254, 254, 254);
     $graph->drawRoundedRectangle(30, 30, 470, 470, 5, 220, 220, 220);
     // Draw the radar graph
     $graph->drawRadarAxis($dataSet->GetData(), $dataSet->GetDataDescription(), true, 20, 120, 120, 120, 5, 5, 5);
     $graph->drawFilledRadar($dataSet->GetData(), $dataSet->GetDataDescription(), 50, 20);
     // Finish the graph
     $graph->setFontProperties(fontName, 9);
     $graph->drawLegend(32, 32, $dataSet->GetDataDescription(), 255, 255, 255);
     $graph->setFontProperties(fontName, 10);
     $graph->drawTitle(0, 22, $title, 50, 50, 50, 400);
     $url = $this->getUniqueMediaFileName($localGraphId, "png");
     $graph->Render(ROOT_PATH . $url);
     return ROOT_URL . $url;
 }
Example #3
0
    Example8 : A radar graph
*/
// Standard inclusions
include "../lib/pData.php";
include "../lib/pChart.php";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint(array("Memory", "Disk", "Network", "Slots", "CPU"), "Label");
$DataSet->AddPoint(array(1, 2, 3, 4, 3), "Serie1");
$DataSet->AddPoint(array(1, 4, 2, 6, 2), "Serie2");
$DataSet->AddSerie("Serie1");
$DataSet->AddSerie("Serie2");
$DataSet->SetAbsciseLabelSerie("Label");
$DataSet->SetSerieName("Reference", "Serie1");
$DataSet->SetSerieName("Tested computer", "Serie2");
// Initialise the graph
$Test = new pChart(400, 400);
$Test->setFontProperties("../Fonts/tahoma.ttf", 8);
$Test->drawFilledRoundedRectangle(7, 7, 393, 393, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 395, 395, 5, 230, 230, 230);
$Test->setGraphArea(30, 30, 370, 370);
$Test->drawFilledRoundedRectangle(30, 30, 370, 370, 5, 255, 255, 255);
$Test->drawRoundedRectangle(30, 30, 370, 370, 5, 220, 220, 220);
// Draw the radar graph
$Test->drawRadarAxis($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE, 20, 120, 120, 120, 230, 230, 230);
$Test->drawFilledRadar($DataSet->GetData(), $DataSet->GetDataDescription(), 50, 20);
// Finish the graph
$Test->drawLegend(15, 15, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties("../Fonts/tahoma.ttf", 10);
$Test->drawTitle(0, 22, "Example 8", 50, 50, 50, 400);
$Test->Render("example8.png");
Example #4
0
// Standard inclusions
require_once "../lib/pData.php";
require_once "../lib/pChart.php";
require_once '../lib/GDCanvas.php';
require_once '../lib/BackgroundStyle.php';
// Definitions
$DataSet = new pData();
$Canvas = new GDCanvas(400, 400);
$Chart = new pChart(400, 400, $Canvas);
// Dataset
$DataSet->AddPoints(array("Memory", "Disk", "Network", "Slots", "CPU"), "Label");
$DataSet->AddPoints(array(1, 2, 3, 4, 3), "Serie1");
$DataSet->AddPoints(array(1, 4, 2, 6, 2), "Serie2");
$DataSet->AddSeries("Serie1");
$DataSet->AddSeries("Serie2");
$DataSet->SetAbscissaLabelSeries("Label");
$DataSet->SetSeriesName("Reference", "Serie1");
$DataSet->SetSeriesName("Tested computer", "Serie2");
// Initialise the graph
$Chart->setFontProperties("../Fonts/tahoma.ttf", 8);
$Chart->setGraphArea(30, 30, 370, 370);
// Draw the radar graph
$Chart->drawRadarAxis($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE, 20, new Color(120), new Color(230));
$Chart->drawFilledRadar($DataSet->GetData(), $DataSet->GetDataDescription(), 50, 20);
// Finish the graph
$Chart->drawLegend(15, 15, $DataSet->GetDataDescription(), new Color(255));
$Chart->setFontProperties("../Fonts/tahoma.ttf", 10);
$Chart->drawTitle(0, 22, "Example 8", new Color(50), 400);
$Chart->Render("Example8.png");
header("Content-Type:image/png");
readfile("Example8.png");