Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Initial the package
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafasoufi committed Nov 6, 2018
1 parent 838fa17 commit 2f6ee62
Show file tree
Hide file tree
Showing 50 changed files with 5,947 additions and 1 deletion.
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@
}
],
"minimum-stability": "stable",
"require": {}
"require": {
"php": ">=5.4.0"
},
"autoload": {
"psr-0": {
"pChart": "src/"
}
}
}
19 changes: 19 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions src/Example1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/*
Example1 : A simple line chart
*/

require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload

use pChart\pData;
use pChart\pChart;
use pChart\pCache;

// Dataset definition
$DataSet = new pData;
$DataSet->ImportFromCSV("Sample/bulkdata.csv", ",", array(1, 2, 3), FALSE, 0);
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie();
$DataSet->SetSerieName("January", "Serie1");
$DataSet->SetSerieName("February", "Serie2");
$DataSet->SetSerieName("March", "Serie3");
$DataSet->SetYAxisName("Average age");
$DataSet->SetYAxisUnit("�s");

// Initialise the graph
$Test = new pChart(700, 230);
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(70, 30, 680, 200);
$Test->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230);
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2);
$Test->drawGrid(4, TRUE, 230, 230, 230, 50);

// Draw the 0 line
$Test->setFontProperties("Fonts/tahoma.ttf", 6);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);

// Draw the line graph
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255);

// Finish the graph
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawLegend(75, 35, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties("Fonts/tahoma.ttf", 10);
$Test->drawTitle(60, 22, "example 1", 50, 50, 50, 585);
$Test->Render("example1.png");
?>
36 changes: 36 additions & 0 deletions src/Example10.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/*
Example10 : A 3D exploded pie graph
*/

require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload

use pChart\pData;
use pChart\pChart;
use pChart\pCache;

// Dataset definition
$DataSet = new pData;
$DataSet->AddPoint(array(10, 2, 3, 5, 3), "Serie1");
$DataSet->AddPoint(array("January", "February", "March", "April", "May"), "Serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("Serie2");

// Initialise the graph
$Test = new pChart(420, 250);
$Test->drawFilledRoundedRectangle(7, 7, 413, 243, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 415, 245, 5, 230, 230, 230);
$Test->createColorGradientPalette(195, 204, 56, 223, 110, 41, 5);

// Draw the pie chart
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->AntialiasQuality = 0;
$Test->drawPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 180, 130, 110, PIE_PERCENTAGE_LABEL, FALSE, 50, 20, 5);
$Test->drawPieLegend(330, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250);

// Write the title
$Test->setFontProperties("Fonts/MankSans.ttf", 10);
$Test->drawTitle(10, 20, "Sales per month", 100, 100, 100);

$Test->Render("example10.png");
?>
51 changes: 51 additions & 0 deletions src/Example11.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/*
Example11 : Using the pCache class
*/

require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload

use pChart\pData;
use pChart\pChart;
use pChart\pCache;

// Dataset definition
$DataSet = new pData;
$DataSet->AddPoint(array(1, 4, 3, 2, 3, 3, 2, 1, 0, 7, 4, 3, 2, 3, 3, 5, 1, 0, 7), "Serie1");
$DataSet->AddPoint(array(1, 4, 2, 6, 2, 3, 0, 1, 5, 1, 2, 4, 5, 2, 1, 0, 6, 4, 2), "Serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie();
$DataSet->SetSerieName("January", "Serie1");
$DataSet->SetSerieName("February", "Serie2");

// Cache definition
$Cache = new pCache();
$Cache->GetFromCache("Graph1", $DataSet->GetData());

// Initialise the graph
$Test = new pChart(700, 230);
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(50, 30, 585, 200);
$Test->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230);
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2);
$Test->drawGrid(4, TRUE, 230, 230, 230, 50);

// Draw the 0 line
$Test->setFontProperties("Fonts/tahoma.ttf", 6);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);

// Draw the cubic curve graph
$Test->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription());

// Finish the graph
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawLegend(600, 30, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties("Fonts/tahoma.ttf", 10);
$Test->drawTitle(50, 22, "Example 1", 50, 50, 50, 585);

// Render the graph
$Cache->WriteToCache("Graph1", $DataSet->GetData(), $Test);
$Test->Render("example1.png");
?>
47 changes: 47 additions & 0 deletions src/Example12.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/*
Example12 : A true bar graph
*/

require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload

use pChart\pData;
use pChart\pChart;
use pChart\pCache;

// Dataset definition
$DataSet = new pData;
$DataSet->AddPoint(array(1, 4, -3, 2, -3, 3, 2, 1, 0, 7, 4), "Serie1");
$DataSet->AddPoint(array(3, 3, -4, 1, -2, 2, 1, 0, -1, 6, 3), "Serie2");
$DataSet->AddPoint(array(4, 1, 2, -1, -4, -2, 3, 2, 1, 2, 2), "Serie3");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie();
$DataSet->SetSerieName("January", "Serie1");
$DataSet->SetSerieName("February", "Serie2");
$DataSet->SetSerieName("March", "Serie3");

// Initialise the graph
$Test = new pChart(700, 230);
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(50, 30, 680, 200);
$Test->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230);
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE);
$Test->drawGrid(4, TRUE, 230, 230, 230, 50);

