Ejemplo n.º 1
0
<?php

/*
 Example6 : A simple filled line graph
*/
// 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(700, 230);
$Chart = new pChart(700, 230, $Canvas);
// Dataset
CSVImporter::importFromCSV($DataSet, dirname(__FILE__) . "/../sample/datawithtitle.csv", ",", array(1, 2, 3), TRUE, 0);
$DataSet->AddAllSeries();
$DataSet->SetAbscissaLabelSeries();
// Initialise the graph
$Chart->setFontProperties("../Fonts/tahoma.ttf", 8);
$Chart->setGraphArea(60, 30, 680, 200);
$Canvas->drawFilledRoundedRectangle(new Point(7, 7), new Point(693, 223), 5, new Color(240), 1, 0, ShadowProperties::NoShadow());
$Canvas->drawFilledRoundedRectangle(new Point(5, 5), new Point(695, 225), 5, new Color(230), 1, 0, ShadowProperties::NoShadow());
$backgroundStyle = new BackgroundStyle(new Color(255), TRUE);
$Chart->drawGraphBackground($backgroundStyle);
$Chart->drawScale($DataSet, ScaleStyle::DefaultStyle(), 0, 2);
$Chart->drawGrid(new GridStyle(4, TRUE, new Color(230), 50));
// Draw the 0 line
$Chart->setFontProperties("../Fonts/tahoma.ttf", 6);
$Chart->drawTreshold(0, new Color(143, 55, 72), TRUE, TRUE);
// Draw the filled line graph
Ejemplo n.º 2
0
 public function testDrawFilledLineGraph()
 {
     // Dataset definition
     $DataSet = new pData();
     CSVImporter::importFromCSV($DataSet, dirname(__FILE__) . "/../sample/datawithtitle.csv", ",", array(1, 2, 3), TRUE, 0);
     $DataSet->AddAllSeries();
     $DataSet->SetAbscissaLabelSeries();
     // Initialise the graph
     $canvas = new TestCanvas();
     $Test = new pChart(700, 230, $canvas);
     $Test->setFontProperties("Fonts/tahoma.ttf", 8);
     $Test->setGraphArea(60, 30, 680, 200);
     $backgroundStyle = new BackgroundStyle(new Color(255), TRUE);
     $Test->drawGraphBackground($backgroundStyle);
     $Test->drawScale($DataSet, ScaleStyle::DefaultStyle(), 0, 2);
     $Test->drawGrid(new GridStyle(4, TRUE, new Color(230), 50));
     // Draw the 0 line
     $Test->setFontProperties("Fonts/tahoma.ttf", 6);
     $Test->drawTreshold(0, new Color(143, 55, 72), TRUE, TRUE);
     // Draw the filled line graph
     $Test->drawFilledLineGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 50, TRUE);
     // Finish the graph
     $Test->setFontProperties("Fonts/tahoma.ttf", 8);
     $Test->drawLegend(65, 35, $DataSet->GetDataDescription(), new Color(255));
     $Test->setFontProperties("Fonts/tahoma.ttf", 10);
     $Test->drawTitle(60, 22, "Example 6", new Color(50), 585);
     $this->assertEquals('9816ffbe4277df46fdce89cdc0b28a47', md5($canvas->getActionLog()));
 }
Ejemplo n.º 3
0
// Standard inclusions
require_once '../lib/pChart.php';
require_once '../lib/PieChart.php';
require_once '../lib/pData.php';
require_once '../lib/GDCanvas.php';
require_once '../lib/TestCanvas.php';
require_once '../lib/GridStyle.php';
require_once '../lib/BackgroundStyle.php';
require_once '../lib/ScaleStyle.php';
require_once '../lib/CSVImporter.php';
// Definitions
$DataSet = new pData();
$Canvas = new GDCanvas(700, 230);
$Chart = new pChart(700, 230, $Canvas);
// Dataset
CSVImporter::importFromCSV($DataSet, dirname(__FILE__) . "/../sample/bulkdata.csv", ",", array(1, 2, 3), FALSE, 0);
$DataSet->AddAllSeries();
$DataSet->SetAbscissaLabelSeries();
$DataSet->setSeriesName("January", "Serie1");
$DataSet->setSeriesName("February", "Serie2");
$DataSet->setSeriesName("March", "Serie3");
$DataSet->getDataDescription()->SetYAxisName("Average age");
$DataSet->getDataDescription()->SetYUnit("µs");
// Initialise the graph
$Chart->setFontProperties("../Fonts/tahoma.ttf", 8);
$Chart->setGraphArea(70, 30, 680, 200);
// Set Canvas
$Canvas->drawFilledRoundedRectangle(new Point(7, 7), new Point(693, 223), 5, new Color(240), 1, 0, ShadowProperties::NoShadow());
$Canvas->drawRoundedRectangle(new Point(5, 5), new Point(695, 225), 5, new Color(230), 1, 0, ShadowProperties::NoShadow());
$Chart->drawGraphBackground(new BackgroundStyle(new Color(255), true));
$Chart->drawScale($DataSet, ScaleStyle::DefaultStyle(), 0, 2);