function index() { $width = 600; $height = 230; /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(array(-4, VOID, VOID, 12, 8, 3), "Female"); $MyData->addPoints(array(3, 12, 15, 8, 5, -5), "Male"); //$MyData->addPoints(array(2,0,5,18,19,22),"Probe 3"); $MyData->setSerieTicks("Male", 4); $MyData->setAxisName(0, "Number of males, females"); $MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Labels"); $MyData->setSerieDescription("Labels", "Months"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage($width, $height, $MyData); /* Draw the background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, $width, $height, $Settings); /* Overlay with a gradient */ $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_VERTICAL, $Settings); //$myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>80)); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, $width - 1, $height - 1, array("R" => 0, "G" => 0, "B" => 0)); /* Write the picture title */ //$myPicture->setFontProperties(array("FontName"=>pClass."fonts/Silkscreen.ttf","FontSize"=>6)); //$myPicture->drawText(10,13,"drawBarChart() - draw a bar chart",array("R"=>255,"G"=>255,"B"=>255)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => pClass . "fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(250, 55, "Average time to find a set", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); /* Draw the scale and the 1st chart */ $myPicture->setGraphArea(60, 60, 450, 190); $myPicture->drawFilledRectangle(60, 60, 450, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10)); $myPicture->drawScale(array("DrawSubTicks" => TRUE)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $myPicture->setFontProperties(array("FontName" => pClass . "fonts/pf_arma_five.ttf", "FontSize" => 10)); $myPicture->drawBarChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO, "Rounded" => TRUE, "Surrounding" => 30)); //$myPicture->drawBarChart(array("DisplayValues"=>TRUE,"DisplayColor"=>DISPLAY_AUTO,"Surrounding"=>30)); $myPicture->setShadow(FALSE); /* Draw the scale and the 2nd chart */ /* $myPicture->setGraphArea(500,60,670,190); $myPicture->drawFilledRectangle(500,60,670,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10)); $myPicture->drawScale(array("Pos"=>SCALE_POS_TOPBOTTOM,"DrawSubTicks"=>TRUE)); $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10)); $myPicture->drawBarChart(); $myPicture->setShadow(FALSE); */ /* Write the chart legend */ //$myPicture->drawLegend(510,205,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL)); $myPicture->drawLegend(500, 105, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL)); /* Render the picture (choose the best way) */ $myPicture->stroke(); }
// echo "<pre>\r\n"; // print_r($csvdata_point); // echo "</pre>\r\n"; // // // ----------------- //============================================================================================= // $MyData = new pData(); // for($i=0;$i<=30;$i++) { $MyData->addPoints(rand(1,15),"Probe 1"); } // $MyData->setSerieTicks("Probe 2",4); // $MyData->setAxisName(0,"Temperatures"); /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints($csvdata_values, "Temperature"); $MyData->addPoints($csvdata_point, "Labels"); $MyData->setSerieDescription("Labels", "Months"); $MyData->setAbscissa("Labels"); $MyData->setSerieTicks("Probe 1", 4); $MyData->setAxisName(0, "Spanung in [mV]"); /* Create the pChart object */ $myPicture = new pImage(800, 400, $MyData); /* Turn of Antialiasing */ $myPicture->Antialias = FALSE; /* Add a border to the picture */ //$myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,array("StartR"=>240,"StartG"=>240,"StartB"=>240,"EndR"=>180,"EndG"=>180,"EndB"=>180,"Alpha"=>100)); //$myPicture->drawGradientArea(0,0,700,230,DIRECTION_HORIZONTAL,array("StartR"=>240,"StartG"=>240,"StartB"=>240,"EndR"=>180,"EndG"=>180,"EndB"=>180,"Alpha"=>20)); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 799, 399, array("R" => 0, "G" => 0, "B" => 0)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => "libs/pChart2.1.4/fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(150, 35, "Spannungsverlauf seit Ladung", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); /* Set the default font */ $myPicture->setFontProperties(array("FontName" => "libs/pChart2.1.4/fonts/pf_arma_five.ttf", "FontSize" => 6));
$results = $tc->getResponses($entry); $otype = $entry->Is_Hardware__c ? 'Hardware' : 'Software'; $position = $results['02']->Position; $result = $results[$chart]; $benchmark = ($result->Benchmark_High - $result->Benchmark_Low) / 2 + $result->Benchmark_Low; $ytemp = max($result->Response__c, $result->Benchmark_High, $result->Peer_Median, $result->Group_Median__c); $yaxis = $ytemp - $ytemp % 5 + 5; if ($yaxis < 15) { $yaxis = 15; } $overUnder = $position == 'ABOVE' ? '70% or more' : 'less than 70%'; $ctitle = $result->Question__c; $data = new pData(); $bdat = array(array(0 => $result->Benchmark_High, 1 => $result->Benchmark_High, 2 => $result->Benchmark_High, 3 => $result->Benchmark_High, 4 => $result->Benchmark_High, 5 => $result->Benchmark_High), array(0 => $result->Benchmark_Low, 1 => $result->Benchmark_Low, 2 => $result->Benchmark_Low, 3 => $result->Benchmark_Low, 4 => $result->Benchmark_Low, 5 => $result->Benchmark_Low)); $data->addPoints(array($result->Prior_Year, $result->Response__c, $result->Peer_Median, $result->Group_Median__c), "series1"); $data->setSerieTicks("series1", 4); $data->addPoints(array("Your 2009\npercentage", "Your 2010\npercentage", "Median percentage \namong other companies \nwith {$overUnder} of \ntheir technical workforce\nin engineering, R&D, and \ntechnical design, 2010", "Median percentage among\nall other participating\ncompanies, 2010"), "Labels"); $data->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(700, 450, $data); /* Create a solid background */ $Settings = array("R" => 242, "G" => 242, "B" => 242); $myPicture->drawFilledRectangle(0, 0, 700, 450, $Settings); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 449, array("R" => 102, "G" => 102, "B" => 102)); /* Write the picture title */ $myPicture->setFontProperties(array("FontName" => "../pChart/fonts/verdana.ttf", "FontSize" => 11)); $myPicture->drawText(50, 28, $ctitle, array("R" => 69, "G" => 43, "B" => 135)); //rgb(69,43,135) /* Draw the scale */ $myPicture->setFontProperties(array("FontName" => "../pChart/fonts/verdana.ttf", "FontSize" => 8));
$data3[] = round($z[$i]['re'], 0); $labels[] = $i + $j * count($x); } } //var_dump($data1); $MyData = new pData(); $MyData->addPoints($data1, "Probe 1"); $MyData->addPoints($data2, "Probe 2"); $MyData->addPoints($data3, "Probe 3"); //$myPicture->drawScale(array("DrawYLines"=>array(0))); //$MyData->setSerieTicks("Probe 2",1); //$MyData->setSerieWeight("Probe 3",1); $MyData->setAxisName(0, "Temperatures"); $MyData->addPoints($labels, "Labels"); $MyData->setSerieDescription("Labels", "Months"); $MyData->setSerieTicks(10); $MyData->setAbscissa("Labels"); $MyData->setPalette("Probe 1", array("R" => 13, "G" => 35, "B" => 58)); $MyData->setPalette("Probe 2", array("R" => 145, "G" => 0, "B" => 0)); $MyData->setPalette("Probe 3", array("R" => 242, "G" => 143, "B" => 67)); /* Create the pChart object */ $W = 1024; if (isset($_GET["w"])) { $W = $_GET["w"]; } $myPicture = new pImage($W, 400, $MyData); /* Turn of Antialiasing */ $myPicture->Antialias = FALSE; //$myPicture->drawGraphAreaGradient(132,153,172,50,TARGET_BACKGROUND); /* Add a border to the picture */ //$myPicture->drawRectangle(0,0,1023,399,array("R"=>0,"G"=>0,"B"=>0));
<?php /* CAT:Drawing */ /* pChart library inclusions */ include "../class/pData.class.php"; include "../class/pDraw.class.php"; include "../class/pImage.class.php"; /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(array(24, 25, 26, 25, 25), "My Serie 1"); $MyData->addPoints(array(80, 85, 84, 81, 82), "My Serie 2"); $MyData->addPoints(array(17, 16, 18, 18, 15), "My Serie 3"); $MyData->setSerieTicks("My Serie 1", 4); $MyData->setSerieWeight("My Serie 2", 2); $MyData->setSerieDescription("My Serie 1", "Temperature"); $MyData->setSerieDescription("My Serie 2", "Humidity\n(in percentage)"); $MyData->setSerieDescription("My Serie 3", "Pressure"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); /* Draw the background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings); /* Overlay with a gradient */ $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); $myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80)); /* Draw the picture border */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Write the picture title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6)); $myPicture->drawText(10, 13, "drawLegend() - Write your chart legend", array("R" => 255, "G" => 255, "B" => 255));
<?php /* CAT:Combo */ /* pChart library inclusions */ include "../class/pData.class.php"; include "../class/pDraw.class.php"; include "../class/pImage.class.php"; /* Create the pData object with some random values*/ $MyData = new pData(); $MyData->addPoints(array(30, 24, 32), "This year"); $MyData->addPoints(array(28, 20, 27), "Last year"); $MyData->setSerieTicks("Last year", 4); $MyData->addPoints(array("Year", "Month", "Day"), "Labels"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); /* Turn on antialiasing */ $myPicture->Antialias = FALSE; /* Create a solid background */ $Settings = array("R" => 179, "G" => 217, "B" => 91, "Dash" => 1, "DashR" => 199, "DashG" => 237, "DashB" => 111); $myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings); /* Do a gradient overlay */ $Settings = array("StartR" => 194, "StartG" => 231, "StartB" => 44, "EndR" => 43, "EndG" => 107, "EndB" => 58, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); $myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100)); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Write the picture title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6)); $myPicture->drawText(10, 13, "Chart title", array("R" => 255, "G" => 255, "B" => 255)); /* Draw the scale */
session_start(); $popularity = $_SESSION['popularity']; $year = $_SESSION['year']; $name = $_SESSION['name']; /* CAT:Line chart */ /* pChart library inclusions */ include "../class/pData.class.php"; include "../class/pDraw.class.php"; include "../class/pImage.class.php"; /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints($popularity, "{$name}"); $MyData->addPoints($popularity, ""); //$MyData->addPoints($popularity,"$name"); $MyData->setSerieTicks("", 2); //$MyData->setSerieWeight("$name",2); $MyData->setAxisName(0, "Popularity "); $MyData->addPoints($year, "Labels"); $MyData->setSerieDescription("Labels", "Year"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); /* Turn of Antialiasing */ $myPicture->Antialias = FALSE; /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(150, 35, "Popularity Graph", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); /* Set the default font */
function temperatures_mois() { //initialisation des variables tableau $timestamp = ""; $temperature_dehors = ""; $temperature_chambre = ""; $hygro_chambre = ""; $temperature_sejour = ""; $hygro_sejour = ""; $pression_sejour = ""; $sql = mysql_query("SELECT TIMESTAMP( CONCAT( YEAR( date_histo ) , '-', MONTH( date_histo ) , '-', DAY( date_histo ) , ' ', HOUR( date_histo ) , ':00' ) ) , date_histo, id_objet, AVG( valeur1 ) , AVG( valeur2 ) , AVG( valeur3 ) \n\t\t\t\t\tFROM historique_donnees\n\t\t\t\t\tWHERE id_objet IN ( 1, 3, 4 ) \n\t\t\t\t\tAND date_histo > DATE_SUB(NOW( ), INTERVAL 31 DAY)\n\t\t\t\t\tGROUP BY YEAR( date_histo ) , MONTH( date_histo ) , DAY( date_histo ), HOUR( date_histo ), id_objet\n\t\t\t\t\tHAVING HOUR( date_histo ) IN ( 00, 06, 12, 18 ) \n\t\t\t\t\tORDER BY date_histo"); while (list($date_histo, $date_histo2, $id_objet, $temp, $hygro, $pression) = mysql_fetch_array($sql)) { $timestamp[$date_histo] = strtotime($date_histo); switch ($id_objet) { case 1: //chambre $temperature_chambre[$date_histo] = $temp; $hygro_chambre[$date_histo] = $hygro; break; case 3: //dehors $temperature_dehors[$date_histo] = $temp; break; case 4: //sejour $temperature_sejour[$date_histo] = $temp; $hygro_sejour[$date_histo] = $hygro; $pression_sejour[$date_histo] = $pression; break; } } //on garde les trous en cas de pertes d'informations $temperature_chambre = combler_les_trous($timestamp, $temperature_chambre); $hygro_chambre = combler_les_trous($timestamp, $hygro_chambre); $temperature_dehors = combler_les_trous($timestamp, $temperature_dehors); $temperature_sejour = combler_les_trous($timestamp, $temperature_sejour); $hygro_sejour = combler_les_trous($timestamp, $hygro_sejour); $pression_sejour = combler_les_trous($timestamp, $pression_sejour); $myData = new pData(); $myData->addPoints($timestamp, "Timestamp"); $myData->addPoints($temperature_dehors, "T° Exterieure"); $myData->addPoints($temperature_sejour, "T° Séjour"); $myData->addPoints($temperature_chambre, "T° Chambre"); $myData->addPoints($hygro_chambre, "Hygro Chambre"); $myData->addPoints($hygro_sejour, "Hygro Séjour"); $myData->addPoints($pression_sejour, "Pression Atmo"); $myData->setSerieOnAxis("T° Exterieure", 0); $myData->setSerieOnAxis("T° Séjour", 0); $myData->setSerieOnAxis("T° chambre", 0); $myData->setSerieOnAxis("Hygro Séjour", 1); $myData->setSerieOnAxis("Hygro Chambre", 1); $myData->setSerieTicks("Hygro Séjour", 4); $myData->setSerieTicks("Hygro Chambre", 4); $myData->setSerieOnAxis("Pression Atmo", 2); $myData->setAbscissa("Timestamp"); $myData->setXAxisName("Time"); // $myData->setXAxisDisplay(AXIS_FORMAT_TIME,"H:i"); $myData->setXAxisDisplay(AXIS_FORMAT_TIME, "d/m"); //$myData->setXAxisDisplay(0,AXIS_FORMAT_CUSTOM,"format_absisse_jour"); $myData->setAxisName(0, "Temperatures en °C"); $myData->setAxisUnit(0, "°"); //temperature $bornes_axe_ordonnees[0] = array("Min" => -8, "Max" => 35); //humidite $bornes_axe_ordonnees[1] = array("Min" => 30, "Max" => 90); $myData->setAxisName(1, "Humidite"); $myData->setAxisUnit(1, "%"); $myData->setAxisName(2, "Pression Atmosphérique"); $myData->setAxisUnit(2, "HPa"); $myData->setAxisPosition(2, AXIS_POSITION_RIGHT); $myPicture = new pImage(1250, 550, $myData); //$Settings = array("R"=>48, "G"=>124, "B"=>183, "Dash"=>1, "DashR"=>68, "DashG"=>144, "DashB"=>203); //$myPicture->drawFilledRectangle(0,0,1200,500,$Settings); $Settings = array("StartR" => 48, "StartG" => 124, "StartB" => 183, "EndR" => 33, "EndG" => 86, "EndB" => 128, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 1250, 550, DIRECTION_VERTICAL, $Settings); //$myPicture->drawRectangle(0,0,1199,499,array("R"=>0,"G"=>0,"B"=>0)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 20)); $myPicture->setFontProperties(array("FontName" => "fonts/Forgotte.ttf", "FontSize" => 18)); $TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 255, "G" => 255, "B" => 255); $myPicture->drawText(350, 25, "Météo Nantaise", $TextSettings); $myPicture->setShadow(FALSE); $myPicture->setGraphArea(110, 50, 1160, 500); $myPicture->setFontProperties(array("R" => 0, "G" => 0, "B" => 0, "FontName" => "fonts/Forgotte.ttf", "FontSize" => 14)); $Settings = array("Pos" => SCALE_POS_LEFTRIGHT, "Mode" => SCALE_MODE_FLOATING, "LabelingMethod" => LABELING_ALL, "GridR" => 255, "GridG" => 255, "GridB" => 255, "GridAlpha" => 50, "TickR" => 0, "TickG" => 0, "TickB" => 0, "TickAlpha" => 50, "LabelRotation" => 45, "CycleBackground" => 1, "DrawXLines" => 1, "DrawSubTicks" => 1, "SubTickR" => 255, "SubTickG" => 0, "SubTickB" => 0, "SubTickAlpha" => 50, "DrawYLines" => ALL, "LabelSkip" => 3); $myPicture->drawScale($Settings); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10)); $Config = ""; $myPicture->drawSplineChart($Config); $Config = array("FontR" => 0, "FontG" => 0, "FontB" => 0, "FontName" => "fonts/Forgotte.ttf", "FontSize" => 14, "Margin" => 6, "Alpha" => 30, "BoxSize" => 5, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL); $myPicture->drawLegend(563, 16, $Config); //$myPicture->stroke(); $myPicture->render("tmp/graphe_tm.png"); echo "<img src='tmp/graphe_tm.png' alt='graphe'/>"; }
<?php /* CAT:Plot chart */ /* pChart library inclusions */ include "../class/pData.class.php"; include "../class/pDraw.class.php"; include "../class/pImage.class.php"; /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(array(3, 4, 7, 4, 2, 5), "User"); $MyData->addPoints(array(12, 17, 15, 18, 19, 22), "Group"); $MyData->setSeriePicture("User", "resources/serie1.png"); $MyData->setSeriePicture("Group", "resources/serie2.png"); $MyData->setSerieWeight("Group", 1); $MyData->setSerieTicks("Group", 4); $MyData->setAxisName(0, "Hours"); $MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Labels"); $MyData->setSerieDescription("Labels", "Months"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); /* Draw the background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings); /* Overlay with a gradient */ $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); $myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80)); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Write the picture title */