// Draw the 0 line
$Test->setFontProperties("Fonts/tahoma.ttf", 6);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);

// Draw the bar graph
$Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE, 80);


// Finish the graph
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawLegend(596, 150, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties("Fonts/tahoma.ttf", 10);
$Test->drawTitle(50, 22, "Example 12", 50, 50, 50, 585);
$Test->Render("example12.png");
?>
34 changes: 34 additions & 0 deletions src/Example13.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/*
Example13: A 2D exploded pie graph
*/

require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload

use pChart\pData;
use pChart\pChart;
use pChart\pCache;

// Dataset definition
$DataSet = new pData;
$DataSet->AddPoint(array(10, 2, 3, 5, 3), "Serie1");
$DataSet->AddPoint(array("Jan", "Feb", "Mar", "Apr", "May"), "Serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("Serie2");

// Initialise the graph
$Test = new pChart(300, 200);
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawFilledRoundedRectangle(7, 7, 293, 193, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 295, 195, 5, 230, 230, 230);

// Draw the pie chart
$Test->AntialiasQuality = 0;
$Test->setShadowProperties(2, 2, 200, 200, 200);
$Test->drawFlatPieGraphWithShadow($DataSet->GetData(), $DataSet->GetDataDescription(), 120, 100, 60, PIE_PERCENTAGE, 8);
$Test->clearShadow();

$Test->drawPieLegend(230, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250);

$Test->Render("example13.png");
?>
35 changes: 35 additions & 0 deletions src/Example14.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/*
Example14: A smooth flat pie graph
*/

require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload

use pChart\pData;
use pChart\pChart;
use pChart\pCache;

// Dataset definition
$DataSet = new pData;
$DataSet->AddPoint(array(10, 2, 3, 5, 3), "Serie1");
$DataSet->AddPoint(array("Jan", "Feb", "Mar", "Apr", "May"), "Serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("Serie2");

// Initialise the graph
$Test = new pChart(300, 200);
$Test->loadColorPalette("Sample/softtones.txt");
$Test->drawFilledRoundedRectangle(7, 7, 293, 193, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 295, 195, 5, 230, 230, 230);

// This will draw a shadow under the pie chart
$Test->drawFilledCircle(122, 102, 70, 200, 200, 200);

// Draw the pie chart
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->AntialiasQuality = 0;
$Test->drawBasicPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 120, 100, 70, PIE_PERCENTAGE, 255, 255, 218);
$Test->drawPieLegend(230, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250);

$Test->Render("example14.png");
?>
70 changes: 70 additions & 0 deletions src/Example15.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/*
Example15 : Playing with line style & pictures inclusion
*/

require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload

use pChart\pData;
use pChart\pChart;
use pChart\pCache;

// Dataset definition
$DataSet = new pData;
$DataSet->AddPoint(array(10, 9.4, 7.7, 5, 1.7, -1.7, -5, -7.7, -9.4, -10, -9.4, -7.7, -5, -1.8, 1.7), "Serie1");
$DataSet->AddPoint(array(0, 3.4, 6.4, 8.7, 9.8, 9.8, 8.7, 6.4, 3.4, 0, -3.4, -6.4, -8.6, -9.8, -9.9), "Serie2");
$DataSet->AddPoint(array(7.1, 9.1, 10, 9.7, 8.2, 5.7, 2.6, -0.9, -4.2, -7.1, -9.1, -10, -9.7, -8.2, -5.8), "Serie3");
$DataSet->AddPoint(array("Jan", "Jan", "Jan", "Feb", "Feb", "Feb", "Mar", "Mar", "Mar", "Apr", "Apr", "Apr", "May", "May", "May"), "Serie4");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("Serie4");
$DataSet->SetSerieName("Max Average", "Serie1");
$DataSet->SetSerieName("Min Average", "Serie2");
$DataSet->SetSerieName("Temperature", "Serie3");
$DataSet->SetYAxisName("Temperature");
$DataSet->SetXAxisName("Month of the year");

// Initialise the graph
$Test = new pChart(700, 230);
$Test->reportWarnings("GD");
$Test->setFixedScale(-12, 12, 5);
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(65, 30, 570, 185);
$Test->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230);
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE, 3);
$Test->drawGrid(4, TRUE, 230, 230, 230, 50);

// Draw the 0 line
$Test->setFontProperties("Fonts/tahoma.ttf", 6);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);

// Draw the area
$DataSet->RemoveSerie("Serie4");
$Test->drawArea($DataSet->GetData(), "Serie1", "Serie2", 239, 238, 227, 50);
$DataSet->RemoveSerie("Serie3");
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());

// Draw the line graph
$Test->setLineStyle(1, 6);
$DataSet->RemoveAllSeries();
$DataSet->AddSerie("Serie3");
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255);

// Write values on Serie3
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->writeValues($DataSet->GetData(), $DataSet->GetDataDescription(), "Serie3");

// Finish the graph
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawLegend(590, 90, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties("Fonts/tahoma.ttf", 10);
$Test->drawTitle(60, 22, "example 15", 50, 50, 50, 585);

// Add an image
$Test->drawFromPNG("Sample/logo.png", 584, 35);

// Render the chart
$Test->Render("example15.png");
?>
Loading

0 comments on commit 2f6ee62

Please sign in to comment.