summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 07110db)
raw | patch | inline | side by side (parent: 07110db)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 12 Aug 2010 09:16:09 +0000 (09:16 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 12 Aug 2010 09:16:09 +0000 (09:16 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19382 594d385d-05f5-0310-b6e9-bd551577e9d8
50 files changed:
diff --git a/gosa-core/include/class_pChartInclude.inc b/gosa-core/include/class_pChartInclude.inc
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+require_once("../include/pChart/pCache.class");
+require_once("../include/pChart/pChart.class");
+require_once("../include/pChart/pData.class");
+
+class pChartInclude {}
+
+?>
diff --git a/gosa-core/include/pChart/CO2.csv b/gosa-core/include/pChart/CO2.csv
--- /dev/null
@@ -0,0 +1,37 @@
+Year,Jan.,Feb.,March,April,May,June,July,Aug.,Sept.,Oct.,Nov.,Dec.,Annual\r
+1967,322.33,322.5,323.04,324.42,325,324.09,322.55,320.92,319.26,319.39,320.72,321.96,322.18\r
+1968,322.57,323.15,323.89,325.02,325.57,325.36,324.14,322.11,320.33,320.25,321.32,322.9,323.05\r
+1969,324,324.42,325.64,326.66,327.38,326.7,325.89,323.67,322.38,321.78,322.85,324.12,324.62\r
+1970,325.06,325.98,326.93,328.13,328.07,327.66,326.35,324.69,323.1,323.07,324.01,325.13,325.68\r
+1971,326.17,326.68,327.18,327.78,328.92,328.57,327.37,325.43,323.36,323.56,324.8,326.01,326.32\r
+1972,326.77,327.63,327.75,329.72,330.07,329.09,328.05,326.32,324.84,325.2,326.5,327.55,327.46\r
+1973,328.54,329.56,330.3,331.5,332.48,332.07,330.87,329.31,327.51,327.18,328.16,328.64,329.68\r
+1974,329.35,330.71,331.48,332.65,333.09,332.25,331.18,329.4,327.44,327.37,328.46,329.58,330.25\r
+1975,330.4,331.41,332.04,333.31,333.96,333.59,331.91,330.06,328.56,328.34,329.49,330.76,331.15\r
+1976,331.74,332.56,333.5,334.58,334.87,334.34,333.05,330.94,329.3,328.94,330.31,331.68,332.15\r
+1977,332.92,333.42,334.7,336.07,336.74,336.27,334.93,332.75,331.58,331.16,332.4,333.85,333.9\r
+1978,334.97,335.39,336.64,337.76,338.01,337.89,336.54,334.68,332.76,332.54,333.92,334.95,335.5\r
+1979,336.23,336.76,337.96,338.89,339.47,339.29,337.73,336.09,333.91,333.86,335.29,336.73,336.85\r
+1980,338.01,338.36,340.08,340.77,341.46,341.17,339.56,337.6,335.88,336.01,337.1,338.21,338.69\r
+1981,339.23,340.47,341.38,342.51,342.91,342.25,340.49,338.43,336.69,336.85,338.36,339.61,339.93\r
+1982,340.75,341.61,342.7,343.56,344.13,343.35,342.06,339.82,337.97,337.86,339.26,340.49,341.13\r
+1983,341.37,342.52,343.1,344.94,345.75,345.32,343.99,342.39,339.86,339.99,341.16,342.99,342.78\r
+1984,343.7,344.51,345.28,347.08,347.43,346.79,345.4,343.28,341.07,341.35,342.98,344.22,344.42\r
+1985,344.97,346,347.43,348.35,348.93,348.25,346.56,344.69,343.09,342.8,344.24,345.56,345.9\r
+1986,346.29,346.96,347.86,349.55,350.21,349.54,347.94,345.91,344.86,344.17,345.66,346.9,347.15\r
+1987,348.02,348.47,349.42,350.99,351.84,351.25,349.52,348.1,346.44,346.36,347.81,348.96,348.93\r
+1988,350.43,351.72,352.22,353.59,354.22,353.79,352.39,350.44,348.72,348.88,350.07,351.34,351.48\r
+1989,352.76,353.07,353.68,355.42,355.67,355.13,353.9,351.67,349.8,349.99,351.3,352.53,352.91\r
+1990,353.66,354.7,355.39,356.2,357.16,356.22,354.82,352.91,350.96,351.18,352.83,354.21,354.19\r
+1991,354.72,355.75,357.16,358.6,359.34,358.24,356.17,354.03,352.16,352.21,353.75,354.99,355.59\r
+1992,355.98,356.72,357.81,359.15,359.66,359.25,357.03,355,353.01,353.31,354.16,355.4,356.37\r
+1993,356.7,357.16,358.38,359.46,360.28,359.6,357.57,355.52,353.7,353.98,355.33,356.8,357.04\r
+1994,358.36,358.91,359.97,361.26,361.68,360.95,359.55,357.49,355.84,355.99,357.58,359.04,358.88\r
+1995,359.96,361,361.64,363.45,363.79,363.26,361.9,359.46,358.06,357.75,359.56,360.7,360.88\r
+1996,362.05,363.25,364.03,364.72,365.41,364.97,363.65,361.49,359.46,359.6,360.76,362.33,362.64\r
+1997,363.18,364,364.57,366.35,366.79,365.62,364.47,362.51,360.19,360.77,362.43,364.28,363.76\r
+1998,365.32,366.15,367.31,368.61,369.3,368.87,367.64,365.77,363.9,364.23,365.46,366.97,366.63\r
+1999,368.15,368.86,369.58,371.12,370.97,370.33,369.25,366.91,364.6,365.09,366.63,367.96,368.29\r
+2000,369.08,369.4,370.45,371.59,371.75,371.62,370.04,368.04,366.54,366.63,368.2,369.43,369.4\r
+2001,370.17,371.39,372,372.75,373.88,373.17,371.48,369.42,367.83,367.96,369.55,371.1,370.89\r
+2002,372.29,372.94,373.38,374.71,375.4,375.26,373.87,371.35,370.57,370.1,371.93,373.63,372.95\r
diff --git a/gosa-core/include/pChart/Example1.php b/gosa-core/include/pChart/Example1.php
--- /dev/null
@@ -0,0 +1,45 @@
+<?php \r
+ /*\r
+ Example1 : A simple line chart\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class"); \r
+ include("pChart/pChart.class"); \r
+ \r
+ // Dataset definition \r
+ $DataSet = new pData; \r
+ $DataSet->ImportFromCSV("Sample/bulkdata.csv",",",array(1,2,3),FALSE,0); \r
+ $DataSet->AddAllSeries(); \r
+ $DataSet->SetAbsciseLabelSerie(); \r
+ $DataSet->SetSerieName("January","Serie1"); \r
+ $DataSet->SetSerieName("February","Serie2"); \r
+ $DataSet->SetSerieName("March","Serie3"); \r
+ $DataSet->SetYAxisName("Average age");\r
+ $DataSet->SetYAxisUnit("µs");\r
+ \r
+ // Initialise the graph \r
+ $Test = new pChart(700,230);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8); \r
+ $Test->setGraphArea(70,30,680,200); \r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240); \r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230); \r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2); \r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+ \r
+ // Draw the 0 line \r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6); \r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE); \r
+ \r
+ // Draw the line graph\r
+ $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription()); \r
+ $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255); \r
+ \r
+ // Finish the graph \r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8); \r
+ $Test->drawLegend(75,35,$DataSet->GetDataDescription(),255,255,255); \r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10); \r
+ $Test->drawTitle(60,22,"example 1",50,50,50,585); \r
+ $Test->Render("example1.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example10.php b/gosa-core/include/pChart/Example10.php
--- /dev/null
@@ -0,0 +1,34 @@
+<?php\r
+ /*\r
+ Example10 : A 3D exploded pie graph\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(10,2,3,5,3),"Serie1");\r
+ $DataSet->AddPoint(array("January","February","March","April","May"),"Serie2");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie("Serie2");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(420,250);\r
+ $Test->drawFilledRoundedRectangle(7,7,413,243,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,415,245,5,230,230,230);\r
+ $Test->createColorGradientPalette(195,204,56,223,110,41,5);\r
+\r
+ // Draw the pie chart\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->AntialiasQuality = 0;\r
+ $Test->drawPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),180,130,110,PIE_PERCENTAGE_LABEL,FALSE,50,20,5);\r
+ $Test->drawPieLegend(330,15,$DataSet->GetData(),$DataSet->GetDataDescription(),250,250,250);\r
+\r
+ // Write the title\r
+ $Test->setFontProperties("Fonts/MankSans.ttf",10);\r
+ $Test->drawTitle(10,20,"Sales per month",100,100,100);\r
+\r
+ $Test->Render("example10.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example11.php b/gosa-core/include/pChart/Example11.php
--- /dev/null
@@ -0,0 +1,50 @@
+<?php\r
+ /*\r
+ Example11 : Using the pCache class\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+ include("pChart/pCache.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(1,4,3,2,3,3,2,1,0,7,4,3,2,3,3,5,1,0,7),"Serie1");\r
+ $DataSet->AddPoint(array(1,4,2,6,2,3,0,1,5,1,2,4,5,2,1,0,6,4,2),"Serie2");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie();\r
+ $DataSet->SetSerieName("January","Serie1");\r
+ $DataSet->SetSerieName("February","Serie2");\r
+\r
+ // Cache definition \r
+ $Cache = new pCache();\r
+ $Cache->GetFromCache("Graph1",$DataSet->GetData());\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(50,30,585,200);\r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);\r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);\r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+\r
+ // Draw the 0 line\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6);\r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);\r
+\r
+ // Draw the cubic curve graph\r
+ $Test->drawCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription());\r
+\r
+ // Finish the graph\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(600,30,$DataSet->GetDataDescription(),255,255,255);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(50,22,"Example 1",50,50,50,585);\r
+\r
+ // Render the graph\r
+ $Cache->WriteToCache("Graph1",$DataSet->GetData(),$Test);\r
+ $Test->Render("example1.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example12.php b/gosa-core/include/pChart/Example12.php
--- /dev/null
@@ -0,0 +1,45 @@
+<?php\r
+ /*\r
+ Example12 : A true bar graph\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(1,4,-3,2,-3,3,2,1,0,7,4),"Serie1");\r
+ $DataSet->AddPoint(array(3,3,-4,1,-2,2,1,0,-1,6,3),"Serie2");\r
+ $DataSet->AddPoint(array(4,1,2,-1,-4,-2,3,2,1,2,2),"Serie3");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie();\r
+ $DataSet->SetSerieName("January","Serie1");\r
+ $DataSet->SetSerieName("February","Serie2");\r
+ $DataSet->SetSerieName("March","Serie3");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(50,30,680,200);\r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);\r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2,TRUE);\r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+\r
+ // Draw the 0 line\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6);\r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);\r
+\r
+ // Draw the bar graph\r
+ $Test->drawBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),TRUE,80);\r
+\r
+\r
+ // Finish the graph\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(596,150,$DataSet->GetDataDescription(),255,255,255);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(50,22,"Example 12",50,50,50,585);\r
+ $Test->Render("example12.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example13.php b/gosa-core/include/pChart/Example13.php
--- /dev/null
@@ -0,0 +1,32 @@
+<?php\r
+ /*\r
+ Example13: A 2D exploded pie graph\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(10,2,3,5,3),"Serie1");\r
+ $DataSet->AddPoint(array("Jan","Feb","Mar","Apr","May"),"Serie2");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie("Serie2");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(300,200);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawFilledRoundedRectangle(7,7,293,193,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,295,195,5,230,230,230);\r
+\r
+ // Draw the pie chart\r
+ $Test->AntialiasQuality = 0;\r
+ $Test->setShadowProperties(2,2,200,200,200);\r
+ $Test->drawFlatPieGraphWithShadow($DataSet->GetData(),$DataSet->GetDataDescription(),120,100,60,PIE_PERCENTAGE,8);\r
+ $Test->clearShadow();\r
+\r
+ $Test->drawPieLegend(230,15,$DataSet->GetData(),$DataSet->GetDataDescription(),250,250,250);\r
+\r
+ $Test->Render("example13.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example14.php b/gosa-core/include/pChart/Example14.php
--- /dev/null
@@ -0,0 +1,33 @@
+<?php\r
+ /*\r
+ Example14: A smooth flat pie graph\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(10,2,3,5,3),"Serie1");\r
+ $DataSet->AddPoint(array("Jan","Feb","Mar","Apr","May"),"Serie2");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie("Serie2");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(300,200);\r
+ $Test->loadColorPalette("Sample/softtones.txt");\r
+ $Test->drawFilledRoundedRectangle(7,7,293,193,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,295,195,5,230,230,230);\r
+\r
+ // This will draw a shadow under the pie chart\r
+ $Test->drawFilledCircle(122,102,70,200,200,200);\r
+\r
+ // Draw the pie chart\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->AntialiasQuality = 0;\r
+ $Test->drawBasicPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),120,100,70,PIE_PERCENTAGE,255,255,218);\r
+ $Test->drawPieLegend(230,15,$DataSet->GetData(),$DataSet->GetDataDescription(),250,250,250);\r
+\r
+ $Test->Render("example14.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example15.php b/gosa-core/include/pChart/Example15.php
--- /dev/null
@@ -0,0 +1,68 @@
+<?php \r
+ /*\r
+ Example15 : Playing with line style & pictures inclusion\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class"); \r
+ include("pChart/pChart.class"); \r
+ \r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $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");\r
+ $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");\r
+ $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");\r
+ $DataSet->AddPoint(array("Jan","Jan","Jan","Feb","Feb","Feb","Mar","Mar","Mar","Apr","Apr","Apr","May","May","May"),"Serie4");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie("Serie4");\r
+ $DataSet->SetSerieName("Max Average","Serie1");\r
+ $DataSet->SetSerieName("Min Average","Serie2");\r
+ $DataSet->SetSerieName("Temperature","Serie3");\r
+ $DataSet->SetYAxisName("Temperature");\r
+ $DataSet->SetXAxisName("Month of the year");\r
+ \r
+ // Initialise the graph \r
+ $Test = new pChart(700,230);\r
+ $Test->reportWarnings("GD");\r
+ $Test->setFixedScale(-12,12,5);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8); \r
+ $Test->setGraphArea(65,30,570,185); \r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240); \r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230); \r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2,TRUE,3); \r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+\r
+ // Draw the 0 line \r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6); \r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE); \r
+ \r
+ // Draw the area\r
+ $DataSet->RemoveSerie("Serie4");\r
+ $Test->drawArea($DataSet->GetData(),"Serie1","Serie2",239,238,227,50);\r
+ $DataSet->RemoveSerie("Serie3");\r
+ $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription()); \r
+\r
+ // Draw the line graph\r
+ $Test->setLineStyle(1,6);\r
+ $DataSet->RemoveAllSeries();\r
+ $DataSet->AddSerie("Serie3");\r
+ $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription()); \r
+ $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255); \r
+\r
+ // Write values on Serie3\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8); \r
+ $Test->writeValues($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie3"); \r
+ \r
+ // Finish the graph \r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8); \r
+ $Test->drawLegend(590,90,$DataSet->GetDataDescription(),255,255,255); \r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10); \r
+ $Test->drawTitle(60,22,"example 15",50,50,50,585);\r
+\r
+ // Add an image\r
+ $Test->drawFromPNG("Sample/logo.png",584,35);\r
+\r
+ // Render the chart\r
+ $Test->Render("example15.png"); \r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example16.php b/gosa-core/include/pChart/Example16.php
--- /dev/null
@@ -0,0 +1,42 @@
+<?php\r
+ /*\r
+ Example16 : Importing CSV data\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->ImportFromCSV("Sample/CO2.csv",",",array(1,2,3,4),TRUE,0);\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie();\r
+ $DataSet->SetYAxisName("CO2 concentrations");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->reportWarnings("GD");\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(60,30,680,180);\r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);\r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,90,2);\r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+\r
+ // Draw the 0 line\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6);\r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);\r
+\r
+ // Draw the line graph\r
+ $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());\r
+ $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);\r
+\r
+ // Finish the graph\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8); \r
+ $Test->drawLegend(70,40,$DataSet->GetDataDescription(),255,255,255); \r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(60,22,"CO2 concentrations at Mauna Loa",50,50,50,585);\r
+ $Test->Render("example16.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example17.php b/gosa-core/include/pChart/Example17.php
--- /dev/null
@@ -0,0 +1,48 @@
+<?php \r
+ /*\r
+ Example17 : Playing with axis\r
+ */\r
+\r
+ // Standard inclusions\r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+ \r
+ // Dataset definition\r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(100,320,200,10,43),"Serie1");\r
+ $DataSet->AddPoint(array(23,432,43,153,234),"Serie2");\r
+ $DataSet->AddPoint(array(1217541600,1217628000,1217714400,1217800800,1217887200),"Serie3");\r
+ $DataSet->AddSerie("Serie1");\r
+ $DataSet->AddSerie("Serie2");\r
+ $DataSet->SetAbsciseLabelSerie("Serie3");\r
+ $DataSet->SetSerieName("Incoming","Serie1");\r
+ $DataSet->SetSerieName("Outgoing","Serie2");\r
+ $DataSet->SetYAxisName("Call duration");\r
+ $DataSet->SetYAxisFormat("time");\r
+ $DataSet->SetXAxisFormat("date");\r
+\r
+ // Initialise the graph \r
+ $Test = new pChart(700,230);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(85,30,650,200);\r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);\r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);\r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+ \r
+ // Draw the 0 line \r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6);\r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);\r
+ \r
+ // Draw the line graph\r
+ $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());\r
+ $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);\r
+ \r
+ // Finish the graph\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(90,35,$DataSet->GetDataDescription(),255,255,255);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(60,22,"example 17",50,50,50,585);\r
+ $Test->Render("example17.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example18.php b/gosa-core/include/pChart/Example18.php
--- /dev/null
@@ -0,0 +1,55 @@
+<?php\r
+ /*\r
+ Example18 : Missing values\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(2,5,7,"","",5,6,4,8,4,"",2,5,6,4,5,6,7,6),"Serie1");\r
+ $DataSet->AddPoint(array(-1,-3,-1,-2,-4,-1,"",-4,-5,-3,-2,-2,-3,-3,-5,-4,-3,-1,""),"Serie2");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie();\r
+ $DataSet->SetSerieName("Raw #1","Serie1");\r
+ $DataSet->SetSerieName("Raw #2","Serie2");\r
+ $DataSet->SetYAxisName("Response time");\r
+ $DataSet->SetXAxisName("Sample #ID");\r
+\r
+ //print_r($DataSet->GetData());\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(55,30,585,185);\r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);\r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2,TRUE);\r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+\r
+ // Draw the 0 line\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6);\r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);\r
+\r
+ // Draw the line graph\r
+ $DataSet->RemoveSerie("Serie2");\r
+ $Test->drawFilledLineGraph($DataSet->GetData(),$DataSet->GetDataDescription(),60,TRUE); \r
+\r
+ // Draw the curve graph\r
+ $DataSet->RemoveSerie("Serie1");\r
+ $DataSet->AddSerie("Serie2");\r
+ $Test->setShadowProperties(2,2,200,200,200,50);\r
+ $Test->drawCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription());\r
+ $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255); \r
+ $Test->clearShadow();\r
+\r
+ // Finish the graph\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(600,30,$DataSet->GetDataDescription(),255,255,255);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(50,22,"Example 18",50,50,50,585);\r
+ $Test->Render("example18.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example19.php b/gosa-core/include/pChart/Example19.php
--- /dev/null
@@ -0,0 +1,44 @@
+<?php\r
+ /*\r
+ Example19 : Error reporting\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(10,4,3,2,3,3,2,1,0,7,4,3,2,3,3,5,1,0,7),"Serie1");\r
+ $DataSet->AddPoint(array(1,4,2,6,2,3,0,1,-5,1,2,4,5,2,1,0,6,4,30),"Serie2");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie();\r
+ $DataSet->SetXAxisName("Samples");\r
+ $DataSet->SetYAxisName("Temperature");\r
+ $DataSet->SetSerieName("January","Serie1");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->reportWarnings("GD");\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(60,30,585,185);\r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);\r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);\r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+\r
+ // Draw the 0 line\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6);\r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);\r
+\r
+ // Draw the cubic curve graph\r
+ $Test->drawCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription());\r
+\r
+ // Finish the graph\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(600,30,$DataSet->GetDataDescription(),255,255,255);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(50,22,"Example 19",50,50,50,585);\r
+ $Test->Render("example19.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example2.php b/gosa-core/include/pChart/Example2.php
--- /dev/null
@@ -0,0 +1,43 @@
+<?php\r
+ /*\r
+ Example2 : A cubic curve graph\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(1,4,3,4,3,3,2,1,0,7,4,3,2,3,3,5,1,0,7),"Serie1");\r
+ $DataSet->AddPoint(array(1,4,2,6,2,3,0,1,5,1,2,4,5,2,1,0,6,4,2),"Serie2");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie();\r
+ $DataSet->SetSerieName("January","Serie1");\r
+ $DataSet->SetSerieName("February","Serie2");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->setFixedScale(-2,8);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(50,30,585,200);\r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);\r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);\r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+\r
+ // Draw the 0 line\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6);\r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);\r
+\r
+ // Draw the cubic curve graph\r
+ $Test->drawCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription());\r
+\r
+ // Finish the graph\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(600,30,$DataSet->GetDataDescription(),255,255,255);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(50,22,"Example 2",50,50,50,585);\r
+ $Test->Render("example2.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example20.php b/gosa-core/include/pChart/Example20.php
--- /dev/null
@@ -0,0 +1,44 @@
+<?php\r
+ /*\r
+ Example20 : A stacked bar graph\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(1,4,-3,2,-3,3,2,1,0,7,4),"Serie1");\r
+ $DataSet->AddPoint(array(3,3,-4,1,-2,2,1,0,-1,6,3),"Serie2");\r
+ $DataSet->AddPoint(array(4,1,2,-1,-4,-2,3,2,1,2,2),"Serie3");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie();\r
+ $DataSet->SetSerieName("January","Serie1");\r
+ $DataSet->SetSerieName("February","Serie2");\r
+ $DataSet->SetSerieName("March","Serie3");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(50,30,680,200);\r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);\r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_ADDALL,150,150,150,TRUE,0,2,TRUE);\r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+\r
+ // Draw the 0 line\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6);\r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);\r
+\r
+ // Draw the bar graph\r
+ $Test->drawStackedBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),100);\r
+\r
+ // Finish the graph\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(596,150,$DataSet->GetDataDescription(),255,255,255);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(50,22,"Example 20",50,50,50,585);\r
+ $Test->Render("example20.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example21.php b/gosa-core/include/pChart/Example21.php
--- /dev/null
@@ -0,0 +1,53 @@
+<?php\r
+ /*\r
+ Example21 : Playing with background\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(9,9,9,10,10,11,12,14,16,17,18,18,19,19,18,15,12,10,9),"Serie1");\r
+ $DataSet->AddPoint(array(10,11,11,12,12,13,14,15,17,19,22,24,23,23,22,20,18,16,14),"Serie2");\r
+ $DataSet->AddPoint(array(4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22),"Serie3");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->RemoveSerie("Serie3");\r
+ $DataSet->SetAbsciseLabelSerie("Serie3");\r
+ $DataSet->SetSerieName("January","Serie1");\r
+ $DataSet->SetSerieName("February","Serie2");\r
+ $DataSet->SetYAxisName("Temperature");\r
+ $DataSet->SetYAxisUnit("°C");\r
+ $DataSet->SetXAxisUnit("h");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->drawGraphAreaGradient(132,153,172,50,TARGET_BACKGROUND);\r
+\r
+ // Graph area setup\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(60,20,585,180);\r
+ $Test->drawGraphArea(213,217,221,FALSE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,213,217,221,TRUE,0,2);\r
+ $Test->drawGraphAreaGradient(162,183,202,50);\r
+ $Test->drawGrid(4,TRUE,230,230,230,20);\r
+\r
+ // Draw the line chart\r
+ $Test->setShadowProperties(3,3,0,0,0,30,4);\r
+ $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());\r
+ $Test->clearShadow();\r
+ $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),4,2,-1,-1,-1,TRUE);\r
+\r
+ // Draw the legend\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(605,142,$DataSet->GetDataDescription(),236,238,240,52,58,82);\r
+\r
+ // Draw the title\r
+ $Title = "Average Temperatures during the first months of 2008 ";\r
+ $Test->drawTextBox(0,210,700,230,$Title,0,255,255,255,ALIGN_RIGHT,TRUE,0,0,0,30);\r
+\r
+ // Render the picture\r
+ $Test->addBorder(2);\r
+ $Test->Render("example21.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example22.php b/gosa-core/include/pChart/Example22.php
--- /dev/null
@@ -0,0 +1,50 @@
+<?php \r
+ /*\r
+ Example22 : Customizing plot graphs\r
+ */\r
+\r
+ // Standard inclusions\r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+ \r
+ // Dataset definition\r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(60,70,90,110,100,90),"Serie1");\r
+ $DataSet->AddPoint(array(40,50,60,80,70,60),"Serie2");\r
+ $DataSet->AddPoint(array("Jan","Feb","Mar","Apr","May","Jun"),"Serie3");\r
+ $DataSet->AddSerie("Serie1");\r
+ $DataSet->AddSerie("Serie2");\r
+ $DataSet->SetAbsciseLabelSerie("Serie3");\r
+ $DataSet->SetSerieName("Company A","Serie1");\r
+ $DataSet->SetSerieName("Company B","Serie2");\r
+ $DataSet->SetYAxisName("Product sales");\r
+ $DataSet->SetYAxisUnit("k");\r
+ $DataSet->SetSerieSymbol("Serie1","Sample/Point_Asterisk.gif");\r
+ $DataSet->SetSerieSymbol("Serie2","Sample/Point_Cd.gif");\r
+\r
+ // Initialise the graph \r
+ $Test = new pChart(700,230);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(65,30,650,200);\r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);\r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2,TRUE);\r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+ \r
+ // Draw the title\r
+ $Test->setFontProperties("Fonts/pf_arma_five.ttf",6);\r
+ $Title = "Comparative product sales for company A & B ";\r
+ $Test->drawTextBox(65,30,650,45,$Title,0,255,255,255,ALIGN_RIGHT,TRUE,0,0,0,30);\r
+ \r
+ // Draw the line graph\r
+ $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());\r
+ $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);\r
+ \r
+ // Draw the legend\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(80,60,$DataSet->GetDataDescription(),255,255,255);\r
+\r
+ // Render the chart\r
+ $Test->Render("example22.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example23.php b/gosa-core/include/pChart/Example23.php
--- /dev/null
@@ -0,0 +1,49 @@
+<?php\r
+ /*\r
+ Example23 : Playing with background bis\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(9,9,9,10,10,11,12,14,16,17,18,18,19,19,18,15,12,10,9),"Serie1");\r
+ $DataSet->AddPoint(array(10,11,11,12,12,13,14,15,17,19,22,24,23,23,22,20,18,16,14),"Serie2");\r
+ $DataSet->AddPoint(array(4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22),"Serie3");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->RemoveSerie("Serie3");\r
+ $DataSet->SetAbsciseLabelSerie("Serie3");\r
+ $DataSet->SetSerieName("January","Serie1");\r
+ $DataSet->SetSerieName("February","Serie2");\r
+ $DataSet->SetYAxisName("Temperature");\r
+ $DataSet->SetYAxisUnit("°C");\r
+ $DataSet->SetXAxisUnit("h");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->drawGraphAreaGradient(132,173,131,50,TARGET_BACKGROUND);\r
+\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(120,20,675,190);\r
+ $Test->drawGraphArea(213,217,221,FALSE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_ADDALL,213,217,221,TRUE,0,2,TRUE);\r
+ $Test->drawGraphAreaGradient(163,203,167,50);\r
+ $Test->drawGrid(4,TRUE,230,230,230,20);\r
+\r
+ // Draw the bar chart\r
+ $Test->drawStackedBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),70);\r
+\r
+ // Draw the title\r
+ $Title = " Average Temperatures during\r\n the first months of 2008 ";\r
+ $Test->drawTextBox(0,0,50,230,$Title,90,255,255,255,ALIGN_BOTTOM_CENTER,TRUE,0,0,0,30);\r
+\r
+ // Draw the legend\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(610,10,$DataSet->GetDataDescription(),236,238,240,52,58,82);\r
+\r
+ // Render the picture\r
+ $Test->addBorder(2);\r
+ $Test->Render("example23.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example24.php b/gosa-core/include/pChart/Example24.php
--- /dev/null
@@ -0,0 +1,53 @@
+<?php\r
+ /*\r
+ Example24 : X versus Y chart\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+\r
+ // Compute the points\r
+ for($i=0;$i<=360;$i=$i+10)\r
+ {\r
+ $DataSet->AddPoint(cos($i*3.14/180)*80+$i,"Serie1");\r
+ $DataSet->AddPoint(sin($i*3.14/180)*80+$i,"Serie2");\r
+ }\r
+\r
+ $DataSet->SetSerieName("Trigonometric function","Serie1");\r
+ $DataSet->AddSerie("Serie1");\r
+ $DataSet->AddSerie("Serie2");\r
+ $DataSet->SetXAxisName("X Axis");\r
+ $DataSet->SetYAxisName("Y Axis");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(300,300);\r
+ $Test->drawGraphAreaGradient(0,0,0,-100,TARGET_BACKGROUND);\r
+\r
+ // Prepare the graph area\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(55,30,270,230);\r
+ $Test->drawXYScale($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie2",213,217,221,TRUE,45);\r
+ $Test->drawGraphArea(213,217,221,FALSE);\r
+ $Test->drawGraphAreaGradient(30,30,30,-50);\r
+ $Test->drawGrid(4,TRUE,230,230,230,20);\r
+\r
+ // Draw the chart\r
+ $Test->setShadowProperties(2,2,0,0,0,60,4);\r
+ $Test->drawXYGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie2",0);\r
+ $Test->clearShadow();\r
+\r
+ // Draw the title\r
+ $Title = "Drawing X versus Y charts trigonometric functions ";\r
+ $Test->drawTextBox(0,280,300,300,$Title,0,255,255,255,ALIGN_RIGHT,TRUE,0,0,0,30);\r
+\r
+ // Draw the legend\r
+ $Test->setFontProperties("Fonts/pf_arma_five.ttf",6);\r
+ $DataSet->RemoveSerie("Serie2");\r
+ $Test->drawLegend(160,5,$DataSet->GetDataDescription(),0,0,0,0,0,0,255,255,255,FALSE);\r
+\r
+ $Test->Render("example24.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example25.php b/gosa-core/include/pChart/Example25.php
--- /dev/null
@@ -0,0 +1,55 @@
+<?php\r
+ /*\r
+ Example25 : Playing with shadow\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(9,9,9,10,10,11,12,14,16,17,18,18,19,19,18,15,12,10,9),"Serie1");\r
+ $DataSet->AddPoint(array(10,11,11,12,12,13,14,15,17,19,22,24,23,23,22,20,18,16,14),"Serie2");\r
+ $DataSet->AddPoint(array(4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22),"Serie3");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->RemoveSerie("Serie3");\r
+ $DataSet->SetAbsciseLabelSerie("Serie3");\r
+ $DataSet->SetSerieName("January","Serie1");\r
+ $DataSet->SetSerieName("February","Serie2");\r
+ $DataSet->SetYAxisName("Temperature");\r
+ $DataSet->SetYAxisUnit("°C");\r
+ $DataSet->SetXAxisUnit("h");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->drawGraphAreaGradient(90,90,90,90,TARGET_BACKGROUND);\r
+ $Test->setFixedScale(0,40,4);\r
+\r
+ // Graph area setup\r
+ $Test->setFontProperties("Fonts/pf_arma_five.ttf",6);\r
+ $Test->setGraphArea(60,40,680,200);\r
+ $Test->drawGraphArea(200,200,200,FALSE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,200,200,200,TRUE,0,2);\r
+ $Test->drawGraphAreaGradient(40,40,40,-50);\r
+ $Test->drawGrid(4,TRUE,230,230,230,10);\r
+\r
+ // Draw the line chart\r
+ $Test->setShadowProperties(3,3,0,0,0,30,4);\r
+ $Test->drawCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription());\r
+ $Test->clearShadow();\r
+ $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,0,-1,-1,-1,TRUE);\r
+\r
+ // Write the title\r
+ $Test->setFontProperties("Fonts/MankSans.ttf",18);\r
+ $Test->setShadowProperties(1,1,0,0,0);\r
+ $Test->drawTitle(0,0,"Average temperatures",255,255,255,700,30,TRUE);\r
+ $Test->clearShadow();\r
+\r
+ // Draw the legend\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(610,5,$DataSet->GetDataDescription(),0,0,0,0,0,0,255,255,255,FALSE);\r
+\r
+ // Render the picture\r
+ $Test->Render("example25.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example26.php b/gosa-core/include/pChart/Example26.php
--- /dev/null
@@ -0,0 +1,69 @@
+<?php\r
+ /*\r
+ Example26 : Two Y axis / shadow demonstration\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(110,101,118,108,110,106,104),"Serie1");\r
+ $DataSet->AddPoint(array(700,2705,2041,1712,2051,846,903),"Serie2");\r
+ $DataSet->AddPoint(array("03 Oct","02 Oct","01 Oct","30 Sep","29 Sep","28 Sep","27 Sep"),"Serie3");\r
+ $DataSet->AddSerie("Serie1");\r
+ $DataSet->SetAbsciseLabelSerie("Serie3");\r
+ $DataSet->SetSerieName("SourceForge Rank","Serie1");\r
+ $DataSet->SetSerieName("Web Hits","Serie2");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(660,230);\r
+ $Test->drawGraphAreaGradient(90,90,90,90,TARGET_BACKGROUND);\r
+\r
+ // Prepare the graph area\r
+ $Test->setFontProperties("fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(60,40,595,190);\r
+\r
+ // Initialise graph area\r
+ $Test->setFontProperties("fonts/tahoma.ttf",8);\r
+\r
+ // Draw the SourceForge Rank graph\r
+ $DataSet->SetYAxisName("Sourceforge Rank");\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,213,217,221,TRUE,0,0);\r
+ $Test->drawGraphAreaGradient(40,40,40,-50);\r
+ $Test->drawGrid(4,TRUE,230,230,230,10);\r
+ $Test->setShadowProperties(3,3,0,0,0,30,4);\r
+ $Test->drawCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription());\r
+ $Test->clearShadow();\r
+ $Test->drawFilledCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription(),.1,30);\r
+ $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);\r
+\r
+ // Clear the scale\r
+ $Test->clearScale();\r
+\r
+ // Draw the 2nd graph\r
+ $DataSet->RemoveSerie("Serie1");\r
+ $DataSet->AddSerie("Serie2");\r
+ $DataSet->SetYAxisName("Web Hits");\r
+ $Test->drawRightScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,213,217,221,TRUE,0,0);\r
+ $Test->drawGrid(4,TRUE,230,230,230,10);\r
+ $Test->setShadowProperties(3,3,0,0,0,30,4);\r
+ $Test->drawCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription());\r
+ $Test->clearShadow();\r
+ $Test->drawFilledCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription(),.1,30);\r
+ $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);\r
+\r
+ // Write the legend (box less)\r
+ $Test->setFontProperties("fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(530,5,$DataSet->GetDataDescription(),0,0,0,0,0,0,255,255,255,FALSE);\r
+\r
+ // Write the title\r
+ $Test->setFontProperties("fonts/MankSans.ttf",18);\r
+ $Test->setShadowProperties(1,1,0,0,0);\r
+ $Test->drawTitle(0,0,"SourceForge ranking summary",255,255,255,660,30,TRUE);\r
+ $Test->clearShadow();\r
+\r
+ // Render the picture\r
+ $Test->Render("example26.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example3.php b/gosa-core/include/pChart/Example3.php
--- /dev/null
@@ -0,0 +1,42 @@
+<?php\r
+ /*\r
+ Example3 : an overlayed bar graph, uggly no?\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(1,4,-3,2,-3,3,2,1,0,7,4,-3,2,-3,3,5,1,0,7),"Serie1");\r
+ $DataSet->AddPoint(array(0,3,-4,1,-2,2,1,0,-1,6,3,-4,1,-4,2,4,0,-1,6),"Serie2");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie();\r
+ $DataSet->SetSerieName("January","Serie1");\r
+ $DataSet->SetSerieName("February","Serie2");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(50,30,585,200);\r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);\r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2,TRUE);\r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+\r
+ // Draw the 0 line\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6);\r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);\r
+\r
+ // Draw the bar graph\r
+ $Test->drawOverlayBarGraph($DataSet->GetData(),$DataSet->GetDataDescription());\r
+\r
+ // Finish the graph\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(600,30,$DataSet->GetDataDescription(),255,255,255);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(50,22,"Example 3",50,50,50,585);\r
+ $Test->Render("example3.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example4.php b/gosa-core/include/pChart/Example4.php
--- /dev/null
@@ -0,0 +1,45 @@
+<?php\r
+ /*\r
+ Example4 : Showing how to draw area\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->ImportFromCSV("Sample/datawithtitle.csv",",",array(1,2,3),TRUE,0);\r
+ $DataSet->AddSerie("Serie2");\r
+ $DataSet->SetAbsciseLabelSerie();\r
+ $DataSet->removeSerieName("Serie1");\r
+ $DataSet->removeSerieName("Serie3");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(60,30,680,200);\r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);\r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);\r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+\r
+ // Draw the 0 line\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6);\r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);\r
+\r
+ // Draw the area\r
+ $Test->drawArea($DataSet->GetData(),"Serie1","Serie3",239,238,227,50);\r
+\r
+ // Draw the line graph\r
+ $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());\r
+ $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);\r
+\r
+ // Finish the graph\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(65,35,$DataSet->GetDataDescription(),250,250,250);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(60,22,"Example 4",50,50,50,585);\r
+ $Test->Render("example4.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example5.php b/gosa-core/include/pChart/Example5.php
--- /dev/null
@@ -0,0 +1,42 @@
+<?php\r
+ /*\r
+ Example5 : A limits graph\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(1,4,-3,2,-3,3,2,1,0,7,4,-3,2,-3,3,5,1,0,7),"Serie1");\r
+ $DataSet->AddPoint(array(2,5,7,5,1,5,6,4,8,4,0,2,5,6,4,5,6,7,6),"Serie2");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie();\r
+ $DataSet->SetSerieName("January","Serie1");\r
+ $DataSet->SetSerieName("February","Serie2");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(50,30,585,200);\r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);\r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2,TRUE);\r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+\r
+ // Draw the 0 line\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6);\r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);\r
+\r
+ // Draw the limit graph\r
+ $Test->drawLimitsGraph($DataSet->GetData(),$DataSet->GetDataDescription(),180,180,180);\r
+\r
+ // Finish the graph\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(600,30,$DataSet->GetDataDescription(),255,255,255);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(50,22,"Example 5",50,50,50,585);\r
+ $Test->Render("example5.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example6.php b/gosa-core/include/pChart/Example6.php
--- /dev/null
@@ -0,0 +1,39 @@
+<?php\r
+ /*\r
+ Example6 : A simple filled line graph\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->ImportFromCSV("Sample/datawithtitle.csv",",",array(1,2,3),TRUE,0);\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie();\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(60,30,680,200);\r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);\r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);\r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+\r
+ // Draw the 0 line\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6);\r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);\r
+\r
+ // Draw the filled line graph\r
+ $Test->drawFilledLineGraph($DataSet->GetData(),$DataSet->GetDataDescription(),50,TRUE);\r
+\r
+ // Finish the graph\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(65,35,$DataSet->GetDataDescription(),255,255,255);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(60,22,"Example 6",50,50,50,585);\r
+ $Test->Render("example6.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example7.php b/gosa-core/include/pChart/Example7.php
--- /dev/null
@@ -0,0 +1,42 @@
+<?php\r
+ /*\r
+ Example7 : A filled cubic curve graph\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(1,4,3,2,3,3,2,1,0,7,4,3,2,3,3,5,1,0,7),"Serie1");\r
+ $DataSet->AddPoint(array(1,4,2,6,2,3,0,1,5,1,2,4,5,2,1,0,6,4,2),"Serie2");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie();\r
+ $DataSet->SetSerieName("January","Serie1");\r
+ $DataSet->SetSerieName("February","Serie2");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(50,30,585,200);\r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);\r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);\r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+\r
+ // Draw the 0 line\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6);\r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);\r
+\r
+ // Draw the cubic curve graph\r
+ $Test->drawFilledCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription(),.1,50);\r
+\r
+ // Finish the graph\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(600,30,$DataSet->GetDataDescription(),255,255,255);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(50,22,"Example 7",50,50,50,585);\r
+ $Test->Render("example7.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example8.php b/gosa-core/include/pChart/Example8.php
--- /dev/null
@@ -0,0 +1,41 @@
+<?php\r
+ /*\r
+ Example8 : A radar graph\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array("Memory","Disk","Network","Slots","CPU"),"Label");\r
+ $DataSet->AddPoint(array(1,2,3,4,3),"Serie1");\r
+ $DataSet->AddPoint(array(1,4,2,6,2),"Serie2");\r
+ $DataSet->AddSerie("Serie1");\r
+ $DataSet->AddSerie("Serie2");\r
+ $DataSet->SetAbsciseLabelSerie("Label");\r
+\r
+\r
+ $DataSet->SetSerieName("Reference","Serie1");\r
+ $DataSet->SetSerieName("Tested computer","Serie2");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(400,400);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawFilledRoundedRectangle(7,7,393,393,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,395,395,5,230,230,230);\r
+ $Test->setGraphArea(30,30,370,370);\r
+ $Test->drawFilledRoundedRectangle(30,30,370,370,5,255,255,255);\r
+ $Test->drawRoundedRectangle(30,30,370,370,5,220,220,220);\r
+\r
+ // Draw the radar graph\r
+ $Test->drawRadarAxis($DataSet->GetData(),$DataSet->GetDataDescription(),TRUE,20,120,120,120,230,230,230);\r
+ $Test->drawFilledRadar($DataSet->GetData(),$DataSet->GetDataDescription(),50,20);\r
+\r
+ // Finish the graph\r
+ $Test->drawLegend(15,15,$DataSet->GetDataDescription(),255,255,255);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(0,22,"Example 8",50,50,50,400);\r
+ $Test->Render("example8.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Example9.php b/gosa-core/include/pChart/Example9.php
--- /dev/null
@@ -0,0 +1,49 @@
+<?php\r
+ /*\r
+ Example9 : Showing how to use labels\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(0,70,70,0,0,70,70,0,0,70),"Serie1");\r
+ $DataSet->AddPoint(array(0.5,2,4.5,8,12.5,18,24.5,32,40.5,50),"Serie2");\r
+\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie();\r
+ $DataSet->SetSerieName("January","Serie1");\r
+ $DataSet->SetSerieName("February","Serie2");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(50,30,585,200);\r
+ $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);\r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);\r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+\r
+ // Draw the 0 line\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6);\r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);\r
+\r
+ // Draw the line graph\r
+ $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());\r
+ $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);\r
+\r
+ // Set labels\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setLabel($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","2","Daily incomes",221,230,174);\r
+ $Test->setLabel($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie2","6","Production break",239,233,195);\r
+\r
+ // Finish the graph\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(600,30,$DataSet->GetDataDescription(),255,255,255);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(50,22,"Example 9",50,50,50,585);\r
+ $Test->Render("example9.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/GeosansLight.ttf b/gosa-core/include/pChart/GeosansLight.ttf
new file mode 100644 (file)
index 0000000..055932a
Binary files /dev/null and b/gosa-core/include/pChart/GeosansLight.ttf differ
index 0000000..055932a
Binary files /dev/null and b/gosa-core/include/pChart/GeosansLight.ttf differ
diff --git a/gosa-core/include/pChart/HomePage3.php b/gosa-core/include/pChart/HomePage3.php
--- /dev/null
@@ -0,0 +1,70 @@
+<?php\r
+ /*\r
+ Example21 : A single stacked bar graph\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(1,2,5),"Serie1");\r
+ $DataSet->AddPoint(array(3,2,2),"Serie2");\r
+ $DataSet->AddPoint(array(3,4,1),"Serie3");\r
+ $DataSet->AddPoint(array("A#~1","A#~2","A#~3"),"Labels");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->RemoveSerie("Labels");\r
+ $DataSet->SetAbsciseLabelSerie("Labels");\r
+ $DataSet->SetSerieName("Alpha","Serie1");\r
+ $DataSet->SetSerieName("Beta","Serie2");\r
+ $DataSet->SetSerieName("Gama","Serie3");\r
+ $DataSet->SetXAxisName("Samples IDs");\r
+ $DataSet->SetYAxisName("Test Marker");\r
+ $DataSet->SetYAxisUnit("µm");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(380,400);\r
+ $Test->drawGraphAreaGradient(90,90,90,90,TARGET_BACKGROUND);\r
+\r
+ // Graph area setup\r
+ $Test->setFontProperties("Fonts/pf_arma_five.ttf",6);\r
+ $Test->setGraphArea(110,180,350,360);\r
+ $Test->drawGraphArea(213,217,221,FALSE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_ADDALLSTART0,213,217,221,TRUE,0,2,TRUE);\r
+ $Test->drawGraphAreaGradient(40,40,40,-50);\r
+ $Test->drawGrid(4,TRUE,230,230,230,5);\r
+\r
+ // Draw the title \r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Title = " Average growth size for selected\r\n DNA samples "; \r
+ $Test->setLineStyle(2);\r
+ $Test->drawLine(51,-2,51,402,0,0,0); \r
+ $Test->setLineStyle(1);\r
+ $Test->drawTextBox(0,0,50,400,$Title,90,255,255,255,ALIGN_BOTTOM_CENTER,TRUE,0,0,0,30); \r
+ $Test->setFontProperties("Fonts/pf_arma_five.ttf",6);\r
+\r
+ // Draw the bar graph\r
+ $Test->drawStackedBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),70);\r
+\r
+ // Second chart\r
+ $DataSet->SetXAxisName("");\r
+ $Test->clearScale();\r
+ $Test->setGraphArea(110,20,350,140);\r
+ $Test->drawGraphArea(213,217,221,FALSE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,213,217,221,TRUE,0,2);\r
+ $Test->drawGraphAreaGradient(40,40,40,-50);\r
+ $Test->drawGrid(4,TRUE,230,230,230,5);\r
+\r
+ // Draw the line chart\r
+ $Test->setShadowProperties(0,3,0,0,0,30,4);\r
+ $Test->drawFilledCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription(),.1,40);\r
+ $Test->clearShadow();\r
+\r
+ // Write the legend\r
+ $Test->drawLegend(-2,3,$DataSet->GetDataDescription(),0,0,0,0,0,0,255,255,255,FALSE);\r
+\r
+ // Finish the graph\r
+ $Test->addBorder(1);\r
+ $Test->Render("HomePage2.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/MankSans.ttf b/gosa-core/include/pChart/MankSans.ttf
new file mode 100644 (file)
index 0000000..a6146a9
Binary files /dev/null and b/gosa-core/include/pChart/MankSans.ttf differ
index 0000000..a6146a9
Binary files /dev/null and b/gosa-core/include/pChart/MankSans.ttf differ
diff --git a/gosa-core/include/pChart/Naked.php b/gosa-core/include/pChart/Naked.php
--- /dev/null
@@ -0,0 +1,34 @@
+<?php\r
+ /*\r
+ Naked: Naked and easy!\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(1,4,3,2,3,3,2,1,0,7,4,3,2,3,3,5,1,0,7));\r
+ $DataSet->AddSerie();\r
+ $DataSet->SetSerieName("Sample data","Serie1");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(700,230);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->setGraphArea(40,30,680,200);\r
+ $Test->drawGraphArea(252,252,252,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);\r
+ $Test->drawGrid(4,TRUE,230,230,230,70);\r
+\r
+ // Draw the line graph\r
+ $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());\r
+ $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);\r
+\r
+ // Finish the graph\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(45,35,$DataSet->GetDataDescription(),255,255,255);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(60,22,"My pretty graph",50,50,50,585);\r
+ $Test->Render("Naked.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/Point_Asterisk.gif b/gosa-core/include/pChart/Point_Asterisk.gif
new file mode 100644 (file)
index 0000000..f75e9b8
Binary files /dev/null and b/gosa-core/include/pChart/Point_Asterisk.gif differ
index 0000000..f75e9b8
Binary files /dev/null and b/gosa-core/include/pChart/Point_Asterisk.gif differ
diff --git a/gosa-core/include/pChart/Point_Cd.gif b/gosa-core/include/pChart/Point_Cd.gif
new file mode 100644 (file)
index 0000000..814c642
Binary files /dev/null and b/gosa-core/include/pChart/Point_Cd.gif differ
index 0000000..814c642
Binary files /dev/null and b/gosa-core/include/pChart/Point_Cd.gif differ
diff --git a/gosa-core/include/pChart/Sav143.tmp b/gosa-core/include/pChart/Sav143.tmp
diff --git a/gosa-core/include/pChart/Silkscreen.ttf b/gosa-core/include/pChart/Silkscreen.ttf
new file mode 100644 (file)
index 0000000..ae4425d
Binary files /dev/null and b/gosa-core/include/pChart/Silkscreen.ttf differ
index 0000000..ae4425d
Binary files /dev/null and b/gosa-core/include/pChart/Silkscreen.ttf differ
diff --git a/gosa-core/include/pChart/SmallGraph.php b/gosa-core/include/pChart/SmallGraph.php
--- /dev/null
@@ -0,0 +1,30 @@
+<?php\r
+ /*\r
+ SmallGraph: Let's go fast, draw small!\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(array(1,4,-3,2,-3,3,2,1,0,7,4,-3,2,-3,3,5,1,0,7),"Serie1");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->SetAbsciseLabelSerie();\r
+ $DataSet->SetSerieName("January","Serie1");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(100,30);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawFilledRoundedRectangle(2,2,98,28,2,230,230,230);\r
+ $Test->setGraphArea(5,5,95,25);\r
+ $Test->drawGraphArea(255,255,255);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,220,220,220,FALSE);\r
+\r
+ // Draw the line graph\r
+ $Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());\r
+\r
+ // Finish the graph\r
+ $Test->Render("SmallGraph.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/SmallStacked.php b/gosa-core/include/pChart/SmallStacked.php
--- /dev/null
@@ -0,0 +1,48 @@
+<?php\r
+ /*\r
+ Example21 : A single stacked bar graph\r
+ */\r
+\r
+ // Standard inclusions \r
+ include("pChart/pData.class");\r
+ include("pChart/pChart.class");\r
+\r
+ // Dataset definition \r
+ $DataSet = new pData;\r
+ $DataSet->AddPoint(1,"Serie1");\r
+ $DataSet->AddPoint(3,"Serie2");\r
+ $DataSet->AddPoint(3,"Serie3");\r
+ $DataSet->AddPoint("A#~1","Labels");\r
+ $DataSet->AddAllSeries();\r
+ $DataSet->RemoveSerie("Labels");\r
+ $DataSet->SetAbsciseLabelSerie("Labels");\r
+ $DataSet->SetSerieName("Alpha","Serie1");\r
+ $DataSet->SetSerieName("Beta","Serie2");\r
+ $DataSet->SetSerieName("Gama","Serie3");\r
+ $DataSet->SetYAxisName("Test Marker");\r
+ $DataSet->SetYAxisUnit("µm");\r
+\r
+ // Initialise the graph\r
+ $Test = new pChart(210,230);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->setGraphArea(65,30,125,200);\r
+ $Test->drawFilledRoundedRectangle(7,7,203,223,5,240,240,240);\r
+ $Test->drawRoundedRectangle(5,5,205,225,5,230,230,230);\r
+ $Test->drawGraphArea(255,255,255,TRUE);\r
+ $Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_ADDALLSTART0,150,150,150,TRUE,0,2,TRUE);\r
+ $Test->drawGrid(4,TRUE,230,230,230,50);\r
+\r
+ // Draw the 0 line\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",6);\r
+ $Test->drawTreshold(0,143,55,72,TRUE,TRUE);\r
+\r
+ // Draw the bar graph\r
+ $Test->drawStackedBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),50);\r
+\r
+ // Finish the graph\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",8);\r
+ $Test->drawLegend(135,150,$DataSet->GetDataDescription(),255,255,255);\r
+ $Test->setFontProperties("Fonts/tahoma.ttf",10);\r
+ $Test->drawTitle(0,22,"Sample size",50,50,50,210);\r
+ $Test->Render("SmallStacked.png");\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/buildAll.cmd b/gosa-core/include/pChart/buildAll.cmd
--- /dev/null
@@ -0,0 +1,63 @@
+ECHO OFF\r
+CLS\r
+ECHO Processing all examples\r
+ECHO.\r
+ECHO [01/28] A simple line chart\r
+ php -q %~dp0Example1.php\r
+ECHO [02/28] A cubic curve graph\r
+ php -q %~dp0Example2.php\r
+ECHO [03/28] An overlayed bar graph\r
+ php -q %~dp0Example3.php\r
+ECHO [04/28] Showing how to draw area\r
+ php -q %~dp0Example4.php\r
+ECHO [05/28] A limits graph\r
+ php -q %~dp0Example5.php\r
+ECHO [06/28] A simple filled line graph\r
+ php -q %~dp0Example6.php\r
+ECHO [07/28] A filled cubic curve graph\r
+ php -q %~dp0Example7.php\r
+ECHO [08/28] A radar graph\r
+ php -q %~dp0Example8.php\r
+ECHO [09/28] Showing how to use labels\r
+ php -q %~dp0Example9.php\r
+ECHO [10/28] A 3D exploded pie graph\r
+ php -q %~dp0Example10.php\r
+ECHO [11/28] A true bar graph\r
+ php -q %~dp0Example12.php\r
+ECHO [12/28] A 2D exploded pie graph\r
+ php -q %~dp0Example13.php\r
+ECHO [13/28] A smooth flat pie graph\r
+ php -q %~dp0Example14.php\r
+ECHO [14/28] Playing with line style and pictures inclusion\r
+ php -q %~dp0Example15.php\r
+ECHO [15/28] Importing CSV data\r
+ php -q %~dp0Example16.php\r
+ECHO [16/28] Playing with axis\r
+ php -q %~dp0Example17.php\r
+ECHO [17/28] Missing values\r
+ php -q %~dp0Example18.php\r
+ECHO [18/28] Error reporting\r
+ php -q %~dp0Example19.php\r
+ECHO [19/28] Stacked bar graph\r
+ php -q %~dp0Example20.php\r
+ECHO [20/28] Playing with background\r
+ php -q %~dp0Example21.php\r
+ECHO [21/28] Customizing plot charts\r
+ php -q %~dp0Example22.php\r
+ECHO [22/28] Playing with background - Bis\r
+ php -q %~dp0Example23.php\r
+ECHO [23/28] X Versus Y chart\r
+ php -q %~dp0Example24.php\r
+ECHO [24/28] Using shadows\r
+ php -q %~dp0Example25.php\r
+ECHO [25/28] Two Y axis / shadow demonstration\r
+ php -q %~dp0Example26.php\r
+ECHO [26/28] Naked and easy!\r
+ php -q %~dp0Naked.php\r
+ECHO [27/28] Let's go fast, draw small!\r
+ php -q %~dp0SmallGraph.php\r
+ECHO [28/28] A Small stacked chart\r
+ php -q %~dp0SmallStacked.php\r
+ECHO.\r
+ECHO Rendering complete!\r
+PAUSE\r
diff --git a/gosa-core/include/pChart/bulkdata.csv b/gosa-core/include/pChart/bulkdata.csv
--- /dev/null
@@ -0,0 +1,20 @@
+1,0,1,0.5\r
+2,1.204119983,4,2\r
+3,4.294091292,9,4.5\r
+4,9.632959861,16,8\r
+5,17.47425011,25,12.5\r
+6,28.01344501,36,18\r
+7,41.40980396,49,24.5\r
+8,57.79775917,64,32\r
+9,77.29364326,81,40.5\r
+10,100,100,50\r
+11,126.0085149,121,60.5\r
+12,155.4020994,144,72\r
+13,188.2564265,169,84.5\r
+14,224.641095,196,98\r
+15,264.6205333,225,112.5\r
+16,308.2547156,256,128\r
+17,355.5997383,289,144.5\r
+18,406.7082917,324,162\r
+19,461.6300499,361,180.5\r
+20,520.4119983,400,200\r
diff --git a/gosa-core/include/pChart/datawithtitle.csv b/gosa-core/include/pChart/datawithtitle.csv
--- /dev/null
@@ -0,0 +1,21 @@
+Zob,January,February,March\r
+1,0,1,0.5\r
+2,1.204119983,4,2\r
+3,4.294091292,9,4.5\r
+4,9.632959861,16,8\r
+5,17.47425011,25,12.5\r
+6,28.01344501,36,18\r
+7,41.40980396,49,24.5\r
+8,57.79775917,64,32\r
+9,77.29364326,81,40.5\r
+10,100,100,50\r
+11,126.0085149,121,60.5\r
+12,155.4020994,144,72\r
+13,188.2564265,169,84.5\r
+14,224.641095,196,98\r
+15,264.6205333,225,112.5\r
+16,308.2547156,256,128\r
+17,355.5997383,289,144.5\r
+18,406.7082917,324,162\r
+19,461.6300499,361,180.5\r
+20,520.4119983,400,200\r
diff --git a/gosa-core/include/pChart/logo.png b/gosa-core/include/pChart/logo.png
new file mode 100644 (file)
index 0000000..8df1e4b
Binary files /dev/null and b/gosa-core/include/pChart/logo.png differ
index 0000000..8df1e4b
Binary files /dev/null and b/gosa-core/include/pChart/logo.png differ
diff --git a/gosa-core/include/pChart/pCache.class b/gosa-core/include/pChart/pCache.class
--- /dev/null
@@ -0,0 +1,119 @@
+<?php\r
+ /*\r
+ pCache - Faster renderding using data cache\r
+ Copyright (C) 2008 Jean-Damien POGOLOTTI\r
+ Version 1.1.2 last updated on 06/17/08\r
+\r
+ http://pchart.sourceforge.net\r
+\r
+ This program is free software: you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation, either version 1,2,3 of the License, or\r
+ (at your option) any later version.\r
+\r
+ This program is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+ Class initialisation :\r
+ pCache($CacheFolder="Cache/")\r
+ Cache management :\r
+ IsInCache($Data)\r
+ GetFromCache($ID,$Data)\r
+ WriteToCache($ID,$Data,$Picture)\r
+ DeleteFromCache($ID,$Data)\r
+ ClearCache()\r
+ Inner functions :\r
+ GetHash($ID,$Data)\r
+ */\r
+\r
+ /* pCache class definition */\r
+ class pCache\r
+ {\r
+ var $HashKey = "";\r
+ var $CacheFolder = "Cache/";\r
+\r
+ /* Create the pCache object */\r
+ function pCache($CacheFolder="Cache/")\r
+ {\r
+ $this->CacheFolder = $CacheFolder;\r
+ }\r
+\r
+ /* This function is clearing the cache folder */\r
+ function ClearCache()\r
+ {\r
+ if ($handle = opendir($this->CacheFolder))\r
+ {\r
+ while (false !== ($file = readdir($handle)))\r
+ {\r
+ if ( $file != "." && $file != ".." )\r
+ unlink($this->CacheFolder.$file);\r
+ }\r
+ closedir($handle);\r
+ }\r
+ }\r
+\r
+ /* This function is checking if we have an offline version of this chart */\r
+ function IsInCache($ID,$Data,$Hash="")\r
+ {\r
+ if ( $Hash == "" )\r
+ $Hash = $this->GetHash($ID,$Data);\r
+\r
+ if ( file_exists($this->CacheFolder.$Hash) )\r
+ return(TRUE);\r
+ else\r
+ return(FALSE);\r
+ }\r
+\r
+ /* This function is making a copy of drawn chart in the cache folder */\r
+ function WriteToCache($ID,$Data,$Picture)\r
+ {\r
+ $Hash = $this->GetHash($ID,$Data);\r
+ $FileName = $this->CacheFolder.$Hash;\r
+\r
+ imagepng($Picture->Picture,$FileName);\r
+ }\r
+\r
+ /* This function is removing any cached copy of this chart */\r
+ function DeleteFromCache($ID,$Data)\r
+ {\r
+ $Hash = $this->GetHash($ID,$Data);\r
+ $FileName = $this->CacheFolder.$Hash;\r
+\r
+ if ( file_exists($FileName ) )\r
+ unlink($FileName);\r
+ }\r
+\r
+ /* This function is retrieving the cached picture if applicable */\r
+ function GetFromCache($ID,$Data)\r
+ {\r
+ $Hash = $this->GetHash($ID,$Data);\r
+ if ( $this->IsInCache("","",$Hash ) )\r
+ {\r
+ $FileName = $this->CacheFolder.$Hash;\r
+\r
+ header('Content-type: image/png');\r
+ @readfile($FileName);\r
+ exit();\r
+ }\r
+ }\r
+\r
+ /* This function is building the graph unique hash key */\r
+ function GetHash($ID,$Data)\r
+ {\r
+ $mKey = "$ID";\r
+ foreach($Data as $key => $Values)\r
+ {\r
+ $tKey = "";\r
+ foreach($Values as $Serie => $Value)\r
+ $tKey = $tKey.$Serie.$Value;\r
+ $mKey = $mKey.md5($tKey);\r
+ }\r
+ return(md5($mKey));\r
+ }\r
+ }\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/pChart.1.27d.rar b/gosa-core/include/pChart/pChart.1.27d.rar
new file mode 100644 (file)
index 0000000..3fa26d4
Binary files /dev/null and b/gosa-core/include/pChart/pChart.1.27d.rar differ
index 0000000..3fa26d4
Binary files /dev/null and b/gosa-core/include/pChart/pChart.1.27d.rar differ
diff --git a/gosa-core/include/pChart/pChart.class b/gosa-core/include/pChart/pChart.class
--- /dev/null
@@ -0,0 +1,3489 @@
+<?php\r
+ /*\r
+ pChart - a PHP class to build charts!\r
+ Copyright (C) 2008 Jean-Damien POGOLOTTI\r
+ Version 1.27d last updated on 09/30/08\r
+\r
+ http://pchart.sourceforge.net\r
+\r
+ This program is free software: you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation, either version 1,2,3 of the License, or\r
+ (at your option) any later version.\r
+\r
+ This program is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+ Class initialisation :\r
+ pChart($XSize,$YSize)\r
+ Draw methods :\r
+ drawBackground($R,$G,$B)\r
+ drawRectangle($X1,$Y1,$X2,$Y2,$R,$G,$B)\r
+ drawFilledRectangle($X1,$Y1,$X2,$Y2,$R,$G,$B,$DrawBorder=TRUE,$Alpha=100)\r
+ drawRoundedRectangle($X1,$Y1,$X2,$Y2,$Radius,$R,$G,$B)\r
+ drawFilledRoundedRectangle($X1,$Y1,$X2,$Y2,$Radius,$R,$G,$B)\r
+ drawCircle($Xc,$Yc,$Height,$R,$G,$B,$Width=0)\r
+ drawFilledCircle($Xc,$Yc,$Height,$R,$G,$B,$Width=0)\r
+ drawEllipse($Xc,$Yc,$Height,$Width,$R,$G,$B)\r
+ drawFilledEllipse($Xc,$Yc,$Height,$Width,$R,$G,$B)\r
+ drawLine($X1,$Y1,$X2,$Y2,$R,$G,$B,$GraphFunction=FALSE)\r
+ drawDottedLine($X1,$Y1,$X2,$Y2,$DotSize,$R,$G,$B)\r
+ drawAlphaPixel($X,$Y,$Alpha,$R,$G,$B)\r
+ drawFromPNG($FileName,$X,$Y,$Alpha=100)\r
+ drawFromGIF($FileName,$X,$Y,$Alpha=100)\r
+ drawFromJPG($FileName,$X,$Y,$Alpha=100)\r
+ Graph setup methods :\r
+ addBorder($Width=3,$R=0,$G=0,$B=0)\r
+ clearScale()\r
+ clearShadow()\r
+ createColorGradientPalette($R1,$G1,$B1,$R2,$G2,$B2,$Shades)\r
+ drawGraphArea($R,$G,$B,$Stripe=FALSE)\r
+ drawScale($Data,$DataDescription,$ScaleMode,$R,$G,$B,$DrawTicks=TRUE,$Angle=0,$Decimals=1,$WithMargin=FALSE,$SkipLabels=1,$RightScale=FALSE)\r
+ drawRightScale($Data,$DataDescription,$ScaleMode,$R,$G,$B,$DrawTicks=TRUE,$Angle=0,$Decimals=1,$WithMargin=FALSE,$SkipLabels=1)\r
+ drawXYScale($Data,$DataDescription,$YSerieName,$XSerieName,$R,$G,$B,$WithMargin=0,$Angle=0,$Decimals=1)\r
+ drawGrid($LineWidth,$Mosaic=TRUE,$R=220,$G=220,$B=220,$Alpha=100)\r
+ drawLegend($XPos,$YPos,$DataDescription,$R,$G,$B,$Rs=-1,$Gs=-1,$Bs=-1,$Rt=0,$Gt=0,$Bt=0,$Border=FALSE)\r
+ drawPieLegend($XPos,$YPos,$Data,$DataDescription,$R,$G,$B)\r
+ drawTitle($XPos,$YPos,$Value,$R,$G,$B,$XPos2=-1,$YPos2=-1,$Shadow=FALSE)\r
+ drawTreshold($Value,$R,$G,$B,$ShowLabel=FALSE,$ShowOnRight=FALSE,$TickWidth=4,$FreeText=NULL)\r
+ drawArea($Data,$Serie1,$Serie2,$R,$G,$B,$Alpha = 50)\r
+ drawRadarAxis($Data,$DataDescription,$Mosaic=TRUE,$BorderOffset=10,$A_R=60,$A_G=60,$A_B=60,$S_R=200,$S_G=200,$S_B=200,$MaxValue=-1)\r
+ drawGraphAreaGradient($R,$G,$B,$Decay,$Target=TARGET_GRAPHAREA)\r
+ drawTextBox($X1,$Y1,$X2,$Y2,$Text,$Angle=0,$R=255,$G=255,$B=255,$Align=ALIGN_LEFT,$Shadow=TRUE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=100)\r
+ getLegendBoxSize($DataDescription)\r
+ loadColorPalette($FileName,$Delimiter=",")\r
+ reportWarnings($Interface="CLI")\r
+ setGraphArea($X1,$Y1,$X2,$Y2)\r
+ setLabel($Data,$DataDescription,$SerieName,$ValueName,$Caption,$R=210,$G=210,$B=210)\r
+ setColorPalette($ID,$R,$G,$B)\r
+ setCurrency($Currency)\r
+ setDateFormat($Format)\r
+ setFontProperties($FontName,$FontSize)\r
+ setLineStyle($Width=1,$DotSize=0)\r
+ setFixedScale($VMin,$VMax,$Divisions=5,$VXMin=0,$VXMin=0,$XDivisions=5)\r
+ setShadowProperties($XDistance=1,$YDistance=1,$R=60,$G=60,$B=60,$Alpha)\r
+ writeValues($Data,$DataDescription,$Series)\r
+ Graphs methods :\r
+ drawPlotGraph($Data,$DataDescription,$BigRadius=5,$SmallRadius=2,$R2=-1,$G2=-1,$B2=-1,$Shadow=FALSE)\r
+ drawXYPlotGraph($Data,$DataDescription,$YSerieName,$XSerieName,$PaletteID=0,$BigRadius=5,$SmallRadius=2,$R2=-1,$G2=-1,$B2=-1)\r
+ drawLineGraph($Data,$DataDescription,$SerieName="")\r
+ drawXYGraph($Data,$DataDescription,$YSerieName,$XSerieName,$PaletteID=0)\r
+ drawFilledLineGraph($Data,$DataDescription,$Alpha=100,$AroundZero=FALSE)\r
+ drawCubicCurve($Data,$DataDescription,$Accuracy=.1,$SerieName="")\r
+ drawFilledCubicCurve($Data,$DataDescription,$Accuracy=.1,$Alpha=100,$AroundZero=FALSE)\r
+ drawOverlayBarGraph($Data,$DataDescription,$Alpha=50)\r
+ drawBarGraph($Data,$DataDescription,$Shadow=FALSE)\r
+ drawStackedBarGraph($Data,$DataDescription,$Alpha=50,$Contiguous=FALSE)\r
+ drawLimitsGraph($Data,$DataDescription,$R=0,$G=0,$B=0)\r
+ drawRadar($Data,$DataDescription,$BorderOffset=10,$MaxValue=-1)\r
+ drawFilledRadar($Data,$DataDescription,$Alpha=50,$BorderOffset=10,$MaxValue=-1)\r
+ drawBasicPieGraph($Data,$DataDescription,$XPos,$YPos,$Radius=100,$DrawLabels=PIE_NOLABEL,$R=255,$G=255,$B=255,$Decimals=0)\r
+ drawFlatPieGraph($Data,$DataDescription,$XPos,$YPos,$Radius=100,$DrawLabels=PIE_NOLABEL,$SpliceDistance=0,$Decimals = 0)\r
+ drawFlatPieGraphWithShadow($Data,$DataDescription,$XPos,$YPos,$Radius=100,$DrawLabels=PIE_NOLABEL,$SpliceDistance=0,$Decimals = 0)\r
+ drawPieGraph($Data,$DataDescription,$XPos,$YPos,$Radius=100,$DrawLabels=PIE_NOLABEL,$EnhanceColors=TRUE,$Skew=60,$SpliceHeight=20,$SpliceDistance=0,$Decimals=0)\r
+ Other methods :\r
+ setImageMap($Mode=TRUE,$GraphID="MyGraph")\r
+ getImageMap($MapName,$Flush=TRUE)\r
+ Render($FileName)\r
+ Stroke()\r
+ */\r
+ \r
+ /* Declare some script wide constants */\r
+ define("SCALE_NORMAL",1);\r
+ define("SCALE_ADDALL",2);\r
+ define("SCALE_START0",3);\r
+ define("SCALE_ADDALLSTART0",4);\r
+ define("PIE_PERCENTAGE", 1);\r
+ define("PIE_LABELS",2);\r
+ define("PIE_NOLABEL",3);\r
+ define("PIE_PERCENTAGE_LABEL", 4);\r
+ define("TARGET_GRAPHAREA",1);\r
+ define("TARGET_BACKGROUND",2);\r
+ define("ALIGN_TOP_LEFT",1);\r
+ define("ALIGN_TOP_CENTER",2);\r
+ define("ALIGN_TOP_RIGHT",3);\r
+ define("ALIGN_LEFT",4);\r
+ define("ALIGN_CENTER",5);\r
+ define("ALIGN_RIGHT",6);\r
+ define("ALIGN_BOTTOM_LEFT",7);\r
+ define("ALIGN_BOTTOM_CENTER",8);\r
+ define("ALIGN_BOTTOM_RIGHT",9);\r
+\r
+ /* pChart class definition */\r
+ class pChart\r
+ {\r
+ /* Palettes definition */\r
+ var $Palette = array("0"=>array("R"=>188,"G"=>224,"B"=>46),\r
+ "1"=>array("R"=>224,"G"=>100,"B"=>46),\r
+ "2"=>array("R"=>224,"G"=>214,"B"=>46),\r
+ "3"=>array("R"=>46,"G"=>151,"B"=>224),\r
+ "4"=>array("R"=>176,"G"=>46,"B"=>224),\r
+ "5"=>array("R"=>224,"G"=>46,"B"=>117),\r
+ "6"=>array("R"=>92,"G"=>224,"B"=>46),\r
+ "7"=>array("R"=>224,"G"=>176,"B"=>46));\r
+\r
+ /* Some static vars used in the class */\r
+ var $XSize = NULL;\r
+ var $YSize = NULL;\r
+ var $Picture = NULL;\r
+ var $ImageMap = NULL;\r
+\r
+ /* Error management */\r
+ var $ErrorReporting = FALSE;\r
+ var $ErrorInterface = "CLI";\r
+ var $Errors = NULL;\r
+ var $ErrorFontName = "Fonts/pf_arma_five.ttf";\r
+ var $ErrorFontSize = 6;\r
+\r
+ /* vars related to the graphing area */\r
+ var $GArea_X1 = NULL;\r
+ var $GArea_Y1 = NULL;\r
+ var $GArea_X2 = NULL;\r
+ var $GArea_Y2 = NULL;\r
+ var $GAreaXOffset = NULL;\r
+ var $VMax = NULL;\r
+ var $VMin = NULL;\r
+ var $VXMax = NULL;\r
+ var $VXMin = NULL;\r
+ var $Divisions = NULL;\r
+ var $XDivisions = NULL;\r
+ var $DivisionHeight = NULL;\r
+ var $XDivisionHeight = NULL;\r
+ var $DivisionCount = NULL;\r
+ var $XDivisionCount = NULL;\r
+ var $DivisionRatio = NULL;\r
+ var $XDivisionRatio = NULL;\r
+ var $DivisionWidth = NULL;\r
+ var $DataCount = NULL;\r
+ var $Currency = "\$";\r
+\r
+ /* Text format related vars */\r
+ var $FontName = NULL;\r
+ var $FontSize = NULL;\r
+ var $DateFormat = "d/m/Y";\r
+\r
+ /* Lines format related vars */\r
+ var $LineWidth = 1;\r
+ var $LineDotSize = 0;\r
+\r
+ /* Layer related vars */\r
+ var $Layers = NULL;\r
+\r
+ /* Set antialias quality : 0 is maximum, 100 minimum*/\r
+ var $AntialiasQuality = 0;\r
+\r
+ /* Shadow settings */\r
+ var $ShadowActive = FALSE;\r
+ var $ShadowXDistance = 1;\r
+ var $ShadowYDistance = 1;\r
+ var $ShadowRColor = 60;\r
+ var $ShadowGColor = 60;\r
+ var $ShadowBColor = 60;\r
+ var $ShadowAlpha = 50;\r
+ var $ShadowBlur = 0;\r
+\r
+ /* Image Map settings */\r
+ var $BuildMap = FALSE;\r
+ var $MapFunction = NULL;\r
+ var $tmpFolder = "tmp/";\r
+ var $MapID = NULL;\r
+\r
+ /* This function create the background picture */\r
+ function pChart($XSize,$YSize)\r
+ {\r
+ $this->XSize = $XSize;\r
+ $this->YSize = $YSize;\r
+ $this->Picture = imagecreatetruecolor($XSize,$YSize);\r
+\r
+ $C_White =$this->AllocateColor($this->Picture,255,255,255);\r
+ imagefilledrectangle($this->Picture,0,0,$XSize,$YSize,$C_White);\r
+ imagecolortransparent($this->Picture,$C_White);\r
+\r
+ $this->setFontProperties("tahoma.ttf",8);\r
+ }\r
+\r
+ /* Set if warnings should be reported */\r
+ function reportWarnings($Interface="CLI")\r
+ {\r
+ $this->ErrorReporting = TRUE;\r
+ $this->ErrorInterface = $Interface;\r
+ }\r
+\r
+ /* Set the font properties */\r
+ function setFontProperties($FontName,$FontSize)\r
+ {\r
+ $this->FontName = $FontName;\r
+ $this->FontSize = $FontSize;\r
+ }\r
+\r
+ /* Set the shadow properties */\r
+ function setShadowProperties($XDistance=1,$YDistance=1,$R=60,$G=60,$B=60,$Alpha=50,$Blur=0)\r
+ {\r
+ $this->ShadowActive = TRUE;\r
+ $this->ShadowXDistance = $XDistance;\r
+ $this->ShadowYDistance = $YDistance;\r
+ $this->ShadowRColor = $R;\r
+ $this->ShadowGColor = $G;\r
+ $this->ShadowBColor = $B;\r
+ $this->ShadowAlpha = $Alpha;\r
+ $this->ShadowBlur = $Blur;\r
+ }\r
+\r
+ /* Remove shadow option */\r
+ function clearShadow()\r
+ {\r
+ $this->ShadowActive = FALSE;\r
+ }\r
+ \r
+ /* Set Palette color */\r
+ function setColorPalette($ID,$R,$G,$B)\r
+ {\r
+ if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }\r
+ if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }\r
+ if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }\r
+\r
+ $this->Palette[$ID]["R"] = $R;\r
+ $this->Palette[$ID]["G"] = $G;\r
+ $this->Palette[$ID]["B"] = $B;\r
+ }\r
+\r
+ /* Create a color palette shading from one color to another */\r
+ function createColorGradientPalette($R1,$G1,$B1,$R2,$G2,$B2,$Shades)\r
+ {\r
+ $RFactor = ($R2-$R1)/$Shades;\r
+ $GFactor = ($G2-$G1)/$Shades;\r
+ $BFactor = ($B2-$B1)/$Shades;\r
+\r
+ for($i=0;$i<=$Shades-1;$i++)\r
+ {\r
+ $this->Palette[$i]["R"] = $R1+$RFactor*$i;\r
+ $this->Palette[$i]["G"] = $G1+$GFactor*$i;\r
+ $this->Palette[$i]["B"] = $B1+$BFactor*$i;\r
+ }\r
+ }\r
+\r
+ /* Load Color Palette from file */\r
+ function loadColorPalette($FileName,$Delimiter=",")\r
+ {\r
+ $handle = @fopen($FileName,"r");\r
+ $ColorID = 0;\r
+ if ($handle)\r
+ {\r
+ while (!feof($handle))\r
+ {\r
+ $buffer = fgets($handle, 4096);\r
+ $buffer = str_replace(chr(10),"",$buffer);\r
+ $buffer = str_replace(chr(13),"",$buffer);\r
+ $Values = split($Delimiter,$buffer);\r
+ if ( count($Values) == 3 )\r
+ {\r
+ $this->Palette[$ColorID]["R"] = $Values[0];\r
+ $this->Palette[$ColorID]["G"] = $Values[1];\r
+ $this->Palette[$ColorID]["B"] = $Values[2];\r
+ $ColorID++;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ /* Set line style */\r
+ function setLineStyle($Width=1,$DotSize=0)\r
+ {\r
+ $this->LineWidth = $Width;\r
+ $this->LineDotSize = $DotSize;\r
+ }\r
+\r
+ /* Set currency symbol */\r
+ function setCurrency($Currency)\r
+ {\r
+ $this->Currency = $Currency;\r
+ }\r
+\r
+ /* Set the graph area location */\r
+ function setGraphArea($X1,$Y1,$X2,$Y2)\r
+ {\r
+ $this->GArea_X1 = $X1;\r
+ $this->GArea_Y1 = $Y1;\r
+ $this->GArea_X2 = $X2;\r
+ $this->GArea_Y2 = $Y2;\r
+ }\r
+\r
+ /* Prepare the graph area */\r
+ function drawGraphArea($R,$G,$B,$Stripe=FALSE)\r
+ {\r
+ $this->drawFilledRectangle($this->GArea_X1,$this->GArea_Y1,$this->GArea_X2,$this->GArea_Y2,$R,$G,$B,FALSE);\r
+ $this->drawRectangle($this->GArea_X1,$this->GArea_Y1,$this->GArea_X2,$this->GArea_Y2,$R-40,$G-40,$B-40);\r
+\r
+ if ( $Stripe )\r
+ {\r
+ $R2 = $R-15; if ( $R2 < 0 ) { $R2 = 0; }\r
+ $G2 = $R-15; if ( $G2 < 0 ) { $G2 = 0; }\r
+ $B2 = $R-15; if ( $B2 < 0 ) { $B2 = 0; }\r
+\r
+ $LineColor =$this->AllocateColor($this->Picture,$R2,$G2,$B2);\r
+ $SkewWidth = $this->GArea_Y2-$this->GArea_Y1-1;\r
+\r
+ for($i=$this->GArea_X1-$SkewWidth;$i<=$this->GArea_X2;$i=$i+4)\r
+ {\r
+ $X1 = $i; $Y1 = $this->GArea_Y2;\r
+ $X2 = $i+$SkewWidth; $Y2 = $this->GArea_Y1;\r
+\r
+\r
+ if ( $X1 < $this->GArea_X1 )\r
+ { $X1 = $this->GArea_X1; $Y1 = $this->GArea_Y1 + $X2 - $this->GArea_X1 + 1; }\r
+\r
+ if ( $X2 >= $this->GArea_X2 )\r
+ { $Y2 = $this->GArea_Y1 + $X2 - $this->GArea_X2 +1; $X2 = $this->GArea_X2 - 1; }\r
+// * Fixed in 1.27 * { $X2 = $this->GArea_X2 - 1; $Y2 = $this->GArea_Y2 - ($this->GArea_X2 - $X1); }\r
+\r
+ imageline($this->Picture,$X1,$Y1,$X2,$Y2+1,$LineColor);\r
+ }\r
+ }\r
+ }\r
+\r
+ /* Allow you to clear the scale : used if drawing multiple charts */\r
+ function clearScale()\r
+ {\r
+ $this->VMin = NULL;\r
+ $this->VMax = NULL;\r
+ $this->VXMin = NULL;\r
+ $this->VXMax = NULL;\r
+ $this->Divisions = NULL;\r
+ $this->XDivisions = NULL; }\r
+\r
+ /* Allow you to fix the scale, use this to bypass the automatic scaling */\r
+ function setFixedScale($VMin,$VMax,$Divisions=5,$VXMin=0,$VXMax=0,$XDivisions=5)\r
+ {\r
+ $this->VMin = $VMin;\r
+ $this->VMax = $VMax;\r
+ $this->Divisions = $Divisions;\r
+\r
+ if ( !$VXMin == 0 )\r
+ {\r
+ $this->VXMin = $VXMin;\r
+ $this->VXMax = $VXMax;\r
+ $this->XDivisions = $XDivisions;\r
+ }\r
+ }\r
+\r
+ /* Wrapper to the drawScale() function allowing a second scale to be drawn */\r
+ function drawRightScale($Data,$DataDescription,$ScaleMode,$R,$G,$B,$DrawTicks=TRUE,$Angle=0,$Decimals=1,$WithMargin=FALSE,$SkipLabels=1)\r
+ {\r
+ $this->drawScale($Data,$DataDescription,$ScaleMode,$R,$G,$B,$DrawTicks,$Angle,$Decimals,$WithMargin,$SkipLabels,TRUE);\r
+ }\r
+\r
+ /* Compute and draw the scale */\r
+ function drawScale($Data,$DataDescription,$ScaleMode,$R,$G,$B,$DrawTicks=TRUE,$Angle=0,$Decimals=1,$WithMargin=FALSE,$SkipLabels=1,$RightScale=FALSE)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateData("drawScale",$Data);\r
+\r
+ $C_TextColor =$this->AllocateColor($this->Picture,$R,$G,$B);\r
+\r
+ $this->drawLine($this->GArea_X1,$this->GArea_Y1,$this->GArea_X1,$this->GArea_Y2,$R,$G,$B);\r
+ $this->drawLine($this->GArea_X1,$this->GArea_Y2,$this->GArea_X2,$this->GArea_Y2,$R,$G,$B);\r
+\r
+ if ( $this->VMin == NULL && $this->VMax == NULL)\r
+ {\r
+ if (isset($DataDescription["Values"][0]))\r
+ {\r
+ $this->VMin = $Data[0][$DataDescription["Values"][0]];\r
+ $this->VMax = $Data[0][$DataDescription["Values"][0]];\r
+ }\r
+ else { $this->VMin = 2147483647; $this->VMax = -2147483647; }\r
+\r
+ /* Compute Min and Max values */\r
+ if ( $ScaleMode == SCALE_NORMAL || $ScaleMode == SCALE_START0 )\r
+ {\r
+ if ( $ScaleMode == SCALE_START0 ) { $this->VMin = 0; }\r
+\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ if (isset($Data[$Key][$ColName]))\r
+ {\r
+ $Value = $Data[$Key][$ColName];\r
+\r
+ if ( is_numeric($Value) )\r
+ {\r
+ if ( $this->VMax < $Value) { $this->VMax = $Value; }\r
+ if ( $this->VMin > $Value) { $this->VMin = $Value; }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ elseif ( $ScaleMode == SCALE_ADDALL || $ScaleMode == SCALE_ADDALLSTART0 ) /* Experimental */\r
+ {\r
+ if ( $ScaleMode == SCALE_ADDALLSTART0 ) { $this->VMin = 0; }\r
+\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ $Sum = 0;\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ if (isset($Data[$Key][$ColName]))\r
+ {\r
+ $Value = $Data[$Key][$ColName];\r
+ if ( is_numeric($Value) )\r
+ $Sum += $Value;\r
+ }\r
+ }\r
+ if ( $this->VMax < $Sum) { $this->VMax = $Sum; }\r
+ if ( $this->VMin > $Sum) { $this->VMin = $Sum; }\r
+ }\r
+ }\r
+\r
+ if ( $this->VMax > preg_replace('/\.[0-9]+/','',$this->VMax) )\r
+ $this->VMax = preg_replace('/\.[0-9]+/','',$this->VMax)+1;\r
+\r
+ /* If all values are the same */\r
+ if ( $this->VMax == $this->VMin )\r
+ {\r
+ if ( $this->VMax >= 0 ) { $this->VMax++; }\r
+ else { $this->VMin--; }\r
+ }\r
+\r
+ $DataRange = $this->VMax - $this->VMin;\r
+ if ( $DataRange == 0 ) { $DataRange = .1; }\r
+\r
+ /* Compute automatic scaling */\r
+ $ScaleOk = FALSE; $Factor = 1;\r
+ $MinDivHeight = 25; $MaxDivs = ($this->GArea_Y2 - $this->GArea_Y1) / $MinDivHeight;\r
+\r
+ if ( $this->VMin == 0 && $this->VMax == 0 )\r
+ { $this->VMin = 0; $this->VMax = 2; $Scale = 1; $Divisions = 2;}\r
+ elseif ($MaxDivs > 1)\r
+ {\r
+ while(!$ScaleOk)\r
+ {\r
+ $Scale1 = ( $this->VMax - $this->VMin ) / $Factor;\r
+ $Scale2 = ( $this->VMax - $this->VMin ) / $Factor / 2;\r
+ $Scale4 = ( $this->VMax - $this->VMin ) / $Factor / 4;\r
+\r
+ if ( $Scale1 > 1 && $Scale1 <= $MaxDivs && !$ScaleOk) { $ScaleOk = TRUE; $Divisions = floor($Scale1); $Scale = 1;}\r
+ if ( $Scale2 > 1 && $Scale2 <= $MaxDivs && !$ScaleOk) { $ScaleOk = TRUE; $Divisions = floor($Scale2); $Scale = 2;}\r
+ if (!$ScaleOk)\r
+ {\r
+ if ( $Scale2 > 1 ) { $Factor = $Factor * 10; }\r
+ if ( $Scale2 < 1 ) { $Factor = $Factor / 10; }\r
+ }\r
+ }\r
+\r
+ if ( floor($this->VMax / $Scale / $Factor) != $this->VMax / $Scale / $Factor)\r
+ {\r
+ $GridID = floor ( $this->VMax / $Scale / $Factor) + 1;\r
+ $this->VMax = $GridID * $Scale * $Factor;\r
+ $Divisions++;\r
+ }\r
+\r
+ if ( floor($this->VMin / $Scale / $Factor) != $this->VMin / $Scale / $Factor)\r
+ {\r
+ $GridID = floor( $this->VMin / $Scale / $Factor);\r
+ $this->VMin = $GridID * $Scale * $Factor;\r
+ $Divisions++;\r
+ }\r
+ }\r
+ else /* Can occurs for small graphs */\r
+ $Scale = 1;\r
+\r
+ if ( !isset($Divisions) )\r
+ $Divisions = 2;\r
+\r
+ if ($Scale == 1 && $Divisions%2 == 1)\r
+ $Divisions--;\r
+ }\r
+ else\r
+ $Divisions = $this->Divisions;\r
+\r
+ $this->DivisionCount = $Divisions;\r
+\r
+ $DataRange = $this->VMax - $this->VMin;\r
+ if ( $DataRange == 0 ) { $DataRange = .1; }\r
+\r
+ $this->DivisionHeight = ( $this->GArea_Y2 - $this->GArea_Y1 ) / $Divisions;\r
+ $this->DivisionRatio = ( $this->GArea_Y2 - $this->GArea_Y1 ) / $DataRange;\r
+\r
+ $this->GAreaXOffset = 0;\r
+ if ( count($Data) > 1 )\r
+ {\r
+ if ( $WithMargin == FALSE )\r
+ $this->DivisionWidth = ( $this->GArea_X2 - $this->GArea_X1 ) / (count($Data)-1);\r
+ else\r
+ {\r
+ $this->DivisionWidth = ( $this->GArea_X2 - $this->GArea_X1 ) / (count($Data));\r
+ $this->GAreaXOffset = $this->DivisionWidth / 2;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ $this->DivisionWidth = $this->GArea_X2 - $this->GArea_X1;\r
+ $this->GAreaXOffset = $this->DivisionWidth / 2;\r
+ }\r
+\r
+ $this->DataCount = count($Data);\r
+\r
+ if ( $DrawTicks == FALSE )\r
+ return(0);\r
+\r
+ $YPos = $this->GArea_Y2; $XMin = NULL;\r
+ for($i=1;$i<=$Divisions+1;$i++)\r
+ {\r
+ if ( $RightScale )\r
+ $this->drawLine($this->GArea_X2,$YPos,$this->GArea_X2+5,$YPos,$R,$G,$B);\r
+ else\r
+ $this->drawLine($this->GArea_X1,$YPos,$this->GArea_X1-5,$YPos,$R,$G,$B);\r
+\r
+ $Value = $this->VMin + ($i-1) * (( $this->VMax - $this->VMin ) / $Divisions);\r
+ $Value = round($Value * pow(10,$Decimals)) / pow(10,$Decimals);\r
+ if ( $DataDescription["Format"]["Y"] == "number" )\r
+ $Value = $Value.$DataDescription["Unit"]["Y"];\r
+ if ( $DataDescription["Format"]["Y"] == "time" )\r
+ $Value = $this->ToTime($Value); \r
+ if ( $DataDescription["Format"]["Y"] == "date" )\r
+ $Value = $this->ToDate($Value); \r
+ if ( $DataDescription["Format"]["Y"] == "metric" )\r
+ $Value = $this->ToMetric($Value); \r
+ if ( $DataDescription["Format"]["Y"] == "currency" )\r
+ $Value = $this->ToCurrency($Value); \r
+\r
+ $Position = imageftbbox($this->FontSize,0,$this->FontName,$Value);\r
+ $TextWidth = $Position[2]-$Position[0];\r
+\r
+ if ( $RightScale )\r
+ {\r
+ imagettftext($this->Picture,$this->FontSize,0,$this->GArea_X2+10,$YPos+($this->FontSize/2),$C_TextColor,$this->FontName,$Value);\r
+ if ( $XMin < $this->GArea_X2+15+$TextWidth || $XMin == NULL ) { $XMin = $this->GArea_X2+15+$TextWidth; }\r
+ }\r
+ else\r
+ {\r
+ imagettftext($this->Picture,$this->FontSize,0,$this->GArea_X1-10-$TextWidth,$YPos+($this->FontSize/2),$C_TextColor,$this->FontName,$Value);\r
+ if ( $XMin > $this->GArea_X1-10-$TextWidth || $XMin == NULL ) { $XMin = $this->GArea_X1-10-$TextWidth; }\r
+ }\r
+\r
+ $YPos = $YPos - $this->DivisionHeight;\r
+ }\r
+\r
+ /* Write the Y Axis caption if set */ \r
+ if ( isset($DataDescription["Axis"]["Y"]) )\r
+ {\r
+ $Position = imageftbbox($this->FontSize,90,$this->FontName,$DataDescription["Axis"]["Y"]);\r
+ $TextHeight = abs($Position[1])+abs($Position[3]);\r
+ $TextTop = (($this->GArea_Y2 - $this->GArea_Y1) / 2) + $this->GArea_Y1 + ($TextHeight/2);\r
+\r
+ if ( $RightScale )\r
+ imagettftext($this->Picture,$this->FontSize,90,$XMin+$this->FontSize,$TextTop,$C_TextColor,$this->FontName,$DataDescription["Axis"]["Y"]);\r
+ else\r
+ imagettftext($this->Picture,$this->FontSize,90,$XMin-$this->FontSize,$TextTop,$C_TextColor,$this->FontName,$DataDescription["Axis"]["Y"]);\r
+ }\r
+\r
+ /* Horizontal Axis */\r
+ $XPos = $this->GArea_X1 + $this->GAreaXOffset;\r
+ $ID = 1; $YMax = NULL;\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if ( $ID % $SkipLabels == 0 )\r
+ {\r
+ $this->drawLine(floor($XPos),$this->GArea_Y2,floor($XPos),$this->GArea_Y2+5,$R,$G,$B);\r
+ $Value = $Data[$Key][$DataDescription["Position"]];\r
+ if ( $DataDescription["Format"]["X"] == "number" )\r
+ $Value = $Value.$DataDescription["Unit"]["X"];\r
+ if ( $DataDescription["Format"]["X"] == "time" )\r
+ $Value = $this->ToTime($Value); \r
+ if ( $DataDescription["Format"]["X"] == "date" )\r
+ $Value = $this->ToDate($Value); \r
+ if ( $DataDescription["Format"]["X"] == "metric" )\r
+ $Value = $this->ToMetric($Value); \r
+ if ( $DataDescription["Format"]["X"] == "currency" )\r
+ $Value = $this->ToCurrency($Value); \r
+\r
+ $Position = imageftbbox($this->FontSize,$Angle,$this->FontName,$Value);\r
+ $TextWidth = abs($Position[2])+abs($Position[0]);\r
+ $TextHeight = abs($Position[1])+abs($Position[3]);\r
+\r
+ if ( $Angle == 0 )\r
+ {\r
+ $YPos = $this->GArea_Y2+18;\r
+ imagettftext($this->Picture,$this->FontSize,$Angle,floor($XPos)-floor($TextWidth/2),$YPos,$C_TextColor,$this->FontName,$Value);\r
+ }\r
+ else\r
+ {\r
+ $YPos = $this->GArea_Y2+10+$TextHeight;\r
+ if ( $Angle <= 90 )\r
+ imagettftext($this->Picture,$this->FontSize,$Angle,floor($XPos)-$TextWidth+5,$YPos,$C_TextColor,$this->FontName,$Value);\r
+ else\r
+ imagettftext($this->Picture,$this->FontSize,$Angle,floor($XPos)+$TextWidth+5,$YPos,$C_TextColor,$this->FontName,$Value);\r
+ }\r
+ if ( $YMax < $YPos || $YMax == NULL ) { $YMax = $YPos; }\r
+ }\r
+\r
+ $XPos = $XPos + $this->DivisionWidth;\r
+ $ID++;\r
+ }\r
+\r
+ /* Write the X Axis caption if set */ \r
+ if ( isset($DataDescription["Axis"]["X"]) )\r
+ {\r
+ $Position = imageftbbox($this->FontSize,90,$this->FontName,$DataDescription["Axis"]["X"]);\r
+ $TextWidth = abs($Position[2])+abs($Position[0]);\r
+ $TextLeft = (($this->GArea_X2 - $this->GArea_X1) / 2) + $this->GArea_X1 + ($TextWidth/2);\r
+ imagettftext($this->Picture,$this->FontSize,0,$TextLeft,$YMax+$this->FontSize+5,$C_TextColor,$this->FontName,$DataDescription["Axis"]["X"]);\r
+ }\r
+ }\r
+\r
+ /* Compute and draw the scale for X/Y charts */\r
+ function drawXYScale($Data,$DataDescription,$YSerieName,$XSerieName,$R,$G,$B,$WithMargin=0,$Angle=0,$Decimals=1)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateData("drawScale",$Data);\r
+\r
+ $C_TextColor =$this->AllocateColor($this->Picture,$R,$G,$B);\r
+\r
+ $this->drawLine($this->GArea_X1,$this->GArea_Y1,$this->GArea_X1,$this->GArea_Y2,$R,$G,$B);\r
+ $this->drawLine($this->GArea_X1,$this->GArea_Y2,$this->GArea_X2,$this->GArea_Y2,$R,$G,$B);\r
+\r
+ /* Process Y scale */\r
+ if ( $this->VMin == NULL && $this->VMax == NULL)\r
+ {\r
+ $this->VMin = $Data[0][$YSerieName];\r
+ $this->VMax = $Data[0][$YSerieName];\r
+\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if (isset($Data[$Key][$YSerieName]))\r
+ {\r
+ $Value = $Data[$Key][$YSerieName];\r
+ if ( $this->VMax < $Value) { $this->VMax = $Value; }\r
+ if ( $this->VMin > $Value) { $this->VMin = $Value; }\r
+ }\r
+ }\r
+\r
+ if ( $this->VMax > preg_replace('/\.[0-9]+/','',$this->VMax) )\r
+ $this->VMax = preg_replace('/\.[0-9]+/','',$this->VMax)+1;\r
+\r
+ $DataRange = $this->VMax - $this->VMin;\r
+ if ( $DataRange == 0 ) { $DataRange = .1; }\r
+\r
+ /* Compute automatic scaling */\r
+ $ScaleOk = FALSE; $Factor = 1;\r
+ $MinDivHeight = 25; $MaxDivs = ($this->GArea_Y2 - $this->GArea_Y1) / $MinDivHeight;\r
+\r
+ if ( $this->VMin == 0 && $this->VMax == 0 )\r
+ { $this->VMin = 0; $this->VMax = 2; $Scale = 1; $Divisions = 2;}\r
+ elseif ($MaxDivs > 1)\r
+ {\r
+ while(!$ScaleOk)\r
+ {\r
+ $Scale1 = ( $this->VMax - $this->VMin ) / $Factor;\r
+ $Scale2 = ( $this->VMax - $this->VMin ) / $Factor / 2;\r
+ $Scale4 = ( $this->VMax - $this->VMin ) / $Factor / 4;\r
+\r
+ if ( $Scale1 > 1 && $Scale1 <= $MaxDivs && !$ScaleOk) { $ScaleOk = TRUE; $Divisions = floor($Scale1); $Scale = 1;}\r
+ if ( $Scale2 > 1 && $Scale2 <= $MaxDivs && !$ScaleOk) { $ScaleOk = TRUE; $Divisions = floor($Scale2); $Scale = 2;}\r
+ if (!$ScaleOk)\r
+ {\r
+ if ( $Scale2 > 1 ) { $Factor = $Factor * 10; }\r
+ if ( $Scale2 < 1 ) { $Factor = $Factor / 10; }\r
+ }\r
+ }\r
+\r
+ if ( floor($this->VMax / $Scale / $Factor) != $this->VMax / $Scale / $Factor)\r
+ {\r
+ $GridID = floor ( $this->VMax / $Scale / $Factor) + 1;\r
+ $this->VMax = $GridID * $Scale * $Factor;\r
+ $Divisions++;\r
+ }\r
+\r
+ if ( floor($this->VMin / $Scale / $Factor) != $this->VMin / $Scale / $Factor)\r
+ {\r
+ $GridID = floor( $this->VMin / $Scale / $Factor);\r
+ $this->VMin = $GridID * $Scale * $Factor;\r
+ $Divisions++;\r
+ }\r
+ }\r
+ else /* Can occurs for small graphs */\r
+ $Scale = 1;\r
+\r
+ if ( !isset($Divisions) )\r
+ $Divisions = 2;\r
+\r
+ if ( $this->isRealInt(($this->VMax-$this->VMin)/($Divisions-1)))\r
+ $Divisions--;\r
+ elseif ( $this->isRealInt(($this->VMax-$this->VMin)/($Divisions+1)))\r
+ $Divisions++;\r
+ }\r
+ else\r
+ $Divisions = $this->Divisions;\r
+\r
+ $this->DivisionCount = $Divisions;\r
+\r
+ $DataRange = $this->VMax - $this->VMin;\r
+ if ( $DataRange == 0 ) { $DataRange = .1; }\r
+\r
+ $this->DivisionHeight = ( $this->GArea_Y2 - $this->GArea_Y1 ) / $Divisions;\r
+ $this->DivisionRatio = ( $this->GArea_Y2 - $this->GArea_Y1 ) / $DataRange;\r
+\r
+ $YPos = $this->GArea_Y2; $XMin = NULL;\r
+ for($i=1;$i<=$Divisions+1;$i++)\r
+ {\r
+ $this->drawLine($this->GArea_X1,$YPos,$this->GArea_X1-5,$YPos,$R,$G,$B);\r
+ $Value = $this->VMin + ($i-1) * (( $this->VMax - $this->VMin ) / $Divisions);\r
+ $Value = round($Value * pow(10,$Decimals)) / pow(10,$Decimals);\r
+ if ( $DataDescription["Format"]["Y"] == "number" )\r
+ $Value = $Value.$DataDescription["Unit"]["Y"];\r
+ if ( $DataDescription["Format"]["Y"] == "time" )\r
+ $Value = $this->ToTime($Value); \r
+ if ( $DataDescription["Format"]["Y"] == "date" )\r
+ $Value = $this->ToDate($Value); \r
+ if ( $DataDescription["Format"]["Y"] == "metric" )\r
+ $Value = $this->ToMetric($Value); \r
+ if ( $DataDescription["Format"]["Y"] == "currency" )\r
+ $Value = $this->ToCurrency($Value); \r
+\r
+ $Position = imageftbbox($this->FontSize,0,$this->FontName,$Value);\r
+ $TextWidth = $Position[2]-$Position[0];\r
+ imagettftext($this->Picture,$this->FontSize,0,$this->GArea_X1-10-$TextWidth,$YPos+($this->FontSize/2),$C_TextColor,$this->FontName,$Value);\r
+\r
+ if ( $XMin > $this->GArea_X1-10-$TextWidth || $XMin == NULL ) { $XMin = $this->GArea_X1-10-$TextWidth; }\r
+\r
+ $YPos = $YPos - $this->DivisionHeight;\r
+ }\r
+\r
+ /* Process X scale */\r
+ if ( $this->VXMin == NULL && $this->VXMax == NULL)\r
+ {\r
+ $this->VXMin = $Data[0][$XSerieName];\r
+ $this->VXMax = $Data[0][$XSerieName];\r
+\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if (isset($Data[$Key][$XSerieName]))\r
+ {\r
+ $Value = $Data[$Key][$XSerieName];\r
+ if ( $this->VXMax < $Value) { $this->VXMax = $Value; }\r
+ if ( $this->VXMin > $Value) { $this->VXMin = $Value; }\r
+ }\r
+ }\r
+\r
+ if ( $this->VXMax > preg_replace('/\.[0-9]+/','',$this->VXMax) )\r
+ $this->VXMax = preg_replace('/\.[0-9]+/','',$this->VXMax)+1;\r
+\r
+ $DataRange = $this->VMax - $this->VMin;\r
+ if ( $DataRange == 0 ) { $DataRange = .1; }\r
+\r
+ /* Compute automatic scaling */\r
+ $ScaleOk = FALSE; $Factor = 1;\r
+ $MinDivWidth = 25; $MaxDivs = ($this->GArea_X2 - $this->GArea_X1) / $MinDivWidth;\r
+\r
+ if ( $this->VXMin == 0 && $this->VXMax == 0 )\r
+ { $this->VXMin = 0; $this->VXMax = 2; $Scale = 1; $XDivisions = 2;}\r
+ elseif ($MaxDivs > 1)\r
+ {\r
+ while(!$ScaleOk)\r
+ {\r
+ $Scale1 = ( $this->VXMax - $this->VXMin ) / $Factor;\r
+ $Scale2 = ( $this->VXMax - $this->VXMin ) / $Factor / 2;\r
+ $Scale4 = ( $this->VXMax - $this->VXMin ) / $Factor / 4;\r
+\r
+ if ( $Scale1 > 1 && $Scale1 <= $MaxDivs && !$ScaleOk) { $ScaleOk = TRUE; $XDivisions = floor($Scale1); $Scale = 1;}\r
+ if ( $Scale2 > 1 && $Scale2 <= $MaxDivs && !$ScaleOk) { $ScaleOk = TRUE; $XDivisions = floor($Scale2); $Scale = 2;}\r
+ if (!$ScaleOk)\r
+ {\r
+ if ( $Scale2 > 1 ) { $Factor = $Factor * 10; }\r
+ if ( $Scale2 < 1 ) { $Factor = $Factor / 10; }\r
+ }\r
+ }\r
+\r
+ if ( floor($this->VXMax / $Scale / $Factor) != $this->VXMax / $Scale / $Factor)\r
+ {\r
+ $GridID = floor ( $this->VXMax / $Scale / $Factor) + 1;\r
+ $this->VXMax = $GridID * $Scale * $Factor;\r
+ $XDivisions++;\r
+ }\r
+\r
+ if ( floor($this->VXMin / $Scale / $Factor) != $this->VXMin / $Scale / $Factor)\r
+ {\r
+ $GridID = floor( $this->VXMin / $Scale / $Factor);\r
+ $this->VXMin = $GridID * $Scale * $Factor;\r
+ $XDivisions++;\r
+ }\r
+ }\r
+ else /* Can occurs for small graphs */\r
+ $Scale = 1;\r
+\r
+ if ( !isset($XDivisions) )\r
+ $XDivisions = 2;\r
+\r
+ if ( $this->isRealInt(($this->VXMax-$this->VXMin)/($XDivisions-1)))\r
+ $XDivisions--;\r
+ elseif ( $this->isRealInt(($this->VXMax-$this->VXMin)/($XDivisions+1)))\r
+ $XDivisions++;\r
+ }\r
+ else\r
+ $XDivisions = $this->XDivisions;\r
+\r
+ $this->XDivisionCount = $Divisions;\r
+ $this->DataCount = $Divisions + 2;\r
+\r
+ $XDataRange = $this->VXMax - $this->VXMin;\r
+ if ( $XDataRange == 0 ) { $XDataRange = .1; }\r
+\r
+ $this->DivisionWidth = ( $this->GArea_X2 - $this->GArea_X1 ) / $XDivisions;\r
+ $this->XDivisionRatio = ( $this->GArea_X2 - $this->GArea_X1 ) / $XDataRange;\r
+\r
+ $XPos = $this->GArea_X1; $YMax = NULL;\r
+ for($i=1;$i<=$XDivisions+1;$i++)\r
+ {\r
+ $this->drawLine($XPos,$this->GArea_Y2,$XPos,$this->GArea_Y2+5,$R,$G,$B);\r
+\r
+ $Value = $this->VXMin + ($i-1) * (( $this->VXMax - $this->VXMin ) / $XDivisions);\r
+ $Value = round($Value * pow(10,$Decimals)) / pow(10,$Decimals);\r
+ if ( $DataDescription["Format"]["Y"] == "number" )\r
+ $Value = $Value.$DataDescription["Unit"]["Y"];\r
+ if ( $DataDescription["Format"]["Y"] == "time" )\r
+ $Value = $this->ToTime($Value); \r
+ if ( $DataDescription["Format"]["Y"] == "date" )\r
+ $Value = $this->ToDate($Value); \r
+ if ( $DataDescription["Format"]["Y"] == "metric" )\r
+ $Value = $this->ToMetric($Value); \r
+ if ( $DataDescription["Format"]["Y"] == "currency" )\r
+ $Value = $this->ToCurrency($Value); \r
+\r
+ $Position = imageftbbox($this->FontSize,$Angle,$this->FontName,$Value);\r
+ $TextWidth = abs($Position[2])+abs($Position[0]);\r
+ $TextHeight = abs($Position[1])+abs($Position[3]);\r
+\r
+ if ( $Angle == 0 )\r
+ {\r
+ $YPos = $this->GArea_Y2+18;\r
+ imagettftext($this->Picture,$this->FontSize,$Angle,floor($XPos)-floor($TextWidth/2),$YPos,$C_TextColor,$this->FontName,$Value);\r
+ }\r
+ else\r
+ {\r
+ $YPos = $this->GArea_Y2+10+$TextHeight;\r
+ if ( $Angle <= 90 )\r
+ imagettftext($this->Picture,$this->FontSize,$Angle,floor($XPos)-$TextWidth+5,$YPos,$C_TextColor,$this->FontName,$Value);\r
+ else\r
+ imagettftext($this->Picture,$this->FontSize,$Angle,floor($XPos)+$TextWidth+5,$YPos,$C_TextColor,$this->FontName,$Value);\r
+ }\r
+\r
+ if ( $YMax < $YPos || $YMax == NULL ) { $YMax = $YPos; }\r
+\r
+ $XPos = $XPos + $this->DivisionWidth;\r
+ }\r
+\r
+ /* Write the Y Axis caption if set */ \r
+ if ( isset($DataDescription["Axis"]["Y"]) )\r
+ {\r
+ $Position = imageftbbox($this->FontSize,90,$this->FontName,$DataDescription["Axis"]["Y"]);\r
+ $TextHeight = abs($Position[1])+abs($Position[3]);\r
+ $TextTop = (($this->GArea_Y2 - $this->GArea_Y1) / 2) + $this->GArea_Y1 + ($TextHeight/2);\r
+ imagettftext($this->Picture,$this->FontSize,90,$XMin-$this->FontSize,$TextTop,$C_TextColor,$this->FontName,$DataDescription["Axis"]["Y"]);\r
+ }\r
+\r
+ /* Write the X Axis caption if set */ \r
+ if ( isset($DataDescription["Axis"]["X"]) )\r
+ {\r
+ $Position = imageftbbox($this->FontSize,90,$this->FontName,$DataDescription["Axis"]["X"]);\r
+ $TextWidth = abs($Position[2])+abs($Position[0]);\r
+ $TextLeft = (($this->GArea_X2 - $this->GArea_X1) / 2) + $this->GArea_X1 + ($TextWidth/2);\r
+ imagettftext($this->Picture,$this->FontSize,0,$TextLeft,$YMax+$this->FontSize+5,$C_TextColor,$this->FontName,$DataDescription["Axis"]["X"]);\r
+ }\r
+ }\r
+\r
+ /* Compute and draw the scale */\r
+ function drawGrid($LineWidth,$Mosaic=TRUE,$R=220,$G=220,$B=220,$Alpha=100)\r
+ {\r
+ /* Draw mosaic */\r
+ if ( $Mosaic )\r
+ {\r
+ $LayerWidth = $this->GArea_X2-$this->GArea_X1;\r
+ $LayerHeight = $this->GArea_Y2-$this->GArea_Y1;\r
+\r
+ $this->Layers[0] = imagecreatetruecolor($LayerWidth,$LayerHeight);\r
+ $C_White =$this->AllocateColor($this->Layers[0],255,255,255);\r
+ imagefilledrectangle($this->Layers[0],0,0,$LayerWidth,$LayerHeight,$C_White);\r
+ imagecolortransparent($this->Layers[0],$C_White);\r
+\r
+ $C_Rectangle =$this->AllocateColor($this->Layers[0],250,250,250);\r
+\r
+ $YPos = $LayerHeight; //$this->GArea_Y2-1;\r
+ $LastY = $YPos;\r
+ for($i=0;$i<=$this->DivisionCount;$i++)\r
+ {\r
+ $LastY = $YPos;\r
+ $YPos = $YPos - $this->DivisionHeight;\r
+\r
+ if ( $YPos <= 0 ) { $YPos = 1; }\r
+\r
+ if ( $i % 2 == 0 )\r
+ {\r
+ imagefilledrectangle($this->Layers[0],1,$YPos,$LayerWidth-1,$LastY,$C_Rectangle);\r
+ }\r
+ }\r
+ imagecopymerge($this->Picture,$this->Layers[0],$this->GArea_X1,$this->GArea_Y1,0,0,$LayerWidth,$LayerHeight,$Alpha);\r
+ imagedestroy($this->Layers[0]);\r
+ }\r
+\r
+ /* Horizontal lines */\r
+ $YPos = $this->GArea_Y2 - $this->DivisionHeight;\r
+ for($i=1;$i<=$this->DivisionCount;$i++)\r
+ {\r
+ if ( $YPos > $this->GArea_Y1 && $YPos < $this->GArea_Y2 )\r
+ $this->drawDottedLine($this->GArea_X1,$YPos,$this->GArea_X2,$YPos,$LineWidth,$R,$G,$B);\r
+ \r
+ $YPos = $YPos - $this->DivisionHeight;\r
+ }\r
+\r
+ /* Vertical lines */\r
+ if ( $this->GAreaXOffset == 0 )\r
+ { $XPos = $this->GArea_X1 + $this->DivisionWidth + $this->GAreaXOffset; $ColCount = $this->DataCount-2; }\r
+ else\r
+ { $XPos = $this->GArea_X1 + $this->GAreaXOffset; $ColCount = floor( ($this->GArea_X2 - $this->GArea_X1) / $this->DivisionWidth ); }\r
+\r
+ for($i=1;$i<=$ColCount;$i++)\r
+ {\r
+ if ( $XPos > $this->GArea_X1 && $XPos < $this->GArea_X2 )\r
+ $this->drawDottedLine(floor($XPos),$this->GArea_Y1,floor($XPos),$this->GArea_Y2,$LineWidth,$R,$G,$B);\r
+ $XPos = $XPos + $this->DivisionWidth;\r
+ }\r
+ }\r
+\r
+ /* retrieve the legends size */\r
+ function getLegendBoxSize($DataDescription)\r
+ {\r
+ if ( !isset($DataDescription["Description"]) )\r
+ return(-1);\r
+\r
+ /* <-10->[8]<-4->Text<-10-> */\r
+ $MaxWidth = 0; $MaxHeight = 8;\r
+ foreach($DataDescription["Description"] as $Key => $Value)\r
+ {\r
+ $Position = imageftbbox($this->FontSize,0,$this->FontName,$Value);\r
+ $TextWidth = $Position[2]-$Position[0];\r
+ $TextHeight = $Position[1]-$Position[7];\r
+ if ( $TextWidth > $MaxWidth) { $MaxWidth = $TextWidth; }\r
+ $MaxHeight = $MaxHeight + $TextHeight + 4;\r
+ }\r
+ $MaxHeight = $MaxHeight - 3;\r
+ $MaxWidth = $MaxWidth + 32;\r
+\r
+ return(array($MaxWidth,$MaxHeight));\r
+ }\r
+\r
+ /* Draw the data legends */\r
+ function drawLegend($XPos,$YPos,$DataDescription,$R,$G,$B,$Rs=-1,$Gs=-1,$Bs=-1,$Rt=0,$Gt=0,$Bt=0,$Border=TRUE)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawLegend",$DataDescription);\r
+\r
+ if ( !isset($DataDescription["Description"]) )\r
+ return(-1);\r
+\r
+ $C_TextColor =$this->AllocateColor($this->Picture,$Rt,$Gt,$Bt);\r
+\r
+ /* <-10->[8]<-4->Text<-10-> */\r
+ $MaxWidth = 0; $MaxHeight = 8;\r
+ foreach($DataDescription["Description"] as $Key => $Value)\r
+ {\r
+ $Position = imageftbbox($this->FontSize,0,$this->FontName,$Value);\r
+ $TextWidth = $Position[2]-$Position[0];\r
+ $TextHeight = $Position[1]-$Position[7];\r
+ if ( $TextWidth > $MaxWidth) { $MaxWidth = $TextWidth; }\r
+ $MaxHeight = $MaxHeight + $TextHeight + 4;\r
+ }\r
+ $MaxHeight = $MaxHeight - 5;\r
+ $MaxWidth = $MaxWidth + 32;\r
+\r
+ if ( $Rs == -1 || $Gs == -1 || $Bs == -1 )\r
+ { $Rs = $R-30; $Gs = $G-30; $Bs = $B-30; }\r
+\r
+ if ( $Border )\r
+ {\r
+ $this->drawFilledRoundedRectangle($XPos+1,$YPos+1,$XPos+$MaxWidth+1,$YPos+$MaxHeight+1,5,$Rs,$Gs,$Bs);\r
+ $this->drawFilledRoundedRectangle($XPos,$YPos,$XPos+$MaxWidth,$YPos+$MaxHeight,5,$R,$G,$B);\r
+ }\r
+\r
+ $YOffset = 4 + $this->FontSize; $ID = 0;\r
+ foreach($DataDescription["Description"] as $Key => $Value)\r
+ {\r
+ $this->drawFilledRoundedRectangle($XPos+10,$YPos+$YOffset-4,$XPos+14,$YPos+$YOffset-4,2,$this->Palette[$ID]["R"],$this->Palette[$ID]["G"],$this->Palette[$ID]["B"]);\r
+ imagettftext($this->Picture,$this->FontSize,0,$XPos+22,$YPos+$YOffset,$C_TextColor,$this->FontName,$Value);\r
+\r
+ $Position = imageftbbox($this->FontSize,0,$this->FontName,$Value);\r
+ $TextHeight = $Position[1]-$Position[7];\r
+\r
+ $YOffset = $YOffset + $TextHeight + 4;\r
+ $ID++;\r
+ }\r
+ }\r
+\r
+ /* Draw the data legends */\r
+ function drawPieLegend($XPos,$YPos,$Data,$DataDescription,$R,$G,$B)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawPieLegend",$DataDescription,FALSE);\r
+ $this->validateData("drawPieLegend",$Data);\r
+\r
+ if ( !isset($DataDescription["Position"]) )\r
+ return(-1);\r
+\r
+ $C_TextColor =$this->AllocateColor($this->Picture,0,0,0);\r
+\r
+ /* <-10->[8]<-4->Text<-10-> */\r
+ $MaxWidth = 0; $MaxHeight = 8;\r
+ foreach($Data as $Key => $Value)\r
+ {\r
+ $Value2 = $Value[$DataDescription["Position"]];\r
+ $Position = imageftbbox($this->FontSize,0,$this->FontName,$Value2);\r
+ $TextWidth = $Position[2]-$Position[0];\r
+ $TextHeight = $Position[1]-$Position[7];\r
+ if ( $TextWidth > $MaxWidth) { $MaxWidth = $TextWidth; }\r
+\r
+ $MaxHeight = $MaxHeight + $TextHeight + 4;\r
+ }\r
+ $MaxHeight = $MaxHeight - 3;\r
+ $MaxWidth = $MaxWidth + 32;\r
+\r
+ $this->drawFilledRoundedRectangle($XPos+1,$YPos+1,$XPos+$MaxWidth+1,$YPos+$MaxHeight+1,5,$R-30,$G-30,$B-30);\r
+ $this->drawFilledRoundedRectangle($XPos,$YPos,$XPos+$MaxWidth,$YPos+$MaxHeight,5,$R,$G,$B);\r
+\r
+ $YOffset = 4 + $this->FontSize; $ID = 0;\r
+ foreach($Data as $Key => $Value)\r
+ {\r
+ $Value2 = $Value[$DataDescription["Position"]];\r
+ $Position = imageftbbox($this->FontSize,0,$this->FontName,$Value2);\r
+ $TextHeight = $Position[1]-$Position[7];\r
+ $this->drawFilledRectangle($XPos+10,$YPos+$YOffset-6,$XPos+14,$YPos+$YOffset-2,$this->Palette[$ID]["R"],$this->Palette[$ID]["G"],$this->Palette[$ID]["B"]);\r
+\r
+ imagettftext($this->Picture,$this->FontSize,0,$XPos+22,$YPos+$YOffset,$C_TextColor,$this->FontName,$Value2);\r
+ $YOffset = $YOffset + $TextHeight + 4;\r
+ $ID++;\r
+ }\r
+ }\r
+\r
+ /* Draw the graph title */\r
+ function drawTitle($XPos,$YPos,$Value,$R,$G,$B,$XPos2=-1,$YPos2=-1,$Shadow=FALSE)\r
+ {\r
+ $C_TextColor = $this->AllocateColor($this->Picture,$R,$G,$B);\r
+\r
+ if ( $XPos2 != -1 )\r
+ {\r
+ $Position = imageftbbox($this->FontSize,0,$this->FontName,$Value);\r
+ $TextWidth = $Position[2]-$Position[0];\r
+ $XPos = floor(( $XPos2 - $XPos - $TextWidth ) / 2 ) + $XPos;\r
+ }\r
+\r
+ if ( $YPos2 != -1 )\r
+ {\r
+ $Position = imageftbbox($this->FontSize,0,$this->FontName,$Value);\r
+ $TextHeight = $Position[5]-$Position[3];\r
+ $YPos = floor(( $YPos2 - $YPos - $TextHeight ) / 2 ) + $YPos;\r
+ }\r
+\r
+ if ( $Shadow )\r
+ {\r
+ $C_ShadowColor = $this->AllocateColor($this->Picture,$this->ShadowRColor,$this->ShadowGColor,$this->ShadowBColor);\r
+ imagettftext($this->Picture,$this->FontSize,0,$XPos+$this->ShadowXDistance,$YPos+$this->ShadowYDistance,$C_ShadowColor,$this->FontName,$Value); \r
+ }\r
+\r
+ imagettftext($this->Picture,$this->FontSize,0,$XPos,$YPos,$C_TextColor,$this->FontName,$Value); \r
+ }\r
+\r
+ /* Draw a text box with text align & alpha properties */\r
+ function drawTextBox($X1,$Y1,$X2,$Y2,$Text,$Angle=0,$R=255,$G=255,$B=255,$Align=ALIGN_LEFT,$Shadow=TRUE,$BgR=-1,$BgG=-1,$BgB=-1,$Alpha=100)\r
+ {\r
+ $Position = imageftbbox($this->FontSize,$Angle,$this->FontName,$Text);\r
+ $TextWidth = $Position[2]-$Position[0];\r
+ $TextHeight = $Position[5]-$Position[3];\r
+ $AreaWidth = $X2 - $X1;\r
+ $AreaHeight = $Y2 - $Y1;\r
+\r
+ if ( $BgR != -1 && $BgG != -1 && $BgB != -1 )\r
+ $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,$BgR,$BgG,$BgB,FALSE,$Alpha);\r
+\r
+ if ( $Align == ALIGN_TOP_LEFT ) { $X = $X1+1; $Y = $Y1+$this->FontSize+1; }\r
+ if ( $Align == ALIGN_TOP_CENTER ) { $X = $X1+($AreaWidth/2)-($TextWidth/2); $Y = $Y1+$this->FontSize+1; }\r
+ if ( $Align == ALIGN_TOP_RIGHT ) { $X = $X2-$TextWidth-1; $Y = $Y1+$this->FontSize+1; }\r
+ if ( $Align == ALIGN_LEFT ) { $X = $X1+1; $Y = $Y1+($AreaHeight/2)-($TextHeight/2); }\r
+ if ( $Align == ALIGN_CENTER ) { $X = $X1+($AreaWidth/2)-($TextWidth/2); $Y = $Y1+($AreaHeight/2)-($TextHeight/2); }\r
+ if ( $Align == ALIGN_RIGHT ) { $X = $X2-$TextWidth-1; $Y = $Y1+($AreaHeight/2)-($TextHeight/2); }\r
+ if ( $Align == ALIGN_BOTTOM_LEFT ) { $X = $X1+1; $Y = $Y2-1; }\r
+ if ( $Align == ALIGN_BOTTOM_CENTER ) { $X = $X1+($AreaWidth/2)-($TextWidth/2); $Y = $Y2-1; }\r
+ if ( $Align == ALIGN_BOTTOM_RIGHT ) { $X = $X2-$TextWidth-1; $Y = $Y2-1; }\r
+\r
+ $C_TextColor =$this->AllocateColor($this->Picture,$R,$G,$B);\r
+ $C_ShadowColor =$this->AllocateColor($this->Picture,0,0,0);\r
+ if ( $Shadow )\r
+ imagettftext($this->Picture,$this->FontSize,$Angle,$X+1,$Y+1,$C_ShadowColor,$this->FontName,$Text); \r
+\r
+ imagettftext($this->Picture,$this->FontSize,$Angle,$X,$Y,$C_TextColor,$this->FontName,$Text); \r
+ }\r
+\r
+ /* Compute and draw the scale */\r
+ function drawTreshold($Value,$R,$G,$B,$ShowLabel=FALSE,$ShowOnRight=FALSE,$TickWidth=4,$FreeText=NULL)\r
+ {\r
+ if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }\r
+ if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }\r
+ if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }\r
+\r
+ $C_TextColor =$this->AllocateColor($this->Picture,$R,$G,$B);\r
+ $Y = $this->GArea_Y2 - ($Value - $this->VMin) * $this->DivisionRatio;\r
+\r
+ if ( $Y <= $this->GArea_Y1 || $Y >= $this->GArea_Y2 )\r
+ return(-1);\r
+\r
+ if ( $TickWidth == 0 )\r
+ $this->drawLine($this->GArea_X1,$Y,$this->GArea_X2,$Y,$R,$G,$B);\r
+ else\r
+ $this->drawDottedLine($this->GArea_X1,$Y,$this->GArea_X2,$Y,$TickWidth,$R,$G,$B);\r
+\r
+ if ( $ShowLabel )\r
+ {\r
+ if ( $FreeText == NULL )\r
+ { $Label = $Value; } else { $Label = $FreeText; }\r
+\r
+ if ( $ShowOnRight )\r
+ imagettftext($this->Picture,$this->FontSize,0,$this->GArea_X2+2,$Y+($this->FontSize/2),$C_TextColor,$this->FontName,$Label);\r
+ else\r
+ imagettftext($this->Picture,$this->FontSize,0,$this->GArea_X1+2,$Y-($this->FontSize/2),$C_TextColor,$this->FontName,$Label);\r
+ }\r
+ }\r
+\r
+ /* This function put a label on a specific point */\r
+ function setLabel($Data,$DataDescription,$SerieName,$ValueName,$Caption,$R=210,$G=210,$B=210)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("setLabel",$DataDescription);\r
+ $this->validateData("setLabel",$Data);\r
+ $ShadowFactor = 100;\r
+ $C_Label =$this->AllocateColor($this->Picture,$R,$G,$B);\r
+ $C_Shadow =$this->AllocateColor($this->Picture,$R-$ShadowFactor,$G-$ShadowFactor,$B-$ShadowFactor);\r
+ $C_TextColor =$this->AllocateColor($this->Picture,0,0,0);\r
+\r
+ $Cp = 0; $Found = FALSE;\r
+ foreach ( $Data as $Key => $Value )\r
+ {\r
+ if ( $Data[$Key][$DataDescription["Position"]] == $ValueName )\r
+ { $NumericalValue = $Data[$Key][$SerieName]; $Found = TRUE; }\r
+ if ( !$Found )\r
+ $Cp++;\r
+ }\r
+\r
+ $XPos = $this->GArea_X1 + $this->GAreaXOffset + ( $this->DivisionWidth * $Cp ) + 2;\r
+ $YPos = $this->GArea_Y2 - ($NumericalValue - $this->VMin) * $this->DivisionRatio;\r
+\r
+ $Position = imageftbbox($this->FontSize,0,$this->FontName,$Caption);\r
+ $TextHeight = $Position[3] - $Position[5];\r
+ $TextWidth = $Position[2]-$Position[0] + 2;\r
+ $TextOffset = floor($TextHeight/2);\r
+\r
+ // Shadow\r
+ $Poly = array($XPos+1,$YPos+1,$XPos + 9,$YPos - $TextOffset,$XPos + 8,$YPos + $TextOffset + 2);\r
+ imagefilledpolygon($this->Picture,$Poly,3,$C_Shadow);\r
+ $this->drawLine($XPos,$YPos+1,$XPos + 9,$YPos - $TextOffset - .2,$R-$ShadowFactor,$G-$ShadowFactor,$B-$ShadowFactor);\r
+ $this->drawLine($XPos,$YPos+1,$XPos + 9,$YPos + $TextOffset + 2.2,$R-$ShadowFactor,$G-$ShadowFactor,$B-$ShadowFactor);\r
+ $this->drawFilledRectangle($XPos + 9,$YPos - $TextOffset-.2,$XPos + 13 + $TextWidth,$YPos + $TextOffset + 2.2,$R-$ShadowFactor,$G-$ShadowFactor,$B-$ShadowFactor);\r
+\r
+ // Label background\r
+ $Poly = array($XPos,$YPos,$XPos + 8,$YPos - $TextOffset - 1,$XPos + 8,$YPos + $TextOffset + 1);\r
+ imagefilledpolygon($this->Picture,$Poly,3,$C_Label);\r
+ $this->drawLine($XPos-1,$YPos,$XPos + 8,$YPos - $TextOffset - 1.2,$R,$G,$B);\r
+ $this->drawLine($XPos-1,$YPos,$XPos + 8,$YPos + $TextOffset + 1.2,$R,$G,$B);\r
+ $this->drawFilledRectangle($XPos + 8,$YPos - $TextOffset - 1.2,$XPos + 12 + $TextWidth,$YPos + $TextOffset + 1.2,$R,$G,$B);\r
+\r
+ imagettftext($this->Picture,$this->FontSize,0,$XPos + 10,$YPos + $TextOffset,$C_TextColor,$this->FontName,$Caption);\r
+ }\r
+\r
+ /* This function draw a plot graph */\r
+ function drawPlotGraph($Data,$DataDescription,$BigRadius=5,$SmallRadius=2,$R2=-1,$G2=-1,$B2=-1,$Shadow=FALSE)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawPlotGraph",$DataDescription);\r
+ $this->validateData("drawPlotGraph",$Data);\r
+\r
+ $GraphID = 0;\r
+ $Ro = $R2; $Go = $G2; $Bo = $B2;\r
+\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ $ID = 0;\r
+ foreach ( $DataDescription["Description"] as $keyI => $ValueI )\r
+ { if ( $keyI == $ColName ) { $ColorID = $ID; }; $ID++; }\r
+\r
+ $R = $this->Palette[$ColorID]["R"];\r
+ $G = $this->Palette[$ColorID]["G"];\r
+ $B = $this->Palette[$ColorID]["B"];\r
+ $R2 = $Ro; $G2 = $Go; $B2 = $Bo;\r
+\r
+ if ( isset($DataDescription["Symbol"][$ColName]) )\r
+ {\r
+ $Is_Alpha = ((ord ( file_get_contents ($DataDescription["Symbol"][$ColName], false, null, 25, 1)) & 6) & 4) == 4;\r
+\r
+ $Infos = getimagesize($DataDescription["Symbol"][$ColName]);\r
+ $ImageWidth = $Infos[0];\r
+ $ImageHeight = $Infos[1];\r
+ $Symbol = imagecreatefromgif($DataDescription["Symbol"][$ColName]);\r
+ }\r
+\r
+ $XPos = $this->GArea_X1 + $this->GAreaXOffset;\r
+ $Hsize = round($BigRadius/2);\r
+ $R3 = -1; $G3 = -1; $B3 = -1;\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ $Value = $Data[$Key][$ColName];\r
+ $YPos = $this->GArea_Y2 - (($Value-$this->VMin) * $this->DivisionRatio);\r
+\r
+ /* Save point into the image map if option activated */\r
+ if ( $this->BuildMap )\r
+ $this->addToImageMap($XPos-$Hsize,$YPos-$Hsize,$XPos+1+$Hsize,$YPos+$Hsize+1,$DataDescription["Description"][$ColName],$Data[$Key][$ColName].$DataDescription["Unit"]["Y"],"Plot");\r
+\r
+ if ( is_numeric($Value) )\r
+ {\r
+ if ( !isset($DataDescription["Symbol"][$ColName]) )\r
+ {\r
+\r
+ if ( $Shadow )\r
+ {\r
+ if ( $R3 !=-1 && $G3 !=-1 && $B3 !=-1 )\r
+ $this->drawFilledCircle($XPos+2,$YPos+2,$BigRadius,$R3,$G3,$B3);\r
+ else\r
+ {\r
+ $R3 = $this->Palette[$ColorID]["R"]-20; if ( $R3 < 0 ) { $R3 = 0; }\r
+ $G3 = $this->Palette[$ColorID]["G"]-20; if ( $G3 < 0 ) { $G3 = 0; }\r
+ $B3 = $this->Palette[$ColorID]["B"]-20; if ( $B3 < 0 ) { $B3 = 0; }\r
+ $this->drawFilledCircle($XPos+2,$YPos+2,$BigRadius,$R3,$G3,$B3);\r
+ }\r
+ }\r
+\r
+ $this->drawFilledCircle($XPos+1,$YPos+1,$BigRadius,$R,$G,$B);\r
+\r
+ if ( $SmallRadius != 0 )\r
+ {\r
+ if ( $R2 !=-1 && $G2 !=-1 && $B2 !=-1 )\r
+ $this->drawFilledCircle($XPos+1,$YPos+1,$SmallRadius,$R2,$G2,$B2);\r
+ else\r
+ {\r
+ $R2 = $this->Palette[$ColorID]["R"]-15; if ( $R2 < 0 ) { $R2 = 0; }\r
+ $G2 = $this->Palette[$ColorID]["G"]-15; if ( $G2 < 0 ) { $G2 = 0; }\r
+ $B2 = $this->Palette[$ColorID]["B"]-15; if ( $B2 < 0 ) { $B2 = 0; }\r
+\r
+ $this->drawFilledCircle($XPos+1,$YPos+1,$SmallRadius,$R2,$G2,$B2);\r
+ }\r
+ }\r
+ }\r
+ else\r
+ {\r
+ imagecopymerge($this->Picture,$Symbol,$XPos+1-$ImageWidth/2,$YPos+1-$ImageHeight/2,0,0,$ImageWidth,$ImageHeight,100);\r
+ }\r
+ }\r
+\r
+ $XPos = $XPos + $this->DivisionWidth;\r
+ }\r
+ $GraphID++;\r
+ }\r
+ }\r
+\r
+ /* This function draw a plot graph in an X/Y space */\r
+ function drawXYPlotGraph($Data,$DataDescription,$YSerieName,$XSerieName,$PaletteID=0,$BigRadius=5,$SmallRadius=2,$R2=-1,$G2=-1,$B2=-1,$Shadow=TRUE)\r
+ {\r
+ $R = $this->Palette[$PaletteID]["R"];\r
+ $G = $this->Palette[$PaletteID]["G"];\r
+ $B = $this->Palette[$PaletteID]["B"];\r
+ $R3 = -1; $G3 = -1; $B3 = -1;\r
+\r
+ $YLast = -1; $XLast = -1;\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if ( isset($Data[$Key][$YSerieName]) && isset($Data[$Key][$XSerieName]) )\r
+ {\r
+ $X = $Data[$Key][$XSerieName];\r
+ $Y = $Data[$Key][$YSerieName];\r
+\r
+ $Y = $this->GArea_Y2 - (($Y-$this->VMin) * $this->DivisionRatio);\r
+ $X = $this->GArea_X1 + (($X-$this->VXMin) * $this->XDivisionRatio);\r
+\r
+\r
+ if ( $Shadow )\r
+ {\r
+ if ( $R3 !=-1 && $G3 !=-1 && $B3 !=-1 )\r
+ $this->drawFilledCircle($X+2,$Y+2,$BigRadius,$R3,$G3,$B3);\r
+ else\r
+ {\r
+ $R3 = $this->Palette[$PaletteID]["R"]-20; if ( $R < 0 ) { $R = 0; }\r
+ $G3 = $this->Palette[$PaletteID]["G"]-20; if ( $G < 0 ) { $G = 0; }\r
+ $B3 = $this->Palette[$PaletteID]["B"]-20; if ( $B < 0 ) { $B = 0; }\r
+ $this->drawFilledCircle($X+2,$Y+2,$BigRadius,$R3,$G3,$B3);\r
+ }\r
+ }\r
+\r
+ $this->drawFilledCircle($X+1,$Y+1,$BigRadius,$R,$G,$B);\r
+\r
+ if ( $R2 !=-1 && $G2 !=-1 && $B2 !=-1 )\r
+ $this->drawFilledCircle($X+1,$Y+1,$SmallRadius,$R2,$G2,$B2);\r
+ else\r
+ {\r
+ $R2 = $this->Palette[$PaletteID]["R"]+20; if ( $R > 255 ) { $R = 255; }\r
+ $G2 = $this->Palette[$PaletteID]["G"]+20; if ( $G > 255 ) { $G = 255; }\r
+ $B2 = $this->Palette[$PaletteID]["B"]+20; if ( $B > 255 ) { $B = 255; }\r
+ $this->drawFilledCircle($X+1,$Y+1,$SmallRadius,$R2,$G2,$B2);\r
+ }\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ /* This function draw an area between two series */\r
+ function drawArea($Data,$Serie1,$Serie2,$R,$G,$B,$Alpha = 50)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateData("drawArea",$Data);\r
+\r
+ $LayerWidth = $this->GArea_X2-$this->GArea_X1;\r
+ $LayerHeight = $this->GArea_Y2-$this->GArea_Y1;\r
+\r
+ $this->Layers[0] = imagecreatetruecolor($LayerWidth,$LayerHeight);\r
+ $C_White =$this->AllocateColor($this->Layers[0],255,255,255);\r
+ imagefilledrectangle($this->Layers[0],0,0,$LayerWidth,$LayerHeight,$C_White);\r
+ imagecolortransparent($this->Layers[0],$C_White);\r
+\r
+ $C_Graph =$this->AllocateColor($this->Layers[0],$R,$G,$B);\r
+\r
+ $XPos = $this->GAreaXOffset;\r
+ $LastXPos = -1;\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ $Value1 = $Data[$Key][$Serie1];\r
+ $Value2 = $Data[$Key][$Serie2];\r
+ $YPos1 = $LayerHeight - (($Value1-$this->VMin) * $this->DivisionRatio);\r
+ $YPos2 = $LayerHeight - (($Value2-$this->VMin) * $this->DivisionRatio);\r
+\r
+ if ( $LastXPos != -1 )\r
+ {\r
+ $Points = "";\r
+ $Points[] = $LastXPos; $Points[] = $LastYPos1;\r
+ $Points[] = $LastXPos; $Points[] = $LastYPos2;\r
+ $Points[] = $XPos; $Points[] = $YPos2;\r
+ $Points[] = $XPos; $Points[] = $YPos1;\r
+\r
+ imagefilledpolygon($this->Layers[0],$Points,4,$C_Graph);\r
+ }\r
+\r
+ $LastYPos1 = $YPos1;\r
+ $LastYPos2 = $YPos2;\r
+ $LastXPos = $XPos;\r
+\r
+ $XPos = $XPos + $this->DivisionWidth;\r
+ }\r
+\r
+ imagecopymerge($this->Picture,$this->Layers[0],$this->GArea_X1,$this->GArea_Y1,0,0,$LayerWidth,$LayerHeight,$Alpha);\r
+ imagedestroy($this->Layers[0]);\r
+ }\r
+\r
+\r
+ /* This function write the values of the specified series */\r
+ function writeValues($Data,$DataDescription,$Series)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("writeValues",$DataDescription);\r
+ $this->validateData("writeValues",$Data);\r
+\r
+ if ( !is_array($Series) ) { $Series = array($Series); } \r
+\r
+ foreach($Series as $Key => $Serie)\r
+ {\r
+ $ID = 0;\r
+ foreach ( $DataDescription["Description"] as $keyI => $ValueI )\r
+ { if ( $keyI == $Serie ) { $ColorID = $ID; }; $ID++; }\r
+\r
+ $XPos = $this->GArea_X1 + $this->GAreaXOffset;\r
+ $XLast = -1;\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if ( isset($Data[$Key][$Serie]) && is_numeric($Data[$Key][$Serie]))\r
+ {\r
+ $Value = $Data[$Key][$Serie];\r
+ $YPos = $this->GArea_Y2 - (($Value-$this->VMin) * $this->DivisionRatio);\r
+\r
+ $Positions = imagettfbbox($this->FontSize,0,$this->FontName,$Value);\r
+ $Width = $Positions[2] - $Positions[6]; $XOffset = $XPos - ($Width/2); \r
+ $Height = $Positions[3] - $Positions[7]; $YOffset = $YPos - 4;\r
+\r
+ $C_TextColor =$this->AllocateColor($this->Picture,$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"]);\r
+ imagettftext($this->Picture,$this->FontSize,0,$XOffset,$YOffset,$C_TextColor,$this->FontName,$Value);\r
+ }\r
+ $XPos = $XPos + $this->DivisionWidth;\r
+ }\r
+\r
+ }\r
+ }\r
+\r
+ /* This function draw a line graph */\r
+ function drawLineGraph($Data,$DataDescription,$SerieName="")\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawLineGraph",$DataDescription);\r
+ $this->validateData("drawLineGraph",$Data);\r
+\r
+ $GraphID = 0;\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ $ID = 0;\r
+ foreach ( $DataDescription["Description"] as $keyI => $ValueI )\r
+ { if ( $keyI == $ColName ) { $ColorID = $ID; }; $ID++; }\r
+\r
+ if ( $SerieName == "" || $SerieName == $ColName )\r
+ {\r
+ $XPos = $this->GArea_X1 + $this->GAreaXOffset;\r
+ $XLast = -1;\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if ( isset($Data[$Key][$ColName]))\r
+ {\r
+ $Value = $Data[$Key][$ColName];\r
+ $YPos = $this->GArea_Y2 - (($Value-$this->VMin) * $this->DivisionRatio);\r
+\r
+ /* Save point into the image map if option activated */\r
+ if ( $this->BuildMap )\r
+ $this->addToImageMap($XPos-3,$YPos-3,$XPos+3,$YPos+3,$DataDescription["Description"][$ColName],$Data[$Key][$ColName].$DataDescription["Unit"]["Y"],"Line");\r
+\r
+ if (!is_numeric($Value)) { $XLast = -1; }\r
+ if ( $XLast != -1 )\r
+ $this->drawLine($XLast,$YLast,$XPos,$YPos,$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"],TRUE);\r
+\r
+ $XLast = $XPos;\r
+ $YLast = $YPos;\r
+ if (!is_numeric($Value)) { $XLast = -1; }\r
+ }\r
+ $XPos = $XPos + $this->DivisionWidth;\r
+ }\r
+ $GraphID++;\r
+ }\r
+ }\r
+ }\r
+\r
+ /* This function draw a line graph */\r
+ function drawXYGraph($Data,$DataDescription,$YSerieName,$XSerieName,$PaletteID=0)\r
+ {\r
+ $YLast = -1; $XLast = -1;\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if ( isset($Data[$Key][$YSerieName]) && isset($Data[$Key][$XSerieName]) )\r
+ {\r
+ $X = $Data[$Key][$XSerieName];\r
+ $Y = $Data[$Key][$YSerieName];\r
+\r
+ $Y = $this->GArea_Y2 - (($Y-$this->VMin) * $this->DivisionRatio);\r
+ $X = $this->GArea_X1 + (($X-$this->VXMin) * $this->XDivisionRatio);\r
+\r
+ if ($XLast != -1 && $YLast != -1)\r
+ {\r
+ $this->drawLine($XLast,$YLast,$X,$Y,$this->Palette[$PaletteID]["R"],$this->Palette[$PaletteID]["G"],$this->Palette[$PaletteID]["B"],TRUE);\r
+ }\r
+\r
+ $XLast = $X;\r
+ $YLast = $Y;\r
+ }\r
+ }\r
+ }\r
+\r
+ /* This function draw a cubic curve */\r
+ function drawCubicCurve($Data,$DataDescription,$Accuracy=.1,$SerieName="")\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawCubicCurve",$DataDescription);\r
+ $this->validateData("drawCubicCurve",$Data);\r
+\r
+ $GraphID = 0;\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ if ( $SerieName == "" || $SerieName == $ColName )\r
+ {\r
+ $XIn = ""; $Yin = ""; $Yt = ""; $U = "";\r
+ $XIn[0] = 0; $YIn[0] = 0;\r
+\r
+ $ID = 0;\r
+ foreach ( $DataDescription["Description"] as $keyI => $ValueI )\r
+ { if ( $keyI == $ColName ) { $ColorID = $ID; }; $ID++; }\r
+\r
+ $Index = 1;\r
+ $XLast = -1; $Missing = "";\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if ( isset($Data[$Key][$ColName]) )\r
+ {\r
+ $Value = $Data[$Key][$ColName];\r
+ $XIn[$Index] = $Index;\r
+ $YIn[$Index] = $Value;\r
+ if ( !is_numeric($Value) ) { $Missing[$Index] = TRUE; }\r
+ $Index++;\r
+ }\r
+ }\r
+ $Index--;\r
+\r
+ $Yt[0] = 0;\r
+ $Yt[1] = 0;\r
+ $U[1] = 0;\r
+ for($i=2;$i<=$Index-1;$i++)\r
+ {\r
+ $Sig = ($XIn[$i] - $XIn[$i-1]) / ($XIn[$i+1] - $XIn[$i-1]);\r
+ $p = $Sig * $Yt[$i-1] + 2;\r
+ $Yt[$i] = ($Sig - 1) / $p;\r
+ $U[$i] = ($YIn[$i+1] - $YIn[$i]) / ($XIn[$i+1] - $XIn[$i]) - ($YIn[$i] - $YIn[$i-1]) / ($XIn[$i] - $XIn[$i-1]);\r
+ $U[$i] = (6 * $U[$i] / ($XIn[$i+1] - $XIn[$i-1]) - $Sig * $U[$i-1]) / $p;\r
+ }\r
+\r
+ $qn = 0;\r
+ $un = 0;\r
+ $Yt[$Index] = ($un - $qn * $U[$Index-1]) / ($qn * $Yt[$Index-1] + 1);\r
+\r
+ for($k=$Index-1;$k>=1;$k--)\r
+ $Yt[$k] = $Yt[$k] * $Yt[$k+1] + $U[$k];\r
+\r
+ $XPos = $this->GArea_X1 + $this->GAreaXOffset;\r
+ for($X=1;$X<=$Index;$X=$X+$Accuracy)\r
+ {\r
+ $klo = 1;\r
+ $khi = $Index;\r
+ $k = $khi - $klo;\r
+ while($k > 1)\r
+ {\r
+ $k = $khi - $klo;\r
+ If ( $XIn[$k] >= $X )\r
+ $khi = $k;\r
+ else\r
+ $klo = $k;\r
+ }\r
+ $klo = $khi - 1;\r
+\r
+ $h = $XIn[$khi] - $XIn[$klo];\r
+ $a = ($XIn[$khi] - $X) / $h;\r
+ $b = ($X - $XIn[$klo]) / $h;\r
+ $Value = $a * $YIn[$klo] + $b * $YIn[$khi] + (($a*$a*$a - $a) * $Yt[$klo] + ($b*$b*$b - $b) * $Yt[$khi]) * ($h*$h) / 6;\r
+\r
+ $YPos = $this->GArea_Y2 - (($Value-$this->VMin) * $this->DivisionRatio);\r
+\r
+ if ( $XLast != -1 && !isset($Missing[floor($X)]) && !isset($Missing[floor($X+1)]) )\r
+ $this->drawLine($XLast,$YLast,$XPos,$YPos,$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"],TRUE);\r
+\r
+ $XLast = $XPos;\r
+ $YLast = $YPos;\r
+ $XPos = $XPos + $this->DivisionWidth * $Accuracy;\r
+ }\r
+\r
+ // Add potentialy missing values\r
+ $XPos = $XPos - $this->DivisionWidth * $Accuracy;\r
+ if ( $XPos < ($this->GArea_X2 - $this->GAreaXOffset) )\r
+ {\r
+ $YPos = $this->GArea_Y2 - (($YIn[$Index]-$this->VMin) * $this->DivisionRatio);\r
+ $this->drawLine($XLast,$YLast,$this->GArea_X2-$this->GAreaXOffset,$YPos,$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"],TRUE);\r
+ }\r
+\r
+ $GraphID++;\r
+ }\r
+ }\r
+ }\r
+\r
+ /* This function draw a filled cubic curve */\r
+ function drawFilledCubicCurve($Data,$DataDescription,$Accuracy=.1,$Alpha=100,$AroundZero=FALSE)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawFilledCubicCurve",$DataDescription);\r
+ $this->validateData("drawFilledCubicCurve",$Data);\r
+\r
+ $LayerWidth = $this->GArea_X2-$this->GArea_X1;\r
+ $LayerHeight = $this->GArea_Y2-$this->GArea_Y1;\r
+ $YZero = $LayerHeight - ((0-$this->VMin) * $this->DivisionRatio);\r
+ if ( $YZero > $LayerHeight ) { $YZero = $LayerHeight; }\r
+\r
+ $GraphID = 0;\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ $XIn = ""; $Yin = ""; $Yt = ""; $U = "";\r
+ $XIn[0] = 0; $YIn[0] = 0;\r
+\r
+ $ID = 0;\r
+ foreach ( $DataDescription["Description"] as $keyI => $ValueI )\r
+ { if ( $keyI == $ColName ) { $ColorID = $ID; }; $ID++; }\r
+\r
+ $Index = 1;\r
+ $XLast = -1; $Missing = "";\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ $Value = $Data[$Key][$ColName];\r
+ $XIn[$Index] = $Index;\r
+ $YIn[$Index] = $Value;\r
+ if ( !is_numeric($Value) ) { $Missing[$Index] = TRUE; }\r
+ $Index++;\r
+ }\r
+ $Index--;\r
+ \r
+ $Yt[0] = 0;\r
+ $Yt[1] = 0;\r
+ $U[1] = 0;\r
+ for($i=2;$i<=$Index-1;$i++)\r
+ {\r
+ $Sig = ($XIn[$i] - $XIn[$i-1]) / ($XIn[$i+1] - $XIn[$i-1]);\r
+ $p = $Sig * $Yt[$i-1] + 2;\r
+ $Yt[$i] = ($Sig - 1) / $p;\r
+ $U[$i] = ($YIn[$i+1] - $YIn[$i]) / ($XIn[$i+1] - $XIn[$i]) - ($YIn[$i] - $YIn[$i-1]) / ($XIn[$i] - $XIn[$i-1]);\r
+ $U[$i] = (6 * $U[$i] / ($XIn[$i+1] - $XIn[$i-1]) - $Sig * $U[$i-1]) / $p;\r
+ }\r
+\r
+ $qn = 0;\r
+ $un = 0;\r
+ $Yt[$Index] = ($un - $qn * $U[$Index-1]) / ($qn * $Yt[$Index-1] + 1);\r
+\r
+ for($k=$Index-1;$k>=1;$k--)\r
+ $Yt[$k] = $Yt[$k] * $Yt[$k+1] + $U[$k];\r
+\r
+ $Points = "";\r
+ $Points[] = $this->GAreaXOffset;\r
+ $Points[] = $LayerHeight;\r
+\r
+ $this->Layers[0] = imagecreatetruecolor($LayerWidth,$LayerHeight);\r
+ $C_White =$this->AllocateColor($this->Layers[0],255,255,255);\r
+ imagefilledrectangle($this->Layers[0],0,0,$LayerWidth,$LayerHeight,$C_White);\r
+ imagecolortransparent($this->Layers[0],$C_White);\r
+\r
+ $YLast = NULL;\r
+ $XPos = $this->GAreaXOffset; $PointsCount = 2;\r
+ for($X=1;$X<=$Index;$X=$X+$Accuracy)\r
+ {\r
+ $klo = 1;\r
+ $khi = $Index;\r
+ $k = $khi - $klo;\r
+ while($k > 1)\r
+ {\r
+ $k = $khi - $klo;\r
+ If ( $XIn[$k] >= $X )\r
+ $khi = $k;\r
+ else\r
+ $klo = $k;\r
+ }\r
+ $klo = $khi - 1;\r
+\r
+ $h = $XIn[$khi] - $XIn[$klo];\r
+ $a = ($XIn[$khi] - $X) / $h;\r
+ $b = ($X - $XIn[$klo]) / $h;\r
+ $Value = $a * $YIn[$klo] + $b * $YIn[$khi] + (($a*$a*$a - $a) * $Yt[$klo] + ($b*$b*$b - $b) * $Yt[$khi]) * ($h*$h) / 6;\r
+\r
+ $YPos = $LayerHeight - (($Value-$this->VMin) * $this->DivisionRatio);\r
+\r
+ if ( $YLast != NULL && $AroundZero && !isset($Missing[floor($X)]) && !isset($Missing[floor($X+1)]))\r
+ {\r
+ $aPoints = "";\r
+ $aPoints[] = $XLast;\r
+ $aPoints[] = $YLast;\r
+ $aPoints[] = $XPos;\r
+ $aPoints[] = $YPos;\r
+ $aPoints[] = $XPos;\r
+ $aPoints[] = $YZero;\r
+ $aPoints[] = $XLast;\r
+ $aPoints[] = $YZero;\r
+\r
+ $C_Graph =$this->AllocateColor($this->Layers[0],$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"]);\r
+ imagefilledpolygon($this->Layers[0],$aPoints,4,$C_Graph);\r
+ }\r
+\r
+ if ( !isset($Missing[floor($X)]) || $YLast == NULL )\r
+ {\r
+ $PointsCount++;\r
+ $Points[] = $XPos;\r
+ $Points[] = $YPos;\r
+ }\r
+ else\r
+ {\r
+ $PointsCount++; $Points[] = $XLast; $Points[] = $LayerHeight;\r
+ }\r
+\r
+ $YLast = $YPos; $XLast = $XPos; \r
+ $XPos = $XPos + $this->DivisionWidth * $Accuracy;\r
+ }\r
+\r
+ // Add potentialy missing values\r
+ $XPos = $XPos - $this->DivisionWidth * $Accuracy;\r
+ if ( $XPos < ($LayerWidth-$this->GAreaXOffset) )\r
+ {\r
+ $YPos = $LayerHeight - (($YIn[$Index]-$this->VMin) * $this->DivisionRatio);\r
+\r
+ if ( $YLast != NULL && $AroundZero )\r
+ {\r
+ $aPoints = "";\r
+ $aPoints[] = $XLast;\r
+ $aPoints[] = $YLast;\r
+ $aPoints[] = $LayerWidth-$this->GAreaXOffset;\r
+ $aPoints[] = $YPos;\r
+ $aPoints[] = $LayerWidth-$this->GAreaXOffset;\r
+ $aPoints[] = $YZero;\r
+ $aPoints[] = $XLast;\r
+ $aPoints[] = $YZero;\r
+\r
+ $C_Graph =$this->AllocateColor($this->Layers[0],$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"]);\r
+ imagefilledpolygon($this->Layers[0],$aPoints,4,$C_Graph);\r
+ }\r
+\r
+ if ( $YIn[$klo] != "" && $YIn[$khi] != "" || $YLast == NULL )\r
+ {\r
+ $PointsCount++;\r
+ $Points[] = $LayerWidth-$this->GAreaXOffset;\r
+ $Points[] = $YPos;\r
+ }\r
+ }\r
+\r
+ $Points[] = $LayerWidth-$this->GAreaXOffset;\r
+ $Points[] = $LayerHeight;\r
+\r
+ if ( !$AroundZero )\r
+ {\r
+ $C_Graph =$this->AllocateColor($this->Layers[0],$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"]);\r
+ imagefilledpolygon($this->Layers[0],$Points,$PointsCount,$C_Graph);\r
+ }\r
+\r
+ imagecopymerge($this->Picture,$this->Layers[0],$this->GArea_X1,$this->GArea_Y1,0,0,$LayerWidth,$LayerHeight,$Alpha);\r
+ imagedestroy($this->Layers[0]);\r
+\r
+ $this->drawCubicCurve($Data,$DataDescription,$Accuracy,$ColName);\r
+\r
+ $GraphID++;\r
+ }\r
+ }\r
+\r
+ /* This function draw a filled line graph */\r
+ function drawFilledLineGraph($Data,$DataDescription,$Alpha=100,$AroundZero=FALSE)\r
+ {\r
+ $Empty = -2147483647;\r
+\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawFilledLineGraph",$DataDescription);\r
+ $this->validateData("drawFilledLineGraph",$Data);\r
+\r
+ $LayerWidth = $this->GArea_X2-$this->GArea_X1;\r
+ $LayerHeight = $this->GArea_Y2-$this->GArea_Y1;\r
+\r
+ $GraphID = 0;\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ $ID = 0;\r
+ foreach ( $DataDescription["Description"] as $keyI => $ValueI )\r
+ { if ( $keyI == $ColName ) { $ColorID = $ID; }; $ID++; }\r
+\r
+ $aPoints = "";\r
+ $aPoints[] = $this->GAreaXOffset;\r
+ $aPoints[] = $LayerHeight;\r
+\r
+ $this->Layers[0] = imagecreatetruecolor($LayerWidth,$LayerHeight);\r
+ $C_White = $this->AllocateColor($this->Layers[0],255,255,255);\r
+ imagefilledrectangle($this->Layers[0],0,0,$LayerWidth,$LayerHeight,$C_White);\r
+ imagecolortransparent($this->Layers[0],$C_White);\r
+\r
+ $XPos = $this->GAreaXOffset;\r
+ $XLast = -1; $PointsCount = 2;\r
+ $YZero = $LayerHeight - ((0-$this->VMin) * $this->DivisionRatio);\r
+ if ( $YZero > $LayerHeight ) { $YZero = $LayerHeight; }\r
+\r
+ $YLast = $Empty;\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ $Value = $Data[$Key][$ColName];\r
+ $YPos = $LayerHeight - (($Value-$this->VMin) * $this->DivisionRatio);\r
+\r
+ /* Save point into the image map if option activated */\r
+ if ( $this->BuildMap )\r
+ $this->addToImageMap($XPos-3,$YPos-3,$XPos+3,$YPos+3,$DataDescription["Description"][$ColName],$Data[$Key][$ColName].$DataDescription["Unit"]["Y"],"FLine");\r
+\r
+ if ( !is_numeric($Value) )\r
+ {\r
+ $PointsCount++;\r
+ $aPoints[] = $XLast;\r
+ $aPoints[] = $LayerHeight;\r
+\r
+ $YLast = $Empty;\r
+ }\r
+ else\r
+ {\r
+ $PointsCount++;\r
+ if ( $YLast <> $Empty )\r
+ { $aPoints[] = $XPos; $aPoints[] = $YPos; }\r
+ else\r
+ { $PointsCount++; $aPoints[] = $XPos; $aPoints[] = $LayerHeight; $aPoints[] = $XPos; $aPoints[] = $YPos; }\r
+\r
+ if ($YLast <> $Empty && $AroundZero)\r
+ {\r
+ $Points = "";\r
+ $Points[] = $XLast; $Points[] = $YLast;\r
+ $Points[] = $XPos;\r
+ $Points[] = $YPos;\r
+ $Points[] = $XPos;\r
+ $Points[] = $YZero;\r
+ $Points[] = $XLast;\r
+ $Points[] = $YZero;\r
+\r
+ $C_Graph = $this->AllocateColor($this->Layers[0],$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"]);\r
+ imagefilledpolygon($this->Layers[0],$Points,4,$C_Graph);\r
+ }\r
+ $YLast = $YPos;\r
+ }\r
+\r
+ $XLast = $XPos;\r
+ $XPos = $XPos + $this->DivisionWidth;\r
+ }\r
+ $aPoints[] = $LayerWidth - $this->GAreaXOffset;\r
+ $aPoints[] = $LayerHeight;\r
+\r
+ if ( $AroundZero == FALSE )\r
+ {\r
+ $C_Graph = $this->AllocateColor($this->Layers[0],$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"]);\r
+ imagefilledpolygon($this->Layers[0],$aPoints,$PointsCount,$C_Graph);\r
+ }\r
+\r
+ imagecopymerge($this->Picture,$this->Layers[0],$this->GArea_X1,$this->GArea_Y1,0,0,$LayerWidth,$LayerHeight,$Alpha);\r
+ imagedestroy($this->Layers[0]);\r
+ $GraphID++;\r
+ $this->drawLineGraph($Data,$DataDescription,$ColName);\r
+ }\r
+ }\r
+\r
+ /* This function draw a bar graph */\r
+ function drawOverlayBarGraph($Data,$DataDescription,$Alpha=50)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawOverlayBarGraph",$DataDescription);\r
+ $this->validateData("drawOverlayBarGraph",$Data);\r
+\r
+ $LayerWidth = $this->GArea_X2-$this->GArea_X1;\r
+ $LayerHeight = $this->GArea_Y2-$this->GArea_Y1;\r
+\r
+ $GraphID = 0;\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ $ID = 0;\r
+ foreach ( $DataDescription["Description"] as $keyI => $ValueI )\r
+ { if ( $keyI == $ColName ) { $ColorID = $ID; }; $ID++; }\r
+\r
+ $this->Layers[$GraphID] = imagecreatetruecolor($LayerWidth,$LayerHeight);\r
+ $C_White = $this->AllocateColor($this->Layers[$GraphID],255,255,255);\r
+ $C_Graph = $this->AllocateColor($this->Layers[$GraphID],$this->Palette[$GraphID]["R"],$this->Palette[$GraphID]["G"],$this->Palette[$GraphID]["B"]);\r
+ imagefilledrectangle($this->Layers[$GraphID],0,0,$LayerWidth,$LayerHeight,$C_White);\r
+ imagecolortransparent($this->Layers[$GraphID],$C_White);\r
+\r
+ $XWidth = $this->DivisionWidth / 4;\r
+ $XPos = $this->GAreaXOffset;\r
+ $YZero = $LayerHeight - ((0-$this->VMin) * $this->DivisionRatio);\r
+ $XLast = -1; $PointsCount = 2;\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if ( isset($Data[$Key][$ColName]) )\r
+ {\r
+ $Value = $Data[$Key][$ColName];\r
+ if ( is_numeric($Value) )\r
+ {\r
+ $YPos = $LayerHeight - (($Value-$this->VMin) * $this->DivisionRatio);\r
+\r
+ imagefilledrectangle($this->Layers[$GraphID],$XPos-$XWidth,$YPos,$XPos+$XWidth,$YZero,$C_Graph);\r
+\r
+ $X1 = floor($XPos - $XWidth + $this->GArea_X1); $Y1 = floor($YPos+$this->GArea_Y1) + .2;\r
+ $X2 = floor($XPos + $XWidth + $this->GArea_X1); $Y2 = $this->GArea_Y2 - ((0-$this->VMin) * $this->DivisionRatio);\r
+ if ( $X1 <= $this->GArea_X1 ) { $X1 = $this->GArea_X1 + 1; }\r
+ if ( $X2 >= $this->GArea_X2 ) { $X2 = $this->GArea_X2 - 1; }\r
+\r
+ /* Save point into the image map if option activated */\r
+ if ( $this->BuildMap )\r
+ $this->addToImageMap($X1,min($Y1,$Y2),$X2,max($Y1,$Y2),$DataDescription["Description"][$ColName],$Data[$Key][$ColName].$DataDescription["Unit"]["Y"],"oBar");\r
+\r
+ $this->drawLine($X1,$Y1,$X2,$Y1,$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"],TRUE);\r
+ }\r
+ }\r
+ $XPos = $XPos + $this->DivisionWidth;\r
+ }\r
+\r
+ $GraphID++;\r
+ }\r
+\r
+ for($i=0;$i<=($GraphID-1);$i++)\r
+ {\r
+ imagecopymerge($this->Picture,$this->Layers[$i],$this->GArea_X1,$this->GArea_Y1,0,0,$LayerWidth,$LayerHeight,$Alpha);\r
+ imagedestroy($this->Layers[$i]);\r
+ }\r
+ }\r
+\r
+ /* This function draw a bar graph */\r
+ function drawBarGraph($Data,$DataDescription,$Shadow=FALSE,$Alpha=100)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawBarGraph",$DataDescription);\r
+ $this->validateData("drawBarGraph",$Data);\r
+\r
+ $GraphID = 0;\r
+ $Series = count($DataDescription["Values"]);\r
+ $SeriesWidth = $this->DivisionWidth / ($Series+1);\r
+ $SerieXOffset = $this->DivisionWidth / 2 - $SeriesWidth / 2;\r
+\r
+ $YZero = $this->GArea_Y2 - ((0-$this->VMin) * $this->DivisionRatio);\r
+ if ( $YZero > $this->GArea_Y2 ) { $YZero = $this->GArea_Y2; }\r
+\r
+ $SerieID = 0;\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ $ID = 0;\r
+ foreach ( $DataDescription["Description"] as $keyI => $ValueI )\r
+ { if ( $keyI == $ColName ) { $ColorID = $ID; }; $ID++; }\r
+\r
+ $XPos = $this->GArea_X1 + $this->GAreaXOffset - $SerieXOffset + $SeriesWidth * $SerieID;\r
+ $XLast = -1;\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if ( isset($Data[$Key][$ColName]))\r
+ {\r
+ if ( is_numeric($Data[$Key][$ColName]) )\r
+ {\r
+ $Value = $Data[$Key][$ColName];\r
+ $YPos = $this->GArea_Y2 - (($Value-$this->VMin) * $this->DivisionRatio);\r
+\r
+ /* Save point into the image map if option activated */\r
+ if ( $this->BuildMap )\r
+ {\r
+ $this->addToImageMap($XPos+1,min($YZero,$YPos),$XPos+$SeriesWidth-1,max($YZero,$YPos),$DataDescription["Description"][$ColName],$Data[$Key][$ColName].$DataDescription["Unit"]["Y"],"Bar");\r
+ }\r
+ \r
+ if ( $Shadow && $Alpha == 100 )\r
+ $this->drawRectangle($XPos+1,$YZero,$XPos+$SeriesWidth-1,$YPos,25,25,25,TRUE,$Alpha);\r
+\r
+ $this->drawFilledRectangle($XPos+1,$YZero,$XPos+$SeriesWidth-1,$YPos,$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"],TRUE,$Alpha);\r
+ }\r
+ }\r
+ $XPos = $XPos + $this->DivisionWidth;\r
+ }\r
+ $SerieID++;\r
+ }\r
+ }\r
+\r
+ /* This function draw a stacked bar graph */\r
+ function drawStackedBarGraph($Data,$DataDescription,$Alpha=50,$Contiguous=FALSE)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawBarGraph",$DataDescription);\r
+ $this->validateData("drawBarGraph",$Data);\r
+\r
+ $GraphID = 0;\r
+ $Series = count($DataDescription["Values"]);\r
+ if ( $Contiguous )\r
+ $SeriesWidth = $this->DivisionWidth;\r
+ else\r
+ $SeriesWidth = $this->DivisionWidth * .8;\r
+\r
+ $YZero = $this->GArea_Y2 - ((0-$this->VMin) * $this->DivisionRatio);\r
+ if ( $YZero > $this->GArea_Y2 ) { $YZero = $this->GArea_Y2; }\r
+\r
+ $SerieID = 0; $LastValue = "";\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ $ID = 0;\r
+ foreach ( $DataDescription["Description"] as $keyI => $ValueI )\r
+ { if ( $keyI == $ColName ) { $ColorID = $ID; }; $ID++; }\r
+\r
+ $XPos = $this->GArea_X1 + $this->GAreaXOffset - $SeriesWidth / 2;\r
+ $XLast = -1; \r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if ( isset($Data[$Key][$ColName]))\r
+ {\r
+ if ( is_numeric($Data[$Key][$ColName]) )\r
+ {\r
+ $Value = $Data[$Key][$ColName];\r
+\r
+ if ( isset($LastValue[$Key]) )\r
+ {\r
+ $YPos = $this->GArea_Y2 - ((($Value+$LastValue[$Key])-$this->VMin) * $this->DivisionRatio);\r
+ $YBottom = $this->GArea_Y2 - (($LastValue[$Key]-$this->VMin) * $this->DivisionRatio);\r
+ $LastValue[$Key] += $Value;\r
+ }\r
+ else\r
+ {\r
+ $YPos = $this->GArea_Y2 - (($Value-$this->VMin) * $this->DivisionRatio);\r
+ $YBottom = $YZero;\r
+ $LastValue[$Key] = $Value;\r
+ }\r
+\r
+ /* Save point into the image map if option activated */\r
+ if ( $this->BuildMap )\r
+ $this->addToImageMap($XPos+1,min($YBottom,$YPos),$XPos+$SeriesWidth-1,max($YBottom,$YPos),$DataDescription["Description"][$ColName],$Data[$Key][$ColName].$DataDescription["Unit"]["Y"],"sBar");\r
+\r
+ $this->drawFilledRectangle($XPos+1,$YBottom,$XPos+$SeriesWidth-1,$YPos,$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"],TRUE,$Alpha);\r
+ }\r
+ }\r
+ $XPos = $XPos + $this->DivisionWidth;\r
+ }\r
+ $SerieID++;\r
+ }\r
+ }\r
+\r
+ /* This function draw a limits bar graphs */\r
+ function drawLimitsGraph($Data,$DataDescription,$R=0,$G=0,$B=0)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawLimitsGraph",$DataDescription);\r
+ $this->validateData("drawLimitsGraph",$Data);\r
+\r
+ $XWidth = $this->DivisionWidth / 4;\r
+ $XPos = $this->GArea_X1 + $this->GAreaXOffset;\r
+\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ $Min = $Data[$Key][$DataDescription["Values"][0]];\r
+ $Max = $Data[$Key][$DataDescription["Values"][0]];\r
+ $GraphID = 0; $MaxID = 0; $MinID = 0;\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ if ( isset($Data[$Key][$ColName]) )\r
+ {\r
+ if ( $Data[$Key][$ColName] > $Max && is_numeric($Data[$Key][$ColName]))\r
+ { $Max = $Data[$Key][$ColName]; $MaxID = $GraphID; }\r
+ }\r
+ if ( isset($Data[$Key][$ColName]) && is_numeric($Data[$Key][$ColName]))\r
+ {\r
+ if ( $Data[$Key][$ColName] < $Min )\r
+ { $Min = $Data[$Key][$ColName]; $MinID = $GraphID; }\r
+ $GraphID++;\r
+ }\r
+ }\r
+\r
+ $YPos = $this->GArea_Y2 - (($Max-$this->VMin) * $this->DivisionRatio);\r
+ $X1 = floor($XPos - $XWidth); $Y1 = floor($YPos) - .2;\r
+ $X2 = floor($XPos + $XWidth);\r
+ if ( $X1 <= $this->GArea_X1 ) { $X1 = $this->GArea_X1 + 1; }\r
+ if ( $X2 >= $this->GArea_X2 ) { $X2 = $this->GArea_X2 - 1; }\r
+\r
+ $YPos = $this->GArea_Y2 - (($Min-$this->VMin) * $this->DivisionRatio);\r
+ $Y2 = floor($YPos) + .2;\r
+\r
+ $this->drawLine(floor($XPos)-.2,$Y1+1,floor($XPos)-.2,$Y2-1,$R,$G,$B,TRUE);\r
+ $this->drawLine(floor($XPos)+.2,$Y1+1,floor($XPos)+.2,$Y2-1,$R,$G,$B,TRUE);\r
+ $this->drawLine($X1,$Y1,$X2,$Y1,$this->Palette[$MaxID]["R"],$this->Palette[$MaxID]["G"],$this->Palette[$MaxID]["B"],FALSE);\r
+ $this->drawLine($X1,$Y2,$X2,$Y2,$this->Palette[$MinID]["R"],$this->Palette[$MinID]["G"],$this->Palette[$MinID]["B"],FALSE);\r
+\r
+ $XPos = $XPos + $this->DivisionWidth;\r
+ }\r
+ }\r
+\r
+ /* This function draw radar axis centered on the graph area */\r
+ function drawRadarAxis($Data,$DataDescription,$Mosaic=TRUE,$BorderOffset=10,$A_R=60,$A_G=60,$A_B=60,$S_R=200,$S_G=200,$S_B=200,$MaxValue=-1)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawRadarAxis",$DataDescription);\r
+ $this->validateData("drawRadarAxis",$Data);\r
+\r
+ $C_TextColor = $this->AllocateColor($this->Picture,$A_R,$A_G,$A_B);\r
+\r
+ /* Draw radar axis */\r
+ $Points = count($Data);\r
+ $Radius = ( $this->GArea_Y2 - $this->GArea_Y1 ) / 2 - $BorderOffset;\r
+ $XCenter = ( $this->GArea_X2 - $this->GArea_X1 ) / 2 + $this->GArea_X1;\r
+ $YCenter = ( $this->GArea_Y2 - $this->GArea_Y1 ) / 2 + $this->GArea_Y1;\r
+\r
+ /* Search for the max value */\r
+ if ( $MaxValue == -1 )\r
+ {\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if ( isset($Data[$Key][$ColName]))\r
+ if ( $Data[$Key][$ColName] > $MaxValue ) { $MaxValue = $Data[$Key][$ColName]; }\r
+ }\r
+ }\r
+ }\r
+\r
+ /* Draw the mosaic */\r
+ if ( $Mosaic )\r
+ {\r
+ $RadiusScale = $Radius / $MaxValue;\r
+ for ( $t=1; $t<=$MaxValue-1; $t++)\r
+ {\r
+ $TRadius = $RadiusScale * $t;\r
+ $LastX1 = -1;\r
+\r
+ for ( $i=0; $i<=$Points; $i++)\r
+ {\r
+ $Angle = -90 + $i * 360/$Points;\r
+ $X1 = cos($Angle * 3.1418 / 180 ) * $TRadius + $XCenter;\r
+ $Y1 = sin($Angle * 3.1418 / 180 ) * $TRadius + $YCenter;\r
+ $X2 = cos($Angle * 3.1418 / 180 ) * ($TRadius+$RadiusScale) + $XCenter;\r
+ $Y2 = sin($Angle * 3.1418 / 180 ) * ($TRadius+$RadiusScale) + $YCenter;\r
+\r
+ if ( $t % 2 == 1 && $LastX1 != -1)\r
+ {\r
+ $Plots = "";\r
+ $Plots[] = $X1; $Plots[] = $Y1;\r
+ $Plots[] = $X2; $Plots[] = $Y2;\r
+ $Plots[] = $LastX2; $Plots[] = $LastY2;\r
+ $Plots[] = $LastX1; $Plots[] = $LastY1;\r
+\r
+ $C_Graph = $this->AllocateColor($this->Picture,250,250,250);\r
+ imagefilledpolygon($this->Picture,$Plots,(count($Plots)+1)/2,$C_Graph);\r
+ }\r
+\r
+ $LastX1 = $X1; $LastY1= $Y1;\r
+ $LastX2 = $X2; $LastY2= $Y2;\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ /* Draw the spider web */\r
+ for ( $t=1; $t<=$MaxValue; $t++)\r
+ {\r
+ $TRadius = ( $Radius / $MaxValue ) * $t;\r
+ $LastX = -1;\r
+\r
+ for ( $i=0; $i<=$Points; $i++)\r
+ {\r
+ $Angle = -90 + $i * 360/$Points;\r
+ $X = cos($Angle * 3.1418 / 180 ) * $TRadius + $XCenter;\r
+ $Y = sin($Angle * 3.1418 / 180 ) * $TRadius + $YCenter;\r
+\r
+ if ( $LastX != -1 )\r
+ $this->drawDottedLine($LastX,$LastY,$X,$Y,4,$S_R,$S_G,$S_B);\r
+\r
+ $LastX = $X; $LastY= $Y;\r
+ }\r
+ }\r
+\r
+ /* Draw the axis */\r
+ for ( $i=0; $i<=$Points; $i++)\r
+ {\r
+ $Angle = -90 + $i * 360/$Points;\r
+ $X = cos($Angle * 3.1418 / 180 ) * $Radius + $XCenter;\r
+ $Y = sin($Angle * 3.1418 / 180 ) * $Radius + $YCenter;\r
+\r
+ $this->drawLine($XCenter,$YCenter,$X,$Y,$A_R,$A_G,$A_B);\r
+\r
+ $XOffset = 0; $YOffset = 0;\r
+ if (isset($Data[$i][$DataDescription["Position"]]))\r
+ {\r
+ $Label = $Data[$i][$DataDescription["Position"]];\r
+\r
+ $Positions = imagettfbbox($this->FontSize,0,$this->FontName,$Label);\r
+ $Width = $Positions[2] - $Positions[6];\r
+ $Height = $Positions[3] - $Positions[7];\r
+\r
+ if ( $Angle >= 0 && $Angle <= 90 )\r
+ $YOffset = $Height;\r
+\r
+ if ( $Angle > 90 && $Angle <= 180 )\r
+ { $YOffset = $Height; $XOffset = -$Width; }\r
+\r
+ if ( $Angle > 180 && $Angle <= 270 )\r
+ { $XOffset = -$Width; }\r
+\r
+ imagettftext($this->Picture,$this->FontSize,0,$X+$XOffset,$Y+$YOffset,$C_TextColor,$this->FontName,$Label);\r
+ }\r
+ }\r
+\r
+ /* Write the values */\r
+ for ( $t=1; $t<=$MaxValue; $t++)\r
+ {\r
+ $TRadius = ( $Radius / $MaxValue ) * $t;\r
+\r
+ $Angle = -90 + 360 / $Points;\r
+ $X1 = $XCenter;\r
+ $Y1 = $YCenter - $TRadius;\r
+ $X2 = cos($Angle * 3.1418 / 180 ) * $TRadius + $XCenter;\r
+ $Y2 = sin($Angle * 3.1418 / 180 ) * $TRadius + $YCenter;\r
+\r
+ $XPos = floor(($X2-$X1)/2) + $X1;\r
+ $YPos = floor(($Y2-$Y1)/2) + $Y1;\r
+\r
+ $Positions = imagettfbbox($this->FontSize,0,$this->FontName,$t);\r
+ $X = $XPos - ( $X+$Positions[2] - $X+$Positions[6] ) / 2;\r
+ $Y = $YPos + $this->FontSize;\r
+\r
+ $this->drawFilledRoundedRectangle($X+$Positions[6]-2,$Y+$Positions[7]-1,$X+$Positions[2]+4,$Y+$Positions[3]+1,2,240,240,240);\r
+ $this->drawRoundedRectangle($X+$Positions[6]-2,$Y+$Positions[7]-1,$X+$Positions[2]+4,$Y+$Positions[3]+1,2,220,220,220);\r
+ imagettftext($this->Picture,$this->FontSize,0,$X,$Y,$C_TextColor,$this->FontName,$t);\r
+ }\r
+ }\r
+\r
+ /* This function draw a radar graph centered on the graph area */\r
+ function drawRadar($Data,$DataDescription,$BorderOffset=10,$MaxValue=-1)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawRadar",$DataDescription);\r
+ $this->validateData("drawRadar",$Data);\r
+\r
+ $Points = count($Data);\r
+ $Radius = ( $this->GArea_Y2 - $this->GArea_Y1 ) / 2 - $BorderOffset;\r
+ $XCenter = ( $this->GArea_X2 - $this->GArea_X1 ) / 2 + $this->GArea_X1;\r
+ $YCenter = ( $this->GArea_Y2 - $this->GArea_Y1 ) / 2 + $this->GArea_Y1;\r
+\r
+ /* Search for the max value */\r
+ if ( $MaxValue == -1 )\r
+ {\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if ( isset($Data[$Key][$ColName]))\r
+ if ( $Data[$Key][$ColName] > $MaxValue ) { $MaxValue = $Data[$Key][$ColName]; }\r
+ }\r
+ }\r
+ }\r
+\r
+ $GraphID = 0;\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ $ID = 0;\r
+ foreach ( $DataDescription["Description"] as $keyI => $ValueI )\r
+ { if ( $keyI == $ColName ) { $ColorID = $ID; }; $ID++; }\r
+\r
+ $Angle = -90;\r
+ $XLast = -1;\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if ( isset($Data[$Key][$ColName]))\r
+ {\r
+ $Value = $Data[$Key][$ColName];\r
+ $Strength = ( $Radius / $MaxValue ) * $Value;\r
+\r
+ $XPos = cos($Angle * 3.1418 / 180 ) * $Strength + $XCenter;\r
+ $YPos = sin($Angle * 3.1418 / 180 ) * $Strength + $YCenter;\r
+\r
+ if ( $XLast != -1 )\r
+ $this->drawLine($XLast,$YLast,$XPos,$YPos,$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"]);\r
+\r
+ if ( $XLast == -1 )\r
+ { $FirstX = $XPos; $FirstY = $YPos; }\r
+\r
+ $Angle = $Angle + (360/$Points);\r
+ $XLast = $XPos;\r
+ $YLast = $YPos;\r
+ }\r
+ }\r
+ $this->drawLine($XPos,$YPos,$FirstX,$FirstY,$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"]);\r
+ $GraphID++;\r
+ }\r
+ }\r
+\r
+ /* This function draw a radar graph centered on the graph area */\r
+ function drawFilledRadar($Data,$DataDescription,$Alpha=50,$BorderOffset=10,$MaxValue=-1)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawFilledRadar",$DataDescription);\r
+ $this->validateData("drawFilledRadar",$Data);\r
+\r
+ $Points = count($Data);\r
+ $LayerWidth = $this->GArea_X2-$this->GArea_X1;\r
+ $LayerHeight = $this->GArea_Y2-$this->GArea_Y1;\r
+ $Radius = ( $this->GArea_Y2 - $this->GArea_Y1 ) / 2 - $BorderOffset;\r
+ $XCenter = ( $this->GArea_X2 - $this->GArea_X1 ) / 2;\r
+ $YCenter = ( $this->GArea_Y2 - $this->GArea_Y1 ) / 2;\r
+\r
+ /* Search for the max value */\r
+ if ( $MaxValue == -1 )\r
+ {\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if ( isset($Data[$Key][$ColName]))\r
+ if ( $Data[$Key][$ColName] > $MaxValue && is_numeric($Data[$Key][$ColName])) { $MaxValue = $Data[$Key][$ColName]; }\r
+ }\r
+ }\r
+ }\r
+\r
+ $GraphID = 0;\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ $ID = 0;\r
+ foreach ( $DataDescription["Description"] as $keyI => $ValueI )\r
+ { if ( $keyI == $ColName ) { $ColorID = $ID; }; $ID++; }\r
+\r
+ $Angle = -90;\r
+ $XLast = -1;\r
+ $Plots = "";\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if ( isset($Data[$Key][$ColName]))\r
+ {\r
+ $Value = $Data[$Key][$ColName];\r
+ if ( !is_numeric($Value) ) { $Value = 0; }\r
+ $Strength = ( $Radius / $MaxValue ) * $Value;\r
+\r
+ $XPos = cos($Angle * 3.1418 / 180 ) * $Strength + $XCenter;\r
+ $YPos = sin($Angle * 3.1418 / 180 ) * $Strength + $YCenter;\r
+\r
+ $Plots[] = $XPos;\r
+ $Plots[] = $YPos;\r
+\r
+ $Angle = $Angle + (360/$Points);\r
+ $XLast = $XPos;\r
+ $YLast = $YPos;\r
+ }\r
+ }\r
+\r
+ if (isset($Plots[0]))\r
+ {\r
+ $Plots[] = $Plots[0];\r
+ $Plots[] = $Plots[1];\r
+\r
+ $this->Layers[0] = imagecreatetruecolor($LayerWidth,$LayerHeight);\r
+ $C_White = $this->AllocateColor($this->Layers[0],255,255,255);\r
+ imagefilledrectangle($this->Layers[0],0,0,$LayerWidth,$LayerHeight,$C_White);\r
+ imagecolortransparent($this->Layers[0],$C_White);\r
+\r
+ $C_Graph = $this->AllocateColor($this->Layers[0],$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"]);\r
+ imagefilledpolygon($this->Layers[0],$Plots,(count($Plots)+1)/2,$C_Graph);\r
+\r
+ imagecopymerge($this->Picture,$this->Layers[0],$this->GArea_X1,$this->GArea_Y1,0,0,$LayerWidth,$LayerHeight,$Alpha);\r
+ imagedestroy($this->Layers[0]);\r
+\r
+ for($i=0;$i<=count($Plots)-4;$i=$i+2)\r
+ $this->drawLine($Plots[$i]+$this->GArea_X1,$Plots[$i+1]+$this->GArea_Y1,$Plots[$i+2]+$this->GArea_X1,$Plots[$i+3]+$this->GArea_Y1,$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"]);\r
+ }\r
+\r
+ $GraphID++;\r
+ }\r
+ }\r
+\r
+ /* This function draw a flat pie chart */\r
+ function drawBasicPieGraph($Data,$DataDescription,$XPos,$YPos,$Radius=100,$DrawLabels=PIE_NOLABEL,$R=255,$G=255,$B=255,$Decimals=0)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawBasicPieGraph",$DataDescription,FALSE);\r
+ $this->validateData("drawBasicPieGraph",$Data);\r
+\r
+ /* Determine pie sum */\r
+ $Series = 0; $PieSum = 0;\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ if ( $ColName != $DataDescription["Position"] )\r
+ {\r
+ $Series++;\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if ( isset($Data[$Key][$ColName]))\r
+ $PieSum = $PieSum + $Data[$Key][$ColName]; $iValues[] = $Data[$Key][$ColName]; $iLabels[] = $Data[$Key][$DataDescription["Position"]];\r
+ }\r
+ }\r
+ }\r
+\r
+ /* Validate serie */\r
+ if ( $Series != 1 )\r
+ RaiseFatal("Pie chart can only accept one serie of data.");\r
+\r
+ $SpliceRatio = 360 / $PieSum;\r
+ $SplicePercent = 100 / $PieSum;\r
+\r
+ /* Calculate all polygons */\r
+ $Angle = 0; $TopPlots = "";\r
+ foreach($iValues as $Key => $Value)\r
+ {\r
+ $TopPlots[$Key][] = $XPos;\r
+ $TopPlots[$Key][] = $YPos;\r
+\r
+ /* Process labels position & size */\r
+ $Caption = "";\r
+ if ( !($DrawLabels == PIE_NOLABEL) )\r
+ {\r
+ $TAngle = $Angle+($Value*$SpliceRatio/2);\r
+ if ($DrawLabels == PIE_PERCENTAGE)\r
+ $Caption = (round($Value * pow(10,$Decimals) * $SplicePercent)/pow(10,$Decimals))."%";\r
+ elseif ($DrawLabels == PIE_LABELS)\r
+ $Caption = $iLabels[$Key];\r
+ elseif ($DrawLabels == PIE_PERCENTAGE_LABEL)\r
+ $Caption = $iLabels[$Key]."\r\n".(round($Value * pow(10,$Decimals) * $SplicePercent)/pow(10,$Decimals))."%";\r
+ elseif ($DrawLabels == PIE_PERCENTAGE_LABEL)\r
+ $Caption = $iLabels[$Key]."\r\n".(round($Value * pow(10,$Decimals) * $SplicePercent)/pow(10,$Decimals))."%";\r
+\r
+ $Position = imageftbbox($this->FontSize,0,$this->FontName,$Caption);\r
+ $TextWidth = $Position[2]-$Position[0];\r
+ $TextHeight = abs($Position[1])+abs($Position[3]);\r
+\r
+ $TX = cos(($TAngle) * 3.1418 / 180 ) * ($Radius+10) + $XPos;\r
+\r
+ if ( $TAngle > 0 && $TAngle < 180 )\r
+ $TY = sin(($TAngle) * 3.1418 / 180 ) * ($Radius+10) + $YPos + 4;\r
+ else\r
+ $TY = sin(($TAngle) * 3.1418 / 180 ) * ($Radius+4) + $YPos - ($TextHeight/2);\r
+\r
+ if ( $TAngle > 90 && $TAngle < 270 )\r
+ $TX = $TX - $TextWidth;\r
+\r
+ $C_TextColor = $this->AllocateColor($this->Picture,70,70,70);\r
+ imagettftext($this->Picture,$this->FontSize,0,$TX,$TY,$C_TextColor,$this->FontName,$Caption);\r
+ }\r
+\r
+ /* Process pie slices */\r
+ for($iAngle=$Angle;$iAngle<=$Angle+$Value*$SpliceRatio;$iAngle=$iAngle+.5)\r
+ {\r
+ $TopX = cos($iAngle * 3.1418 / 180 ) * $Radius + $XPos;\r
+ $TopY = sin($iAngle * 3.1418 / 180 ) * $Radius + $YPos;\r
+\r
+ $TopPlots[$Key][] = $TopX; \r
+ $TopPlots[$Key][] = $TopY;\r
+ }\r
+\r
+ $TopPlots[$Key][] = $XPos;\r
+ $TopPlots[$Key][] = $YPos;\r
+\r
+ $Angle = $iAngle;\r
+ }\r
+ $PolyPlots = $TopPlots;\r
+\r
+ /* Set array values type to float --- PHP Bug with imagefilledpolygon casting to integer */\r
+ foreach ($TopPlots as $Key => $Value)\r
+ { foreach ($TopPlots[$Key] as $Key2 => $Value2) { settype($TopPlots[$Key][$Key2],"float"); } }\r
+\r
+ /* Draw Top polygons */\r
+ foreach ($PolyPlots as $Key => $Value)\r
+ { \r
+ $C_GraphLo = $this->AllocateColor($this->Picture,$this->Palette[$Key]["R"],$this->Palette[$Key]["G"],$this->Palette[$Key]["B"]);\r
+ imagefilledpolygon($this->Picture,$PolyPlots[$Key],(count($PolyPlots[$Key])+1)/2,$C_GraphLo);\r
+ }\r
+\r
+ $this->drawCircle($XPos-.5,$YPos-.5,$Radius,$R,$G,$B);\r
+ $this->drawCircle($XPos-.5,$YPos-.5,$Radius+.5,$R,$G,$B);\r
+\r
+ /* Draw Top polygons */\r
+ foreach ($TopPlots as $Key => $Value)\r
+ { \r
+ for($j=0;$j<=count($TopPlots[$Key])-4;$j=$j+2)\r
+ $this->drawLine($TopPlots[$Key][$j],$TopPlots[$Key][$j+1],$TopPlots[$Key][$j+2],$TopPlots[$Key][$j+3],$R,$G,$B);\r
+ }\r
+ }\r
+\r
+ function drawFlatPieGraphWithShadow($Data,$DataDescription,$XPos,$YPos,$Radius=100,$DrawLabels=PIE_NOLABEL,$SpliceDistance=0,$Decimals=0)\r
+ {\r
+ $this->drawFlatPieGraph($Data,$DataDescription,$XPos+$this->ShadowXDistance,$YPos+$this->ShadowYDistance,$Radius,PIE_NOLABEL,$SpliceDistance,$Decimals,TRUE);\r
+ $this->drawFlatPieGraph($Data,$DataDescription,$XPos,$YPos,$Radius,$DrawLabels,$SpliceDistance,$Decimals,FALSE);\r
+ }\r
+\r
+ /* This function draw a flat pie chart */\r
+ function drawFlatPieGraph($Data,$DataDescription,$XPos,$YPos,$Radius=100,$DrawLabels=PIE_NOLABEL,$SpliceDistance=0,$Decimals=0,$AllBlack=FALSE)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawFlatPieGraph",$DataDescription,FALSE);\r
+ $this->validateData("drawFlatPieGraph",$Data);\r
+\r
+ $ShadowStatus = $this->ShadowActive ; $this->ShadowActive = FALSE;\r
+\r
+ /* Determine pie sum */\r
+ $Series = 0; $PieSum = 0;\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ if ( $ColName != $DataDescription["Position"] )\r
+ {\r
+ $Series++;\r
+ foreach ( $Data as $Key => $Values )\r
+ {\r
+ if ( isset($Data[$Key][$ColName]))\r
+ $PieSum = $PieSum + $Data[$Key][$ColName]; $iValues[] = $Data[$Key][$ColName]; $iLabels[] = $Data[$Key][$DataDescription["Position"]];\r
+ }\r
+ }\r
+ }\r
+\r
+ /* Validate serie */\r
+ if ( $Series != 1 )\r
+ {\r
+ RaiseFatal("Pie chart can only accept one serie of data.");\r
+ return(0);\r
+ }\r
+\r
+ $SpliceRatio = 360 / $PieSum;\r
+ $SplicePercent = 100 / $PieSum;\r
+\r
+ /* Calculate all polygons */\r
+ $Angle = 0; $TopPlots = "";\r
+ foreach($iValues as $Key => $Value)\r
+ {\r
+ $XOffset = cos(($Angle+($Value/2*$SpliceRatio)) * 3.1418 / 180 ) * $SpliceDistance;\r
+ $YOffset = sin(($Angle+($Value/2*$SpliceRatio)) * 3.1418 / 180 ) * $SpliceDistance;\r
+\r
+ $TopPlots[$Key][] = round($XPos + $XOffset);\r
+ $TopPlots[$Key][] = round($YPos + $YOffset);\r
+\r
+ if ( $AllBlack )\r
+ { $Rc = $this->ShadowRColor; $Gc = $this->ShadowGColor; $Bc = $this->ShadowBColor; }\r
+ else\r
+ { $Rc = $this->Palette[$Key]["R"]; $Gc = $this->Palette[$Key]["G"]; $Bc = $this->Palette[$Key]["B"]; }\r
+\r
+ $XLineLast = ""; $YLineLast = "";\r
+\r
+ /* Process labels position & size */\r
+ $Caption = "";\r
+ if ( !($DrawLabels == PIE_NOLABEL) )\r
+ {\r
+ $TAngle = $Angle+($Value*$SpliceRatio/2);\r
+ if ($DrawLabels == PIE_PERCENTAGE)\r
+ $Caption = (round($Value * pow(10,$Decimals) * $SplicePercent)/pow(10,$Decimals))."%";\r
+ elseif ($DrawLabels == PIE_LABELS)\r
+ $Caption = $iLabels[$Key];\r
+ elseif ($DrawLabels == PIE_PERCENTAGE_LABEL)\r
+ $Caption = $iLabels[$Key]."\r\n".(round($Value * pow(10,$Decimals) * $SplicePercent)/pow(10,$Decimals))."%";\r
+ elseif ($DrawLabels == PIE_PERCENTAGE_LABEL)\r
+ $Caption = $iLabels[$Key]."\r\n".(round($Value * pow(10,$Decimals) * $SplicePercent)/pow(10,$Decimals))."%";\r
+\r
+ $Position = imageftbbox($this->FontSize,0,$this->FontName,$Caption);\r
+ $TextWidth = $Position[2]-$Position[0];\r
+ $TextHeight = abs($Position[1])+abs($Position[3]);\r
+\r
+ $TX = cos(($TAngle) * 3.1418 / 180 ) * ($Radius+10+$SpliceDistance) + $XPos;\r
+\r
+ if ( $TAngle > 0 && $TAngle < 180 )\r
+ $TY = sin(($TAngle) * 3.1418 / 180 ) * ($Radius+10+$SpliceDistance) + $YPos + 4;\r
+ else\r
+ $TY = sin(($TAngle) * 3.1418 / 180 ) * ($Radius+$SpliceDistance+4) + $YPos - ($TextHeight/2);\r
+\r
+ if ( $TAngle > 90 && $TAngle < 270 )\r
+ $TX = $TX - $TextWidth;\r
+\r
+ $C_TextColor = $this->AllocateColor($this->Picture,70,70,70);\r
+ imagettftext($this->Picture,$this->FontSize,0,$TX,$TY,$C_TextColor,$this->FontName,$Caption);\r
+ }\r
+\r
+ /* Process pie slices */\r
+ if ( !$AllBlack )\r
+ $LineColor = $this->AllocateColor($this->Picture,$Rc,$Gc,$Bc);\r
+ else\r
+ $LineColor = $this->AllocateColor($this->Picture,$Rc,$Gc,$Bc);\r
+\r
+ $XLineLast = ""; $YLineLast = "";\r
+ for($iAngle=$Angle;$iAngle<=$Angle+$Value*$SpliceRatio;$iAngle=$iAngle+.5)\r
+ {\r
+ $PosX = cos($iAngle * 3.1418 / 180 ) * $Radius + $XPos + $XOffset;\r
+ $PosY = sin($iAngle * 3.1418 / 180 ) * $Radius + $YPos + $YOffset;\r
+\r
+ $TopPlots[$Key][] = round($PosX); $TopPlots[$Key][] = round($PosY);\r
+\r
+ if ( $iAngle == $Angle || $iAngle == $Angle+$Value*$SpliceRatio || $iAngle +.5 > $Angle+$Value*$SpliceRatio)\r
+ $this->drawLine($XPos+$XOffset,$YPos+$YOffset,$PosX,$PosY,$Rc,$Gc,$Bc);\r
+\r
+ if ( $XLineLast != "" )\r
+ $this->drawLine($XLineLast,$YLineLast,$PosX,$PosY,$Rc,$Gc,$Bc);\r
+\r
+ $XLineLast = $PosX; $YLineLast = $PosY;\r
+ }\r
+\r
+ $TopPlots[$Key][] = round($XPos + $XOffset); $TopPlots[$Key][] = round($YPos + $YOffset);\r
+\r
+ $Angle = $iAngle;\r
+ }\r
+ $PolyPlots = $TopPlots;\r
+\r
+ /* Draw Top polygons */\r
+ foreach ($PolyPlots as $Key => $Value)\r
+ { \r
+ if ( !$AllBlack )\r
+ $C_GraphLo = $this->AllocateColor($this->Picture,$this->Palette[$Key]["R"],$this->Palette[$Key]["G"],$this->Palette[$Key]["B"]);\r
+ else\r
+ $C_GraphLo = $this->AllocateColor($this->Picture,$this->ShadowRColor,$this->ShadowGColor,$this->ShadowBColor);\r
+\r
+ imagefilledpolygon($this->Picture,$PolyPlots[$Key],(count($PolyPlots[$Key])+1)/2,$C_GraphLo);\r
+ }\r
+ $this->ShadowActive = $ShadowStatus;\r
+ }\r
+\r
+ /* This function draw a pseudo-3D pie chart */\r
+ function drawPieGraph($Data,$DataDescription,$XPos,$YPos,$Radius=100,$DrawLabels=PIE_NOLABEL,$EnhanceColors=TRUE,$Skew=60,$SpliceHeight=20,$SpliceDistance=0,$Decimals=0)\r
+ {\r
+ /* Validate the Data and DataDescription array */\r
+ $this->validateDataDescription("drawPieGraph",$DataDescription,FALSE);\r
+ $this->validateData("drawPieGraph",$Data);\r
+\r
+ /* Determine pie sum */\r
+ $Series = 0; $PieSum = 0; $rPieSum = 0;\r
+ foreach ( $DataDescription["Values"] as $Key2 => $ColName )\r
+ {\r
+ if ( $ColName != $DataDescription["Position"] )\r
+ {\r
+ $Series++;\r
+ foreach ( $Data as $Key => $Values )\r
+ if ( isset($Data[$Key][$ColName]))\r
+ {\r
+ if ( $Data[$Key][$ColName] == 0 )\r
+ { $iValues[] = 0; $rValues[] = 0; $iLabels[] = $Data[$Key][$DataDescription["Position"]]; }\r
+ // Removed : $PieSum++; $rValues[] = 1;\r
+ else\r
+ { $PieSum += $Data[$Key][$ColName]; $iValues[] = $Data[$Key][$ColName]; $iLabels[] = $Data[$Key][$DataDescription["Position"]]; $rValues[] = $Data[$Key][$ColName]; $rPieSum += $Data[$Key][$ColName];}\r
+ }\r
+ }\r
+ }\r
+\r
+ /* Validate serie */\r
+ if ( $Series != 1 )\r
+ RaiseFatal("Pie chart can only accept one serie of data.");\r
+\r
+ $SpliceDistanceRatio = $SpliceDistance;\r
+ $SkewHeight = ($Radius * $Skew) / 100;\r
+ $SpliceRatio = (360 - $SpliceDistanceRatio * count($iValues) ) / $PieSum;\r
+ $SplicePercent = 100 / $PieSum;\r
+ $rSplicePercent = 100 / $rPieSum;\r
+\r
+ /* Calculate all polygons */\r
+ $Angle = 0; $CDev = 5;\r
+ $TopPlots = ""; $BotPlots = "";\r
+ $aTopPlots = ""; $aBotPlots = "";\r
+ foreach($iValues as $Key => $Value)\r
+ {\r
+ $XCenterPos = cos(($Angle-$CDev+($Value*$SpliceRatio+$SpliceDistanceRatio)/2) * 3.1418 / 180 ) * $SpliceDistance + $XPos;\r
+ $YCenterPos = sin(($Angle-$CDev+($Value*$SpliceRatio+$SpliceDistanceRatio)/2) * 3.1418 / 180 ) * $SpliceDistance + $YPos;\r
+ $XCenterPos2 = cos(($Angle+$CDev+($Value*$SpliceRatio+$SpliceDistanceRatio)/2) * 3.1418 / 180 ) * $SpliceDistance + $XPos;\r
+ $YCenterPos2 = sin(($Angle+$CDev+($Value*$SpliceRatio+$SpliceDistanceRatio)/2) * 3.1418 / 180 ) * $SpliceDistance + $YPos;\r
+\r
+ $TopPlots[$Key][] = round($XCenterPos); $BotPlots[$Key][] = round($XCenterPos);\r
+ $TopPlots[$Key][] = round($YCenterPos); $BotPlots[$Key][] = round($YCenterPos + $SpliceHeight);\r
+ $aTopPlots[$Key][] = $XCenterPos; $aBotPlots[$Key][] = $XCenterPos;\r
+ $aTopPlots[$Key][] = $YCenterPos; $aBotPlots[$Key][] = $YCenterPos + $SpliceHeight;\r
+\r
+ /* Process labels position & size */\r
+ $Caption = "";\r
+ if ( !($DrawLabels == PIE_NOLABEL) )\r
+ {\r
+ $TAngle = $Angle+($Value*$SpliceRatio/2);\r
+ if ($DrawLabels == PIE_PERCENTAGE)\r
+ $Caption = (round($rValues[$Key] * pow(10,$Decimals) * $rSplicePercent)/pow(10,$Decimals))."%";\r
+ elseif ($DrawLabels == PIE_LABELS)\r
+ $Caption = $iLabels[$Key];\r
+ elseif ($DrawLabels == PIE_PERCENTAGE_LABEL)\r
+ $Caption = $iLabels[$Key]."\r\n".(round($Value * pow(10,$Decimals) * $SplicePercent)/pow(10,$Decimals))."%";\r
+\r
+ $Position = imageftbbox($this->FontSize,0,$this->FontName,$Caption);\r
+ $TextWidth = $Position[2]-$Position[0];\r
+ $TextHeight = abs($Position[1])+abs($Position[3]);\r
+\r
+ $TX = cos(($TAngle) * 3.1418 / 180 ) * ($Radius + 10)+ $XPos;\r
+\r
+ if ( $TAngle > 0 && $TAngle < 180 )\r
+ $TY = sin(($TAngle) * 3.1418 / 180 ) * ($SkewHeight + 10) + $YPos + $SpliceHeight + 4;\r
+ else\r
+ $TY = sin(($TAngle) * 3.1418 / 180 ) * ($SkewHeight + 4) + $YPos - ($TextHeight/2);\r
+\r
+ if ( $TAngle > 90 && $TAngle < 270 )\r
+ $TX = $TX - $TextWidth;\r
+\r
+ $C_TextColor = $this->AllocateColor($this->Picture,70,70,70);\r
+ imagettftext($this->Picture,$this->FontSize,0,$TX,$TY,$C_TextColor,$this->FontName,$Caption);\r
+ }\r
+\r
+ /* Process pie slices */\r
+ for($iAngle=$Angle;$iAngle<=$Angle+$Value*$SpliceRatio;$iAngle=$iAngle+.5)\r
+ {\r
+ $TopX = cos($iAngle * 3.1418 / 180 ) * $Radius + $XPos;\r
+ $TopY = sin($iAngle * 3.1418 / 180 ) * $SkewHeight + $YPos;\r
+\r
+ $TopPlots[$Key][] = round($TopX); $BotPlots[$Key][] = round($TopX);\r
+ $TopPlots[$Key][] = round($TopY); $BotPlots[$Key][] = round($TopY + $SpliceHeight);\r
+ $aTopPlots[$Key][] = $TopX; $aBotPlots[$Key][] = $TopX;\r
+ $aTopPlots[$Key][] = $TopY; $aBotPlots[$Key][] = $TopY + $SpliceHeight;\r
+ }\r
+\r
+ $TopPlots[$Key][] = round($XCenterPos2); $BotPlots[$Key][] = round($XCenterPos2);\r
+ $TopPlots[$Key][] = round($YCenterPos2); $BotPlots[$Key][] = round($YCenterPos2 + $SpliceHeight);\r
+ $aTopPlots[$Key][] = $XCenterPos2; $aBotPlots[$Key][] = $XCenterPos2;\r
+ $aTopPlots[$Key][] = $YCenterPos2; $aBotPlots[$Key][] = $YCenterPos2 + $SpliceHeight;\r
+\r
+ $Angle = $iAngle + $SpliceDistanceRatio;\r
+ }\r
+\r
+ /* Draw Bottom polygons */\r
+ foreach($iValues as $Key => $Value)\r
+ {\r
+ $C_GraphLo = $this->AllocateColor($this->Picture,$this->Palette[$Key]["R"],$this->Palette[$Key]["G"],$this->Palette[$Key]["B"],-20);\r
+ imagefilledpolygon($this->Picture,$BotPlots[$Key],(count($BotPlots[$Key])+1)/2,$C_GraphLo);\r
+\r
+ if ( $EnhanceColors ) { $En = -10; } else { $En = 0; }\r
+ \r
+ for($j=0;$j<=count($aBotPlots[$Key])-4;$j=$j+2)\r
+ $this->drawLine($aBotPlots[$Key][$j],$aBotPlots[$Key][$j+1],$aBotPlots[$Key][$j+2],$aBotPlots[$Key][$j+3],$this->Palette[$Key]["R"]+$En,$this->Palette[$Key]["G"]+$En,$this->Palette[$Key]["B"]+$En);\r
+ }\r
+\r
+ /* Draw pie layers */\r
+ if ( $EnhanceColors ) { $ColorRatio = 30 / $SpliceHeight; } else { $ColorRatio = 25 / $SpliceHeight; }\r
+ for($i=$SpliceHeight-1;$i>=1;$i--)\r
+ {\r
+ foreach($iValues as $Key => $Value)\r
+ {\r
+ $C_GraphLo = $this->AllocateColor($this->Picture,$this->Palette[$Key]["R"],$this->Palette[$Key]["G"],$this->Palette[$Key]["B"],-10);\r
+ $Plots = ""; $Plot = 0;\r
+ foreach($TopPlots[$Key] as $Key2 => $Value2)\r
+ {\r
+ $Plot++;\r
+ if ( $Plot % 2 == 1 )\r
+ $Plots[] = $Value2;\r
+ else\r
+ $Plots[] = $Value2+$i;\r
+ }\r
+ imagefilledpolygon($this->Picture,$Plots,(count($Plots)+1)/2,$C_GraphLo);\r
+\r
+ $Index = count($Plots);\r
+ if ($EnhanceColors ) {$ColorFactor = -20 + ($SpliceHeight - $i) * $ColorRatio; } else { $ColorFactor = 0; }\r
+\r
+ $this->drawAntialiasPixel($Plots[0],$Plots[1],$this->Palette[$Key]["R"]+$ColorFactor,$this->Palette[$Key]["G"]+$ColorFactor,$this->Palette[$Key]["B"]+$ColorFactor);\r
+ $this->drawAntialiasPixel($Plots[2],$Plots[3],$this->Palette[$Key]["R"]+$ColorFactor,$this->Palette[$Key]["G"]+$ColorFactor,$this->Palette[$Key]["B"]+$ColorFactor);\r
+ $this->drawAntialiasPixel($Plots[$Index-4],$Plots[$Index-3],$this->Palette[$Key]["R"]+$ColorFactor,$this->Palette[$Key]["G"]+$ColorFactor,$this->Palette[$Key]["B"]+$ColorFactor);\r
+ }\r
+ }\r
+\r
+ /* Draw Top polygons */\r
+ for($Key=count($iValues)-1;$Key>=0;$Key--)\r
+ { \r
+ $C_GraphLo = $this->AllocateColor($this->Picture,$this->Palette[$Key]["R"],$this->Palette[$Key]["G"],$this->Palette[$Key]["B"]);\r
+ imagefilledpolygon($this->Picture,$TopPlots[$Key],(count($TopPlots[$Key])+1)/2,$C_GraphLo);\r
+\r
+ if ( $EnhanceColors ) { $En = 10; } else { $En = 0; }\r
+ for($j=0;$j<=count($aTopPlots[$Key])-4;$j=$j+2)\r
+ $this->drawLine($aTopPlots[$Key][$j],$aTopPlots[$Key][$j+1],$aTopPlots[$Key][$j+2],$aTopPlots[$Key][$j+3],$this->Palette[$Key]["R"]+$En,$this->Palette[$Key]["G"]+$En,$this->Palette[$Key]["B"]+$En);\r
+ }\r
+ }\r
+\r
+ /* This function can be used to set the background color */\r
+ function drawBackground($R,$G,$B)\r
+ {\r
+ if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }\r
+ if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }\r
+ if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }\r
+\r
+ $C_Background = $this->AllocateColor($this->Picture,$R,$G,$B);\r
+ imagefilledrectangle($this->Picture,0,0,$this->XSize,$this->YSize,$C_Background);\r
+ }\r
+\r
+ /* This function can be used to set the background color */\r
+ function drawGraphAreaGradient($R,$G,$B,$Decay,$Target=TARGET_GRAPHAREA)\r
+ {\r
+ if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }\r
+ if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }\r
+ if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }\r
+\r
+ if ( $Target == TARGET_GRAPHAREA ) { $X1 = $this->GArea_X1+1; $X2 = $this->GArea_X2-1; $Y1 = $this->GArea_Y1+1; $Y2 = $this->GArea_Y2; }\r
+ if ( $Target == TARGET_BACKGROUND ) { $X1 = 0; $X2 = $this->XSize; $Y1 = 0; $Y2 = $this->YSize; }\r
+\r
+ /* Positive gradient */\r
+ if ( $Decay > 0 )\r
+ {\r
+ $YStep = ($Y2 - $Y1 - 2) / $Decay;\r
+ for($i=0;$i<=$Decay;$i++)\r
+ {\r
+ $R-=1;$G-=1;$B-=1;\r
+ $Yi1 = $Y1 + ( $i * $YStep );\r
+ $Yi2 = ceil( $Yi1 + ( $i * $YStep ) + $YStep );\r
+ if ( $Yi2 >= $Yi2 ) { $Yi2 = $Y2-1; }\r
+\r
+ $C_Background = $this->AllocateColor($this->Picture,$R,$G,$B);\r
+ imagefilledrectangle($this->Picture,$X1,$Yi1,$X2,$Yi2,$C_Background);\r
+ }\r
+ }\r
+\r
+ /* Negative gradient */\r
+ if ( $Decay < 0 )\r
+ {\r
+ $YStep = ($Y2 - $Y1 - 2) / -$Decay;\r
+ $Yi1 = $Y1; $Yi2 = $Y1+$YStep;\r
+ for($i=-$Decay;$i>=0;$i--)\r
+ {\r
+ $R+=1;$G+=1;$B+=1;\r
+ $C_Background = $this->AllocateColor($this->Picture,$R,$G,$B);\r
+ imagefilledrectangle($this->Picture,$X1,$Yi1,$X2,$Yi2,$C_Background);\r
+\r
+ $Yi1+= $YStep;\r
+ $Yi2+= $YStep;\r
+ if ( $Yi2 >= $Yi2 ) { $Yi2 = $Y2-1; }\r
+ }\r
+ }\r
+ }\r
+\r
+ /* This function create a rectangle with antialias */\r
+ function drawRectangle($X1,$Y1,$X2,$Y2,$R,$G,$B)\r
+ {\r
+ if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }\r
+ if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }\r
+ if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }\r
+\r
+ $C_Rectangle = $this->AllocateColor($this->Picture,$R,$G,$B);\r
+\r
+ $X1=$X1-.2;$Y1=$Y1-.2;\r
+ $X2=$X2+.2;$Y2=$Y2+.2;\r
+ $this->drawLine($X1,$Y1,$X2,$Y1,$R,$G,$B);\r
+ $this->drawLine($X2,$Y1,$X2,$Y2,$R,$G,$B);\r
+ $this->drawLine($X2,$Y2,$X1,$Y2,$R,$G,$B);\r
+ $this->drawLine($X1,$Y2,$X1,$Y1,$R,$G,$B);\r
+ }\r
+\r
+ /* This function create a filled rectangle with antialias */\r
+ function drawFilledRectangle($X1,$Y1,$X2,$Y2,$R,$G,$B,$DrawBorder=TRUE,$Alpha=100,$NoFallBack=FALSE)\r
+ {\r
+ if ( $X2 < $X1 ) { list($X1, $X2) = array($X2, $X1); }\r
+ if ( $Y2 < $Y1 ) { list($Y1, $Y2) = array($Y2, $Y1); }\r
+\r
+ if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }\r
+ if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }\r
+ if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }\r
+\r
+ if ( $Alpha == 100 )\r
+ {\r
+ /* Process shadows */\r
+ if ( $this->ShadowActive && !$NoFallBack )\r
+ {\r
+ $this->drawFilledRectangle($X1+$this->ShadowXDistance,$Y1+$this->ShadowYDistance,$X2+$this->ShadowXDistance,$Y2+$this->ShadowYDistance,$this->ShadowRColor,$this->ShadowGColor,$this->ShadowBColor,FALSE,$this->ShadowAlpha,TRUE);\r
+ if ( $this->ShadowBlur != 0 )\r
+ {\r
+ $AlphaDecay = ($this->ShadowAlpha / $this->ShadowBlur);\r
+\r
+ for($i=1; $i<=$this->ShadowBlur; $i++)\r
+ $this->drawFilledRectangle($X1+$this->ShadowXDistance-$i/2,$Y1+$this->ShadowYDistance-$i/2,$X2+$this->ShadowXDistance-$i/2,$Y2+$this->ShadowYDistance-$i/2,$this->ShadowRColor,$this->ShadowGColor,$this->ShadowBColor,FALSE,$this->ShadowAlpha-$AlphaDecay*$i,TRUE);\r
+ for($i=1; $i<=$this->ShadowBlur; $i++)\r
+ $this->drawFilledRectangle($X1+$this->ShadowXDistance+$i/2,$Y1+$this->ShadowYDistance+$i/2,$X2+$this->ShadowXDistance+$i/2,$Y2+$this->ShadowYDistance+$i/2,$this->ShadowRColor,$this->ShadowGColor,$this->ShadowBColor,FALSE,$this->ShadowAlpha-$AlphaDecay*$i,TRUE);\r
+ }\r
+ }\r
+\r
+ $C_Rectangle = $this->AllocateColor($this->Picture,$R,$G,$B);\r
+ imagefilledrectangle($this->Picture,round($X1),round($Y1),round($X2),round($Y2),$C_Rectangle);\r
+ }\r
+ else\r
+ {\r
+ $LayerWidth = abs($X2-$X1)+2;\r
+ $LayerHeight = abs($Y2-$Y1)+2;\r
+\r
+ $this->Layers[0] = imagecreatetruecolor($LayerWidth,$LayerHeight);\r
+ $C_White = $this->AllocateColor($this->Layers[0],255,255,255);\r
+ imagefilledrectangle($this->Layers[0],0,0,$LayerWidth,$LayerHeight,$C_White);\r
+ imagecolortransparent($this->Layers[0],$C_White);\r
+\r
+ $C_Rectangle = $this->AllocateColor($this->Layers[0],$R,$G,$B);\r
+ imagefilledrectangle($this->Layers[0],round(1),round(1),round($LayerWidth-1),round($LayerHeight-1),$C_Rectangle);\r
+\r
+ imagecopymerge($this->Picture,$this->Layers[0],round(min($X1,$X2)-1),round(min($Y1,$Y2)-1),0,0,$LayerWidth,$LayerHeight,$Alpha);\r
+ imagedestroy($this->Layers[0]);\r
+ }\r
+\r
+ if ( $DrawBorder )\r
+ {\r
+ $ShadowSettings = $this->ShadowActive; $this->ShadowActive = FALSE;\r
+ $this->drawRectangle($X1,$Y1,$X2,$Y2,$R,$G,$B);\r
+ $this->ShadowActive = $ShadowSettings;\r
+ }\r
+ }\r
+\r
+ /* This function create a rectangle with rounded corners and antialias */\r
+ function drawRoundedRectangle($X1,$Y1,$X2,$Y2,$Radius,$R,$G,$B)\r
+ {\r
+ if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }\r
+ if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }\r
+ if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }\r
+\r
+ $C_Rectangle = $this->AllocateColor($this->Picture,$R,$G,$B);\r
+\r
+ $Step = 90 / ((3.1418 * $Radius)/2);\r
+\r
+ for($i=0;$i<=90;$i=$i+$Step)\r
+ {\r
+ $X = cos(($i+180)*3.1418/180) * $Radius + $X1 + $Radius;\r
+ $Y = sin(($i+180)*3.1418/180) * $Radius + $Y1 + $Radius;\r
+ $this->drawAntialiasPixel($X,$Y,$R,$G,$B);\r
+\r
+ $X = cos(($i-90)*3.1418/180) * $Radius + $X2 - $Radius;\r
+ $Y = sin(($i-90)*3.1418/180) * $Radius + $Y1 + $Radius;\r
+ $this->drawAntialiasPixel($X,$Y,$R,$G,$B);\r
+\r
+ $X = cos(($i)*3.1418/180) * $Radius + $X2 - $Radius;\r
+ $Y = sin(($i)*3.1418/180) * $Radius + $Y2 - $Radius;\r
+ $this->drawAntialiasPixel($X,$Y,$R,$G,$B);\r
+\r
+ $X = cos(($i+90)*3.1418/180) * $Radius + $X1 + $Radius;\r
+ $Y = sin(($i+90)*3.1418/180) * $Radius + $Y2 - $Radius;\r
+ $this->drawAntialiasPixel($X,$Y,$R,$G,$B);\r
+ }\r
+\r
+ $X1=$X1-.2;$Y1=$Y1-.2;\r
+ $X2=$X2+.2;$Y2=$Y2+.2;\r
+ $this->drawLine($X1+$Radius,$Y1,$X2-$Radius,$Y1,$R,$G,$B);\r
+ $this->drawLine($X2,$Y1+$Radius,$X2,$Y2-$Radius,$R,$G,$B);\r
+ $this->drawLine($X2-$Radius,$Y2,$X1+$Radius,$Y2,$R,$G,$B);\r
+ $this->drawLine($X1,$Y2-$Radius,$X1,$Y1+$Radius,$R,$G,$B);\r
+ }\r
+\r
+ /* This function create a filled rectangle with rounded corners and antialias */\r
+ function drawFilledRoundedRectangle($X1,$Y1,$X2,$Y2,$Radius,$R,$G,$B)\r
+ {\r
+ if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }\r
+ if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }\r
+ if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }\r
+\r
+ $C_Rectangle = $this->AllocateColor($this->Picture,$R,$G,$B);\r
+\r
+ $Step = 90 / ((3.1418 * $Radius)/2);\r
+\r
+ for($i=0;$i<=90;$i=$i+$Step)\r
+ {\r
+ $Xi1 = cos(($i+180)*3.1418/180) * $Radius + $X1 + $Radius;\r
+ $Yi1 = sin(($i+180)*3.1418/180) * $Radius + $Y1 + $Radius;\r
+\r
+ $Xi2 = cos(($i-90)*3.1418/180) * $Radius + $X2 - $Radius;\r
+ $Yi2 = sin(($i-90)*3.1418/180) * $Radius + $Y1 + $Radius;\r
+\r
+ $Xi3 = cos(($i)*3.1418/180) * $Radius + $X2 - $Radius;\r
+ $Yi3 = sin(($i)*3.1418/180) * $Radius + $Y2 - $Radius;\r
+\r
+ $Xi4 = cos(($i+90)*3.1418/180) * $Radius + $X1 + $Radius;\r
+ $Yi4 = sin(($i+90)*3.1418/180) * $Radius + $Y2 - $Radius;\r
+\r
+ imageline($this->Picture,$Xi1,$Yi1,$X1+$Radius,$Yi1,$C_Rectangle);\r
+ imageline($this->Picture,$X2-$Radius,$Yi2,$Xi2,$Yi2,$C_Rectangle);\r
+ imageline($this->Picture,$X2-$Radius,$Yi3,$Xi3,$Yi3,$C_Rectangle);\r
+ imageline($this->Picture,$Xi4,$Yi4,$X1+$Radius,$Yi4,$C_Rectangle);\r
+\r
+ $this->drawAntialiasPixel($Xi1,$Yi1,$R,$G,$B);\r
+ $this->drawAntialiasPixel($Xi2,$Yi2,$R,$G,$B);\r
+ $this->drawAntialiasPixel($Xi3,$Yi3,$R,$G,$B);\r
+ $this->drawAntialiasPixel($Xi4,$Yi4,$R,$G,$B);\r
+ }\r
+\r
+ imagefilledrectangle($this->Picture,$X1,$Y1+$Radius,$X2,$Y2-$Radius,$C_Rectangle);\r
+ imagefilledrectangle($this->Picture,$X1+$Radius,$Y1,$X2-$Radius,$Y2,$C_Rectangle);\r
+\r
+ $X1=$X1-.2;$Y1=$Y1-.2;\r
+ $X2=$X2+.2;$Y2=$Y2+.2;\r
+ $this->drawLine($X1+$Radius,$Y1,$X2-$Radius,$Y1,$R,$G,$B);\r
+ $this->drawLine($X2,$Y1+$Radius,$X2,$Y2-$Radius,$R,$G,$B);\r
+ $this->drawLine($X2-$Radius,$Y2,$X1+$Radius,$Y2,$R,$G,$B);\r
+ $this->drawLine($X1,$Y2-$Radius,$X1,$Y1+$Radius,$R,$G,$B);\r
+ }\r
+\r
+ /* This function create a circle with antialias */\r
+ function drawCircle($Xc,$Yc,$Height,$R,$G,$B,$Width=0)\r
+ {\r
+ if ( $Width == 0 ) { $Width = $Height; }\r
+ if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }\r
+ if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }\r
+ if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }\r
+\r
+ $C_Circle = $this->AllocateColor($this->Picture,$R,$G,$B);\r
+ $Step = 360 / (2 * 3.1418 * max($Width,$Height));\r
+\r
+ for($i=0;$i<=360;$i=$i+$Step)\r
+ {\r
+ $X = cos($i*3.1418/180) * $Height + $Xc;\r
+ $Y = sin($i*3.1418/180) * $Width + $Yc;\r
+ $this->drawAntialiasPixel($X,$Y,$R,$G,$B);\r
+ }\r
+ }\r
+\r
+ /* This function create a filled circle/ellipse with antialias */\r
+ function drawFilledCircle($Xc,$Yc,$Height,$R,$G,$B,$Width=0)\r
+ {\r
+ if ( $Width == 0 ) { $Width = $Height; }\r
+ if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }\r
+ if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }\r
+ if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }\r
+\r
+ $C_Circle = $this->AllocateColor($this->Picture,$R,$G,$B);\r
+ $Step = 360 / (2 * 3.1418 * max($Width,$Height));\r
+\r
+ for($i=90;$i<=270;$i=$i+$Step)\r
+ {\r
+ $X1 = cos($i*3.1418/180) * $Height + $Xc;\r
+ $Y1 = sin($i*3.1418/180) * $Width + $Yc;\r
+ $X2 = cos((180-$i)*3.1418/180) * $Height + $Xc;\r
+ $Y2 = sin((180-$i)*3.1418/180) * $Width + $Yc;\r
+\r
+ $this->drawAntialiasPixel($X1-1,$Y1-1,$R,$G,$B);\r
+ $this->drawAntialiasPixel($X2-1,$Y2-1,$R,$G,$B);\r
+\r
+ if ( ($Y1-1) > $Yc - max($Width,$Height) )\r
+ imageline($this->Picture,$X1,$Y1-1,$X2-1,$Y2-1,$C_Circle);\r
+ }\r
+ }\r
+\r
+ /* This function will draw a filled ellipse */\r
+ function drawEllipse($Xc,$Yc,$Height,$Width,$R,$G,$B)\r
+ { $this->drawCircle($Xc,$Yc,$Height,$R,$G,$B,$Width); }\r
+\r
+ /* This function will draw an ellipse */\r
+ function drawFilledEllipse($Xc,$Yc,$Height,$Width,$R,$G,$B)\r
+ { $this->drawFilledCircle($Xc,$Yc,$Height,$R,$G,$B,$Width); }\r
+\r
+ /* This function create a line with antialias */\r
+ function drawLine($X1,$Y1,$X2,$Y2,$R,$G,$B,$GraphFunction=FALSE)\r
+ {\r
+ if ( $this->LineDotSize > 1 ) { $this->drawDottedLine($X1,$Y1,$X2,$Y2,$this->LineDotSize,$R,$G,$B,$GraphFunction); return(0); }\r
+ if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }\r
+ if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }\r
+ if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }\r
+\r
+ $Distance = sqrt(($X2-$X1)*($X2-$X1)+($Y2-$Y1)*($Y2-$Y1)); \r
+ if ( $Distance == 0 )\r
+ return(-1);\r
+ $XStep = ($X2-$X1) / $Distance;\r
+ $YStep = ($Y2-$Y1) / $Distance;\r
+\r
+ for($i=0;$i<=$Distance;$i++)\r
+ {\r
+ $X = $i * $XStep + $X1;\r
+ $Y = $i * $YStep + $Y1;\r
+\r
+ if ( ($X >= $this->GArea_X1 && $X <= $this->GArea_X2 && $Y >= $this->GArea_Y1 && $Y <= $this->GArea_Y2) || !$GraphFunction )\r
+ {\r
+ if ( $this->LineWidth == 1 )\r
+ $this->drawAntialiasPixel($X,$Y,$R,$G,$B);\r
+ else\r
+ {\r
+ $StartOffset = -($this->LineWidth/2); $EndOffset = ($this->LineWidth/2);\r
+ for($j=$StartOffset;$j<=$EndOffset;$j++)\r
+ $this->drawAntialiasPixel($X+$j,$Y+$j,$R,$G,$B);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ /* This function create a line with antialias */\r
+ function drawDottedLine($X1,$Y1,$X2,$Y2,$DotSize,$R,$G,$B,$GraphFunction=FALSE)\r
+ {\r
+ if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }\r
+ if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }\r
+ if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }\r
+\r
+ $Distance = sqrt(($X2-$X1)*($X2-$X1)+($Y2-$Y1)*($Y2-$Y1)); \r
+\r
+ $XStep = ($X2-$X1) / $Distance;\r
+ $YStep = ($Y2-$Y1) / $Distance;\r
+\r
+ $DotIndex = 0;\r
+ for($i=0;$i<=$Distance;$i++)\r
+ {\r
+ $X = $i * $XStep + $X1;\r
+ $Y = $i * $YStep + $Y1;\r
+\r
+ if ( $DotIndex <= $DotSize)\r
+ {\r
+ if ( ($X >= $this->GArea_X1 && $X <= $this->GArea_X2 && $Y >= $this->GArea_Y1 && $Y <= $this->GArea_Y2) || !$GraphFunction )\r
+ {\r
+ if ( $this->LineWidth == 1 )\r
+ $this->drawAntialiasPixel($X,$Y,$R,$G,$B);\r
+ else\r
+ {\r
+ $StartOffset = -($this->LineWidth/2); $EndOffset = ($this->LineWidth/2);\r
+ for($j=$StartOffset;$j<=$EndOffset;$j++)\r
+ $this->drawAntialiasPixel($X+$j,$Y+$j,$R,$G,$B);\r
+ }\r
+ }\r
+ }\r
+\r
+ $DotIndex++;\r
+ if ( $DotIndex == $DotSize * 2 )\r
+ $DotIndex = 0; \r
+ }\r
+ }\r
+\r
+ /* Load a PNG file and draw it over the chart */\r
+ function drawFromPNG($FileName,$X,$Y,$Alpha=100)\r
+ { $this->drawFromPicture(1,$FileName,$X,$Y,$Alpha); }\r
+\r
+ /* Load a GIF file and draw it over the chart */\r
+ function drawFromGIF($FileName,$X,$Y,$Alpha=100)\r
+ { $this->drawFromPicture(2,$FileName,$X,$Y,$Alpha); }\r
+\r
+ /* Load a JPEG file and draw it over the chart */\r
+ function drawFromJPG($FileName,$X,$Y,$Alpha=100)\r
+ { $this->drawFromPicture(3,$FileName,$X,$Y,$Alpha); }\r
+\r
+ /* Generic loader function for external pictures */\r
+ function drawFromPicture($PicType,$FileName,$X,$Y,$Alpha=100)\r
+ {\r
+ if ( file_exists($FileName))\r
+ {\r
+ $Infos = getimagesize($FileName);\r
+ $Width = $Infos[0];\r
+ $Height = $Infos[1];\r
+ if ( $PicType == 1 ) { $Raster = imagecreatefrompng($FileName); }\r
+ if ( $PicType == 2 ) { $Raster = imagecreatefromgif($FileName); }\r
+ if ( $PicType == 3 ) { $Raster = imagecreatefromjpeg($FileName); }\r
+\r
+ imagecopymerge($this->Picture,$Raster,$X,$Y,0,0,$Width,$Height,$Alpha);\r
+ imagedestroy($Raster);\r
+ }\r
+ }\r
+\r
+ /* Draw an alpha pixel */\r
+ function drawAlphaPixel($X,$Y,$Alpha,$R,$G,$B)\r
+ {\r
+ if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }\r
+ if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }\r
+ if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }\r
+\r
+ if ( $X < 0 || $Y < 0 || $X >= $this->XSize || $Y >= $this->YSize )\r
+ return(-1);\r
+\r
+ $RGB2 = imagecolorat($this->Picture, $X, $Y);\r
+ $R2 = ($RGB2 >> 16) & 0xFF;\r
+ $G2 = ($RGB2 >> 8) & 0xFF;\r
+ $B2 = $RGB2 & 0xFF;\r
+\r
+ $iAlpha = (100 - $Alpha)/100;\r
+ $Alpha = $Alpha / 100;\r
+\r
+ $Ra = floor($R*$Alpha+$R2*$iAlpha);\r
+ $Ga = floor($G*$Alpha+$G2*$iAlpha);\r
+ $Ba = floor($B*$Alpha+$B2*$iAlpha);\r
+\r
+ $C_Aliased = $this->AllocateColor($this->Picture,$Ra,$Ga,$Ba);\r
+ imagesetpixel($this->Picture,$X,$Y,$C_Aliased);\r
+ }\r
+\r
+ /* Color helper */\r
+ function AllocateColor($Picture,$R,$G,$B,$Factor=0)\r
+ {\r
+ $R = $R + $Factor;\r
+ $G = $G + $Factor;\r
+ $B = $B + $Factor;\r
+ if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }\r
+ if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }\r
+ if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }\r
+\r
+ return(imagecolorallocate($Picture,$R,$G,$B));\r
+ }\r
+\r
+ /* Add a border to the picture */\r
+ function addBorder($Size=3,$R=0,$G=0,$B=0)\r
+ {\r
+ $Width = $this->XSize+2*$Size;\r
+ $Height = $this->YSize+2*$Size;\r
+\r
+ $Resampled = imagecreatetruecolor($Width,$Height);\r
+ $C_Background = $this->AllocateColor($Resampled,$R,$G,$B);\r
+ imagefilledrectangle($Resampled,0,0,$Width,$Height,$C_Background);\r
+\r
+ imagecopy($Resampled,$this->Picture,$Size,$Size,0,0,$this->XSize,$this->YSize);\r
+ imagedestroy($this->Picture);\r
+\r
+ $this->XSize = $Width;\r
+ $this->YSize = $Height;\r
+\r
+ $this->Picture = imagecreatetruecolor($this->XSize,$this->YSize);\r
+ $C_White = $this->AllocateColor($this->Picture,255,255,255);\r
+ imagefilledrectangle($this->Picture,0,0,$this->XSize,$this->YSize,$C_White);\r
+ imagecolortransparent($this->Picture,$C_White);\r
+ imagecopy($this->Picture,$Resampled,0,0,0,0,$this->XSize,$this->YSize);\r
+ }\r
+\r
+ /* Render the current picture to a file */\r
+ function Render($FileName)\r
+ {\r
+ if ( $this->ErrorReporting )\r
+ $this->printErrors($this->ErrorInterface);\r
+\r
+ /* Save image map if requested */\r
+ if ( $this->BuildMap )\r
+ $this->SaveImageMap();\r
+\r
+ imagepng($this->Picture,$FileName);\r
+ }\r
+\r
+ /* Render the current picture to STDOUT */\r
+ function Stroke()\r
+ {\r
+ if ( $this->ErrorReporting )\r
+ $this->printErrors("GD");\r
+\r
+ /* Save image map if requested */\r
+ if ( $this->BuildMap )\r
+ $this->SaveImageMap();\r
+\r
+ header('Content-type: image/png');\r
+ imagepng($this->Picture);\r
+ }\r
+\r
+ /* Private functions for internal processing */\r
+ function drawAntialiasPixel($X,$Y,$R,$G,$B,$Alpha=100,$NoFallBack=FALSE)\r
+ {\r
+ /* Process shadows */\r
+ if ( $this->ShadowActive && !$NoFallBack )\r
+ {\r
+ $this->drawAntialiasPixel($X+$this->ShadowXDistance,$Y+$this->ShadowYDistance,$this->ShadowRColor,$this->ShadowGColor,$this->ShadowBColor,$this->ShadowAlpha,TRUE);\r
+ if ( $this->ShadowBlur != 0 )\r
+ {\r
+ $AlphaDecay = ($this->ShadowAlpha / $this->ShadowBlur);\r
+\r
+ for($i=1; $i<=$this->ShadowBlur; $i++)\r
+ $this->drawAntialiasPixel($X+$this->ShadowXDistance-$i/2,$Y+$this->ShadowYDistance-$i/2,$this->ShadowRColor,$this->ShadowGColor,$this->ShadowBColor,$this->ShadowAlpha-$AlphaDecay*$i,TRUE);\r
+ for($i=1; $i<=$this->ShadowBlur; $i++)\r
+ $this->drawAntialiasPixel($X+$this->ShadowXDistance+$i/2,$Y+$this->ShadowYDistance+$i/2,$this->ShadowRColor,$this->ShadowGColor,$this->ShadowBColor,$this->ShadowAlpha-$AlphaDecay*$i,TRUE);\r
+ }\r
+ }\r
+\r
+ if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }\r
+ if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }\r
+ if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }\r
+\r
+ $Plot = "";\r
+ $Xi = floor($X);\r
+ $Yi = floor($Y);\r
+\r
+ if ( $Xi == $X && $Yi == $Y)\r
+ {\r
+ if ( $Alpha == 100 )\r
+ {\r
+ $C_Aliased = $this->AllocateColor($this->Picture,$R,$G,$B);\r
+ imagesetpixel($this->Picture,$X,$Y,$C_Aliased);\r
+ }\r
+ else\r
+ $this->drawAlphaPixel($X,$Y,$Alpha,$R,$G,$B);\r
+ }\r
+ else\r
+ {\r
+ $Alpha1 = (((1 - ($X - floor($X))) * (1 - ($Y - floor($Y))) * 100) / 100) * $Alpha;\r
+ if ( $Alpha1 > $this->AntialiasQuality ) { $this->drawAlphaPixel($Xi,$Yi,$Alpha1,$R,$G,$B); }\r
+\r
+ $Alpha2 = ((($X - floor($X)) * (1 - ($Y - floor($Y))) * 100) / 100) * $Alpha;\r
+ if ( $Alpha2 > $this->AntialiasQuality ) { $this->drawAlphaPixel($Xi+1,$Yi,$Alpha2,$R,$G,$B); }\r
+\r
+ $Alpha3 = (((1 - ($X - floor($X))) * ($Y - floor($Y)) * 100) / 100) * $Alpha;\r
+ if ( $Alpha3 > $this->AntialiasQuality ) { $this->drawAlphaPixel($Xi,$Yi+1,$Alpha3,$R,$G,$B); }\r
+\r
+ $Alpha4 = ((($X - floor($X)) * ($Y - floor($Y)) * 100) / 100) * $Alpha;\r
+ if ( $Alpha4 > $this->AntialiasQuality ) { $this->drawAlphaPixel($Xi+1,$Yi+1,$Alpha4,$R,$G,$B); }\r
+ }\r
+ }\r
+\r
+ /* Validate data contained in the description array */\r
+ function validateDataDescription($FunctionName,&$DataDescription,$DescriptionRequired=TRUE)\r
+ {\r
+ if (!isset($DataDescription["Position"]))\r
+ {\r
+ $this->Errors[] = "[Warning] ".$FunctionName." - Y Labels are not set.";\r
+ $DataDescription["Position"] = "Name";\r
+ }\r
+\r
+ if ( $DescriptionRequired )\r
+ {\r
+ if (!isset($DataDescription["Description"]))\r
+ {\r
+ $this->Errors[] = "[Warning] ".$FunctionName." - Series descriptions are not set.";\r
+ foreach($DataDescription["Values"] as $key => $Value)\r
+ {\r
+ $DataDescription["Description"][$Value] = $Value;\r
+ }\r
+ }\r
+\r
+ if (count($DataDescription["Description"]) < count($DataDescription["Values"]))\r
+ {\r
+ $this->Errors[] = "[Warning] ".$FunctionName." - Some series descriptions are not set.";\r
+ foreach($DataDescription["Values"] as $key => $Value)\r
+ {\r
+ if ( !isset($DataDescription["Description"][$Value]))\r
+ $DataDescription["Description"][$Value] = $Value;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ /* Validate data contained in the data array */\r
+ function validateData($FunctionName,&$Data)\r
+ {\r
+ $DataSummary = array();\r
+\r
+ foreach($Data as $key => $Values)\r
+ {\r
+ foreach($Values as $key2 => $Value)\r
+ {\r
+ if (!isset($DataSummary[$key2]))\r
+ $DataSummary[$key2] = 1;\r
+ else\r
+ $DataSummary[$key2]++;\r
+ }\r
+ }\r
+\r
+ if ( max($DataSummary) == 0 )\r
+ $this->Errors[] = "[Warning] ".$FunctionName." - No data set.";\r
+\r
+ foreach($DataSummary as $key => $Value)\r
+ {\r
+ if ($Value < max($DataSummary))\r
+ {\r
+ $this->Errors[] = "[Warning] ".$FunctionName." - Missing data in serie ".$key.".";\r
+ }\r
+ }\r
+ }\r
+\r
+ /* Print all error messages on the CLI or graphically */\r
+ function printErrors($Mode="CLI")\r
+ {\r
+ if (count($this->Errors) == 0)\r
+ return(0);\r
+\r
+ if ( $Mode == "CLI" )\r
+ {\r
+ foreach($this->Errors as $key => $Value)\r
+ echo $Value."\r\n";\r
+ }\r
+ elseif ( $Mode == "GD" )\r
+ {\r
+ $this->setLineStyle($Width=1);\r
+ $MaxWidth = 0;\r
+ foreach($this->Errors as $key => $Value)\r
+ {\r
+ $Position = imageftbbox($this->ErrorFontSize,0,$this->ErrorFontName,$Value);\r
+ $TextWidth = $Position[2]-$Position[0];\r
+ if ( $TextWidth > $MaxWidth ) { $MaxWidth = $TextWidth; }\r
+ }\r
+ $this->drawFilledRoundedRectangle($this->XSize-($MaxWidth+20),$this->YSize-(20+(($this->ErrorFontSize+4)*count($this->Errors))),$this->XSize-10,$this->YSize-10,6,233,185,185);\r
+ $this->drawRoundedRectangle($this->XSize-($MaxWidth+20),$this->YSize-(20+(($this->ErrorFontSize+4)*count($this->Errors))),$this->XSize-10,$this->YSize-10,6,193,145,145);\r
+\r
+ $C_TextColor = $this->AllocateColor($this->Picture,133,85,85);\r
+ $YPos = $this->YSize - (18 + (count($this->Errors)-1) * ($this->ErrorFontSize + 4));\r
+ foreach($this->Errors as $key => $Value)\r
+ {\r
+ imagettftext($this->Picture,$this->ErrorFontSize,0,$this->XSize-($MaxWidth+15),$YPos,$C_TextColor,$this->ErrorFontName,$Value);\r
+ $YPos = $YPos + ($this->ErrorFontSize + 4);\r
+ }\r
+ }\r
+ }\r
+\r
+ /* Activate the image map creation process */\r
+ function setImageMap($Mode=TRUE,$GraphID="MyGraph")\r
+ {\r
+ $this->BuildMap = $Mode;\r
+ $this->MapID = $GraphID;\r
+ }\r
+\r
+ /* Add a box into the image map */\r
+ function addToImageMap($X1,$Y1,$X2,$Y2,$SerieName,$Value,$CallerFunction)\r
+ {\r
+ if ( $this->MapFunction == NULL || $this->MapFunction == $CallerFunction )\r
+ {\r
+ $this->ImageMap[] = round($X1).",".round($Y1).",".round($X2).",".round($Y2).",".$SerieName.",".$Value;\r
+ $this->MapFunction = $CallerFunction;\r
+ }\r
+ }\r
+\r
+ /* Load and cleanup the image map from disk */\r
+ function getImageMap($MapName,$Flush=TRUE)\r
+ {\r
+ /* Strip HTML query strings */\r
+ $Values = $this->tmpFolder.$MapName;\r
+ $Value = split("\?",$Values);\r
+ $FileName = $Value[0];\r
+\r
+ if ( file_exists($FileName) )\r
+ {\r
+ $Handle = fopen($FileName, "r");\r
+ $MapContent = fread($Handle, filesize($FileName));\r
+ fclose($Handle);\r
+ echo $MapContent;\r
+\r
+ if ( $Flush )\r
+ unlink($FileName);\r
+\r
+ exit();\r
+ }\r
+ else\r
+ {\r
+ header("HTTP/1.0 404 Not Found");\r
+ exit();\r
+ }\r
+ }\r
+\r
+ /* Save the image map to the disk */\r
+ function SaveImageMap()\r
+ {\r
+ if ( !$this->BuildMap ) { return(-1); }\r
+\r
+ if ( $this->ImageMap == NULL )\r
+ {\r
+ $this->Errors[] = "[Warning] SaveImageMap - Image map is empty.";\r
+ return(-1);\r
+ }\r
+\r
+ $Handle = fopen($this->tmpFolder.$this->MapID, 'w');\r
+ if ( !$Handle )\r
+ {\r
+ $this->Errors[] = "[Warning] SaveImageMap - Cannot save the image map.";\r
+ return(-1);\r
+ }\r
+ else\r
+ {\r
+ foreach($this->ImageMap as $Key => $Value)\r
+ fwrite($Handle, htmlentities($Value)."\r");\r
+ }\r
+ fclose ($Handle);\r
+ }\r
+\r
+ /* Convert seconds to a time format string */\r
+ function ToTime($Value)\r
+ {\r
+ $Hour = floor($Value/3600);\r
+ $Minute = floor(($Value - $Hour*3600)/60);\r
+ $Second = floor($Value - $Hour*3600 - $Minute*60);\r
+\r
+ if (strlen($Hour) == 1 ) { $Hour = "0".$Hour; }\r
+ if (strlen($Minute) == 1 ) { $Minute = "0".$Minute; }\r
+ if (strlen($Second) == 1 ) { $Second = "0".$Second; }\r
+\r
+ return($Hour.":".$Minute.":".$Second);\r
+ }\r
+\r
+ /* Convert to metric system */\r
+ function ToMetric($Value)\r
+ {\r
+ $Go = floor($Value/1000000000);\r
+ $Mo = floor(($Value - $Go*1000000000)/1000000);\r
+ $Ko = floor(($Value - $Go*1000000000 - $Mo*1000000)/1000);\r
+ $o = floor($Value - $Go*1000000000 - $Mo*1000000 - $Ko*1000);\r
+\r
+ if ($Go != 0) { return($Go.".".$Mo."g"); }\r
+ if ($Mo != 0) { return($Mo.".".$ko."m"); }\r
+ if ($Ko != 0) { return($Ko.".".$o)."k"; }\r
+ return($o);\r
+ }\r
+\r
+ /* Convert to curency */\r
+ function ToCurrency($Value)\r
+ {\r
+ $Go = floor($Value/1000000000);\r
+ $Mo = floor(($Value - $Go*1000000000)/1000000);\r
+ $Ko = floor(($Value - $Go*1000000000 - $Mo*1000000)/1000);\r
+ $o = floor($Value - $Go*1000000000 - $Mo*1000000 - $Ko*1000);\r
+\r
+ if ( strlen($o) == 1 ) { $o = "00".$o; }\r
+ if ( strlen($o) == 2 ) { $o = "0".$o; }\r
+\r
+ $ResultString = $o;\r
+ if ( $Ko != 0 ) { $ResultString = $Ko.".".$ResultString; }\r
+ if ( $Mo != 0 ) { $ResultString = $Mo.".".$ResultString; }\r
+ if ( $Go != 0 ) { $ResultString = $Go.".".$ResultString; }\r
+\r
+ $ResultString = $this->Currency.$ResultString;\r
+ return($ResultString);\r
+ }\r
+\r
+ /* Set date format for axis labels */\r
+ function setDateFormat($Format)\r
+ {\r
+ $this->DateFormat = $Format;\r
+ }\r
+\r
+ /* Convert TS to a date format string */\r
+ function ToDate($Value)\r
+ {\r
+ return(date($this->DateFormat,$Value));\r
+ }\r
+\r
+ /* Check if a number is a full integer (for scaling) */\r
+ function isRealInt($Value)\r
+ {\r
+ if ($Value == floor($Value))\r
+ return(TRUE);\r
+ return(FALSE);\r
+ }\r
+ }\r
+\r
+ function RaiseFatal($Message)\r
+ {\r
+ echo "[FATAL] ".$Message."\r\n";\r
+ exit();\r
+ }\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/pData.class b/gosa-core/include/pChart/pData.class
--- /dev/null
@@ -0,0 +1,260 @@
+<?php\r
+ /*\r
+ pData - Simplifying data population for pChart\r
+ Copyright (C) 2008 Jean-Damien POGOLOTTI\r
+ Version 1.13 last updated on 08/17/08\r
+\r
+ http://pchart.sourceforge.net\r
+\r
+ This program is free software: you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation, either version 1,2,3 of the License, or\r
+ (at your option) any later version.\r
+\r
+ This program is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with this program. If not, see <http://www.gnu.org/licenses/>.\r
+\r
+ Class initialisation :\r
+ pData()\r
+ Data populating methods :\r
+ ImportFromCSV($FileName,$Delimiter=",",$DataColumns=-1,$HasHeader=FALSE,$DataName=-1)\r
+ AddPoint($Value,$Serie="Serie1",$Description="")\r
+ Series manipulation methods :\r
+ AddSerie($SerieName="Serie1")\r
+ AddAllSeries()\r
+ RemoveSerie($SerieName="Serie1")\r
+ SetAbsciseLabelSerie($SerieName = "Name")\r
+ SetSerieName($Name,$SerieName="Serie1")\r
+ + SetSerieSymbol($Name,$Symbol)\r
+ SetXAxisName($Name="X Axis")\r
+ SetYAxisName($Name="Y Axis")\r
+ SetXAxisFormat($Format="number")\r
+ SetYAxisFormat($Format="number")\r
+ SetXAxisUnit($Unit="")\r
+ SetYAxisUnit($Unit="")\r
+ removeSerieName($SerieName)\r
+ removeAllSeries()\r
+ Data retrieval methods :\r
+ GetData()\r
+ GetDataDescription()\r
+ */\r
+\r
+ /* pData class definition */\r
+ class pData\r
+ {\r
+ var $Data;\r
+ var $DataDescription;\r
+\r
+ function pData()\r
+ {\r
+ $this->Data = "";\r
+ $this->DataDescription = "";\r
+ $this->DataDescription["Position"] = "Name";\r
+ $this->DataDescription["Format"]["X"] = "number";\r
+ $this->DataDescription["Format"]["Y"] = "number";\r
+ $this->DataDescription["Unit"]["X"] = NULL;\r
+ $this->DataDescription["Unit"]["Y"] = NULL;\r
+ }\r
+\r
+ function ImportFromCSV($FileName,$Delimiter=",",$DataColumns=-1,$HasHeader=FALSE,$DataName=-1)\r
+ {\r
+ $handle = @fopen($FileName,"r");\r
+ if ($handle)\r
+ {\r
+ $HeaderParsed = FALSE;\r
+ while (!feof($handle))\r
+ {\r
+ $buffer = fgets($handle, 4096);\r
+ $buffer = str_replace(chr(10),"",$buffer);\r
+ $buffer = str_replace(chr(13),"",$buffer);\r
+ $Values = split($Delimiter,$buffer);\r
+\r
+ if ( $buffer != "" )\r
+ {\r
+ if ( $HasHeader == TRUE && $HeaderParsed == FALSE )\r
+ {\r
+ if ( $DataColumns == -1 )\r
+ {\r
+ $ID = 1;\r
+ foreach($Values as $key => $Value)\r
+ { $this->SetSerieName($Value,"Serie".$ID); $ID++; }\r
+ }\r
+ else\r
+ {\r
+ $SerieName = "";\r
+\r
+ foreach($DataColumns as $key => $Value)\r
+ $this->SetSerieName($Values[$Value],"Serie".$Value);\r
+ }\r
+ $HeaderParsed = TRUE;\r
+ }\r
+ else\r
+ {\r
+ if ( $DataColumns == -1 )\r
+ {\r
+ $ID = 1;\r
+ foreach($Values as $key => $Value)\r
+ { $this->AddPoint(intval($Value),"Serie".$ID); $ID++; }\r
+ }\r
+ else\r
+ {\r
+ $SerieName = "";\r
+ if ( $DataName != -1 )\r
+ $SerieName = $Values[$DataName];\r
+\r
+ foreach($DataColumns as $key => $Value)\r
+ $this->AddPoint($Values[$Value],"Serie".$Value,$SerieName);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ fclose($handle);\r
+ }\r
+ }\r
+\r
+ function AddPoint($Value,$Serie="Serie1",$Description="")\r
+ {\r
+ if (is_array($Value) && count($Value) == 1)\r
+ $Value = $Value[0];\r
+\r
+ $ID = 0;\r
+ for($i=0;$i<=count($this->Data);$i++)\r
+ { if(isset($this->Data[$i][$Serie])) { $ID = $i+1; } }\r
+\r
+ if ( count($Value) == 1 )\r
+ {\r
+ $this->Data[$ID][$Serie] = $Value;\r
+ if ( $Description != "" )\r
+ $this->Data[$ID]["Name"] = $Description;\r
+ elseif (!isset($this->Data[$ID]["Name"]))\r
+ $this->Data[$ID]["Name"] = $ID;\r
+ }\r
+ else\r
+ {\r
+ foreach($Value as $key => $Val)\r
+ {\r
+ $this->Data[$ID][$Serie] = $Val;\r
+ if (!isset($this->Data[$ID]["Name"]))\r
+ $this->Data[$ID]["Name"] = $ID;\r
+ $ID++;\r
+ }\r
+ }\r
+ }\r
+\r
+ function AddSerie($SerieName="Serie1")\r
+ {\r
+ if ( !isset($this->DataDescription["Values"]) )\r
+ {\r
+ $this->DataDescription["Values"][] = $SerieName;\r
+ }\r
+ else\r
+ {\r
+ $Found = FALSE;\r
+ foreach($this->DataDescription["Values"] as $key => $Value )\r
+ if ( $Value == $SerieName ) { $Found = TRUE; }\r
+\r
+ if ( !$Found )\r
+ $this->DataDescription["Values"][] = $SerieName;\r
+ }\r
+ }\r
+\r
+ function AddAllSeries()\r
+ {\r
+ unset($this->DataDescription["Values"]);\r
+\r
+ if ( isset($this->Data[0]) )\r
+ {\r
+ foreach($this->Data[0] as $Key => $Value)\r
+ {\r
+ if ( $Key != "Name" )\r
+ $this->DataDescription["Values"][] = $Key;\r
+ }\r
+ }\r
+ }\r
+\r
+ function RemoveSerie($SerieName="Serie1")\r
+ {\r
+ if ( !isset($this->DataDescription["Values"]) )\r
+ return(0);\r
+\r
+ $Found = FALSE;\r
+ foreach($this->DataDescription["Values"] as $key => $Value )\r
+ {\r
+ if ( $Value == $SerieName )\r
+ unset($this->DataDescription["Values"][$key]);\r
+ }\r
+ }\r
+\r
+ function SetAbsciseLabelSerie($SerieName = "Name")\r
+ {\r
+ $this->DataDescription["Position"] = $SerieName;\r
+ }\r
+\r
+ function SetSerieName($Name,$SerieName="Serie1")\r
+ {\r
+ $this->DataDescription["Description"][$SerieName] = $Name;\r
+ }\r
+\r
+ function SetXAxisName($Name="X Axis")\r
+ {\r
+ $this->DataDescription["Axis"]["X"] = $Name;\r
+ }\r
+\r
+ function SetYAxisName($Name="Y Axis")\r
+ {\r
+ $this->DataDescription["Axis"]["Y"] = $Name;\r
+ }\r
+\r
+ function SetXAxisFormat($Format="number")\r
+ {\r
+ $this->DataDescription["Format"]["X"] = $Format;\r
+ }\r
+\r
+ function SetYAxisFormat($Format="number")\r
+ {\r
+ $this->DataDescription["Format"]["Y"] = $Format;\r
+ }\r
+\r
+ function SetXAxisUnit($Unit="")\r
+ {\r
+ $this->DataDescription["Unit"]["X"] = $Unit;\r
+ }\r
+\r
+ function SetYAxisUnit($Unit="")\r
+ {\r
+ $this->DataDescription["Unit"]["Y"] = $Unit;\r
+ }\r
+\r
+ function SetSerieSymbol($Name,$Symbol)\r
+ {\r
+ $this->DataDescription["Symbol"][$Name] = $Symbol;\r
+ }\r
+\r
+ function removeSerieName($SerieName)\r
+ {\r
+ if ( isset($this->DataDescription["Description"][$SerieName]) )\r
+ unset($this->DataDescription["Description"][$SerieName]);\r
+ }\r
+\r
+ function removeAllSeries()\r
+ {\r
+ foreach($this->DataDescription["Values"] as $Key => $Value)\r
+ unset($this->DataDescription["Values"][$Key]);\r
+ }\r
+\r
+ function GetData()\r
+ {\r
+ return($this->Data);\r
+ }\r
+\r
+ function GetDataDescription()\r
+ {\r
+ return($this->DataDescription);\r
+ }\r
+ }\r
+?>
\ No newline at end of file
diff --git a/gosa-core/include/pChart/pf_arma_five.ttf b/gosa-core/include/pChart/pf_arma_five.ttf
new file mode 100644 (file)
index 0000000..db04ec3
Binary files /dev/null and b/gosa-core/include/pChart/pf_arma_five.ttf differ
index 0000000..db04ec3
Binary files /dev/null and b/gosa-core/include/pChart/pf_arma_five.ttf differ
diff --git a/gosa-core/include/pChart/softtones.txt b/gosa-core/include/pChart/softtones.txt
--- /dev/null
@@ -0,0 +1,5 @@
+168,188,56\r
+188,208,76\r
+208,228,96\r
+228,245,116\r
+248,255,136\r
diff --git a/gosa-core/include/pChart/tahoma.ttf b/gosa-core/include/pChart/tahoma.ttf
new file mode 100644 (file)
index 0000000..59b14a2
Binary files /dev/null and b/gosa-core/include/pChart/tahoma.ttf differ
index 0000000..59b14a2
Binary files /dev/null and b/gosa-core/include/pChart/tahoma.ttf differ
diff --git a/gosa-core/include/pChart/tones.txt b/gosa-core/include/pChart/tones.txt
--- /dev/null
@@ -0,0 +1,5 @@
+94,48,0\r
+201,34,0\r
+247,143,1\r
+255,238,208\r
+90,181,110\r