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

Last change on this file since 42 was 42, checked in by marrucho, 10 years ago
File size: 2.4 KB
Line 
1<html>
2<body>
3
4<?php
5// The names of the graph scripts
6$_graphfilename1 = 'csim_in_html_graph_ex1.php';
7$_graphfilename2 = 'csim_in_html_graph_ex2.php';
8
9// This is the filename of this HTML file
10global $_wrapperfilename;
11$_wrapperfilename = basename (__FILE__);
12
13// Create a random mapname used to connect the image map with the image
14$_mapname1 = '__mapname'.rand(0,1000000).'__';
15$_mapname2 = '__mapname'.rand(0,1000000).'__';
16
17// Get the graph scripts
18require_once ($_graphfilename1);
19require_once ($_graphfilename2);
20
21// This line gets the image map and inserts it on the page
22$imgmap1 = $graph->GetHTMLImageMap($_mapname1);
23$imgmap2 = $piegraph->GetHTMLImageMap($_mapname2);
24echo $imgmap1;
25echo $imgmap2;
26
27?>
28
29<h2>This is an example page with CSIM graphs with arbitrary HTML text</h2>
30
31<?php
32if( empty($_GET['clickedon']) ) {
33   echo '<b style="color:darkred;">Clicked on bar: &lt;none></b>';
34}
35else {
36   echo '<b style="color:darkred;">Clicked on bar: '.$_GET['clickedon'].'</b>';
37}
38echo '<p />';
39if( empty($_GET['pie_clickedon']) ) {
40   echo '<b style="color:darkred;">Clicked on pie slice: &lt;none></b>';
41}
42else {
43   echo '<b style="color:darkred;">Clicked on pie slice: '.$_GET['pie_clickedon'].'</b>';
44}
45echo '<p />';
46?>
47
48<p>First we need to get hold of the image maps and include them in the HTML
49  page.</p>
50<p>For these graphs the maps are:</p>
51<?php
52// The we display the image map as well
53echo '<small><pre>'.htmlentities($imgmap1).'</pre></small>';
54?>
55<p>
56and
57</p>
58<?php
59// The we display the image map as well
60echo '<small><pre>'.htmlentities($imgmap2).'</pre></small>';
61?>
62
63<?php
64// Construct the <img> tags for Figure 1 &amp; 2 and rebuild the URL arguments
65$imgtag1 = $graph->GetCSIMImgHTML($_mapname1,$_graphfilename1);
66$imgtag2 = $piegraph->GetCSIMImgHTML($_mapname2,$_graphfilename2);
67?>
68<p>The graphs are then displayed as shown in figure 1 &amp; 2. With the following
69  created &lt;img> tags:</p>
70<small><pre>
71<?php 
72echo htmlentities($imgtag1); 
73echo htmlentities($imgtag2); 
74?>
75</pre></small>
76
77<p>
78Note: For the Pie the center is counted as the first slice.
79</p>
80
81<p>
82<table border=0>
83<tr><td valign="bottom">
84<?php
85echo $imgtag1;
86?>
87<br><b>Figure 1. </b>The included Bar CSIM graph.
88</p>
89</td>
90<td valign="bottom">
91<?php
92echo $imgtag2;
93?>
94<br><b>Figure 2. </b>The included Pie CSIM graph.
95</p>
96</td>
97</tr>
98</table>
99</body>
100</html>
Note: See TracBrowser for help on using the repository browser.