1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
<?php
include ("src/jpgraph.php");
include ("src/jpgraph_bar.php");
// Les données
$mois=array("Jan","Fev","Mar","Avr","Mai","Jun","Jul","Auo","Sep","Oct","Nov","Dec");
$datay1=array(140,110,50,60,124,120,30,140,40,150,60,150);
$datay2=array(35,90,190,190,124,10,120,30,140,50,160,70);
//Créer le graphique.
$graph = new Graph(320,240,'auto');
$graph->SetScale("textlin");
$graph->img->SetMargin(30,10,10,40);
// Ajuster la couleur à l'ombre de la légende
$graph->legend->SetShadow('darkgray@0.5');
$graph->legend->SetFillColor('lightblue@0.3');
// Obtenir la version localisée des noms de mois
$graph->xaxis->SetTickLabels($mois);
// image arriere plan
$graph->SetBackgroundImage('background.jpg',BGIMG_COPY);
// Placer les titres et les polices d'axe
$graph->xaxis->title->Set('');
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetColor('white');
$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->SetColor('blue');
$graph->yaxis->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->SetColor('blue');
// Une certaine marge supplémentaire (à partir du haut)
$graph->title->SetMargin(3);
$graph->title->SetFont(FF_FONT1,FS_BOLD,12);
// Créer les trois séries de variété
$bplot1 = new BarPlot($datay1);
$bplot2 = new BarPlot($datay2);
// Installer les couleurs avec le transparent de 40% (le canal d'alpha)
$bplot1->SetFillColor('orange@0.4');
$bplot2->SetFillColor('brown@0.4');
$gbarplot = new GroupBarPlot(array($bplot1,$bplot2));
$gbarplot->SetWidth(0.8); // largeur des colonnes
$graph->Add($gbarplot);
$graph->Stroke();
?> |
Partager