Classe CMbGraph
Imprimer

Classe CMbGraph

Cette classe permet de créer des graphique. Elle comprend toutes les fonctions permettant de créer des graphiques en baton, linéaire, camembert...Elle permet aussi de faire une abstraction de la bilbiothèque de création du graphique.

Vous pourrez trouver le code source de cette classe ici : classes/mbGraph (external link)

Fonctions

Constructeur

Pour répondre aux différents paramètres des bibliothèques de création de graphique, un tableau d'option a été définit pour une utilisation plus aisé lors de la création. Des valeurs par défault ont été définis.

<?php
function CMbGraph() {
		global $dPconfig;
		$this->config = $dPconfig['graph_engine'];
		$this->options = array ("width" => 320,   //width of frame 
					"height" => 125,  //height of frame
					"size" => 1,      //frame scale                                       
                    "title" => "Title",  //title of frame
					"subtitle" => " ",   //subtitle of frame 
					"sizeFontTitle" => 7,  //title font size 
					"palette" => array ( "#aa5500",
                          "#55aa00", "#0055aa", "#aa0055", "#5500aa", "#00aa55", "#ff0000", "#00ff00",
                          "#0000ff", "#ffff00", "#ff00ff", "#00ffff", "#FFFFFF", "#C90062", "#E05206",
                          "#F0AB00", "#000000", "#FF0000", "#3C8A2E", "#006983", "#0098C3", "#21578A",
                          "#55517B", "#4E7D5B" ),  //color pallets
				    "ezCPalette" => "ez", //eZComponent pallets
                    "margin" => array (0, 0, 0, 0), //margin of frame
                    "marginColor" => "lightblue", //margin color
					"titleColor"	=> "darkred", //title color
					"subtitleColor"	=> "black", //subtitle color
					"sizeFontLegend" => 7, //legend font size 
					"posLegend" => array(0,0,"right","top"),  //legend position
				    "sizeFontAxis" => 6, //axis font size 
					"labelAngle" => 0,   //label angle
					"textTickInterval" => 0, //text tick interval
                    "posXAbsDelta" => 0, //position X 
					"posYAbsDelta" => 0, //position Y
					"dataPie" => array(), //data of pie graph 
					"dataBar" => array(), //data of bar graph 
					"dataLine" => array(), //data of line graph 
					"dataAccBar" => array(), //data of accBar graph 
					"datax" => array(),		//data of X axis							 
					"addY" => "addY1",		//choice add data is Y1 or Y2
					"from" => "#AAAAAA",  //beginning graph color 
					"to" => "#EEEEEE",		//end graph color 
					"graphBarColor" => "white", //color of bar graph 
					"graphBarLegend" => "", //legend of bar graph 
					"graphLineColor" => "white", //color of line graph 
					"graphLineLegend" => "", //legend of line graph 
					"graphSplineLegend" => "", //legend of spline graph
					"graphPieLegend" => "Legend", //legend of pie graph
					"graphAccLegend" => "Legend", //legend of accBar graph
					"graphLineSize" => 1,  //size of line size
					"map" => "non", //choice if graph is a map
					"mapInfo" => array(),	//map info					 		
                    "renderPath" => "tmp/graphtmp.png",  //render path
					"nameHtmlImageMap" => "nameHtmlImageMap", //name html image map
					"scale" => array(0,0)	//scale of xaxis and yaxis									
);}  
?>

Exemples

Accumulated bar plot

Le graphique "Accumulated bar plot" permet de réprésenter un graphique en bâton en accumulant plusieurs données.

<?php
$options = array( "width" => 480,
		  "height" => 300,
		  "title" => $title,
		  "subtitle" => $subtitle,
		  "sizeFontTitle" => 10,
		  "margin" => array(50,40,50,70),
		  "posLegend" => array(0.02, 0.06, "right", "top"), 
          "sizeFontAxis" => 8,
		  "labelAngle" => 50,
		  "textTickInterval" => 2,
		  "posXAbsDelta" => 15,
		  "posYAbsDelta" => -15,
		  "dataAccBar" => $patbyservice,
		  "datax" => $datax,
          "graphAccLegend" => $patbyservice,);			
$graph = new CMbGraph();
$graph->selectType("Graph",$options);
$graph->selectPalette($options);
$graph->setupAxis($options);
$graph->addAccBarPlot($options);
$graph->render("out",$options);
?>

Spline graph

Le graphique "Spline" est construit en reliant les points d'un repère interpolés

<?php
$options = array( "width" => 480,
		          "height" => 300,
			      "title" => $title,
			      "margin" => array(50,40,50,70),
			      "posLegend" => array(0.015,0.79, "right", "center"), 
			      "sizeFontAxis" => 8,
			      "labelAngle" => 50,
			      "textTickInterval" => 2,
			      "posXAbsDelta" => 15,
			      "posYAbsDelta" => -15,
			      "dataLine" => $op,
			      "datax" => $datax,
			      "scale" => array(0,intval($opSorted[0])+1),);		
$graph = new CMbGraph();
$graph->selectType("Graph",$options);
$graph->selectPalette($options);
$graph->setupAxis($options);
$graph->addSplinePlot($options);
$graph->render("out",$options);
?>


Dernièrement modifié par lryo10166 points  .
Modifiée dernièrement le jeudi 26 de juillet, 2007 12h11m21.

Sponsors privilégiés

Mediboard project