source: trunk/xgraph/jpgraph/Examples/barcsim_popup.php @ 42

Last change on this file since 42 was 42, checked in by marrucho, 10 years ago
File size: 1.3 KB
Line 
1<?php // content="text/plain; charset=utf-8"
2require_once ('jpgraph/jpgraph.php');
3require_once ('jpgraph/jpgraph_bar.php');
4
5// Some random data to plot
6$datay=array(12,26,9,17,31);
7
8// Create the graph.
9$graph = new Graph(400,250);
10$graph->SetScale("textlin");
11
12// Create a bar pot
13$bplot = new BarPlot($datay);
14
15// Create targets for the image maps so that the details are opened in a separate window
16$fmtStr = "javascript:window.open('barcsim_details.php?id=%d','_new','width=500,height=300');void(0)";
17$n = count($datay);
18$targ=array();
19$alts=array();
20for($i=0; $i < $n; ++$i) {
21    $targ[$i] = sprintf($fmtStr,$i+1);
22    $alts[$i] = 'val=%d'; 
23    // Note: The format placeholder val=%d will be replaced by the actual value in the ouput HTML by the
24    // library so that when the user hoovers the mouse over the bar the actual numerical value of the bar
25    // will be dísplayed
26}
27$bplot->SetCSIMTargets($targ,$alts);
28
29// Add plot to graph
30$graph->Add($bplot);
31
32// Setup the title, also wih a CSIM area
33$graph->title->Set("CSIM with popup windows");
34$graph->title->SetFont(FF_FONT2,FS_BOLD);
35// Assume we can give more details on the graph
36$graph->title->SetCSIMTarget(sprintf($fmtStr,-1),'Title for Bar'); 
37
38// Send back the HTML page which will call this script again to retrieve the image.
39$graph->StrokeCSIM();
40
41?>
Note: See TracBrowser for help on using the repository browser.