[ Index ] |
|
Code source de jpGraph 2.2 |
1 <?php 2 include ("../jpgraph.php"); 3 include ("../jpgraph_line.php"); 4 5 DEFINE('WORLDMAP','worldmap1.jpg'); 6 7 function markCallback($y,$x) { 8 // Return array width 9 // width,color,fill color, marker filename, imgscale 10 // any value can be false, in that case the default value will 11 // be used. 12 // We only make one pushpin another color 13 if( $x == 54 ) 14 return array(false,false,false,'red',0.8); 15 else 16 return array(false,false,false,'green',0.8); 17 } 18 19 // Data arrays 20 $datax = array(10,20,30,40,54,60,70,80); 21 $datay = array(12,23,65,18,84,28,86,44); 22 23 // Setup the graph 24 $graph = new Graph(400,270); 25 26 // We add a small 1pixel left,right,bottom margin so the plot area 27 // doesn't cover the frame around the graph. 28 $graph->img->SetMargin(1,1,1,1); 29 $graph->SetScale('linlin',0,100,0,100); 30 31 // We don't want any axis to be shown 32 $graph->xaxis->Hide(); 33 $graph->yaxis->Hide(); 34 35 // Use a worldmap as the background and let it fill the plot area 36 $graph->SetBackgroundImage(WORLDMAP,BGIMG_FILLPLOT); 37 38 // Setup a nice title with a striped bevel background 39 $graph->title->Set("Pushpin graph"); 40 $graph->title->SetFont(FF_ARIAL,FS_BOLD,16); 41 $graph->title->SetColor('white'); 42 $graph->SetTitleBackground('darkgreen',TITLEBKG_STYLE1,TITLEBKG_FRAME_BEVEL); 43 $graph->SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED,'blue','darkgreen'); 44 45 // Finally create the lineplot 46 $lp = new LinePlot($datay,$datax); 47 $lp->SetColor('lightgray'); 48 49 // We want the markers to be an image 50 $lp->mark->SetType(MARK_IMG_PUSHPIN,'blue',0.6); 51 52 // Install the Y-X callback for the markers 53 $lp->mark->SetCallbackYX('markCallback'); 54 55 // ... and add it to the graph 56 $graph->Add($lp); 57 58 // .. and output to browser 59 $graph->Stroke(); 60 61 ?> 62 63
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 09:27:55 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |