Line | |
---|
1 | <?php // content="text/plain; charset=utf-8" |
---|
2 | require_once ('jpgraph/jpgraph.php'); |
---|
3 | require_once ('jpgraph/jpgraph_bar.php'); |
---|
4 | |
---|
5 | $data = array(0.1235,0.4567,0.67,0.45,0.832); |
---|
6 | |
---|
7 | // Callback function |
---|
8 | // Get called with the actual value and should return the |
---|
9 | // value to be displayed as a string |
---|
10 | function cbFmtPercentage($aVal) { |
---|
11 | return sprintf("%.1f%%",100*$aVal); // Convert to string |
---|
12 | } |
---|
13 | |
---|
14 | // Create the graph. |
---|
15 | $graph = new Graph(400,300); |
---|
16 | $graph->SetScale("textlin"); |
---|
17 | |
---|
18 | // Create a bar plots |
---|
19 | $bar1 = new BarPlot($data); |
---|
20 | |
---|
21 | // Setup the callback function |
---|
22 | $bar1->value->SetFormatCallback("cbFmtPercentage"); |
---|
23 | $bar1->value->Show(); |
---|
24 | |
---|
25 | // Add the plot to the graph |
---|
26 | $graph->Add($bar1); |
---|
27 | |
---|
28 | // .. and send the graph back to the browser |
---|
29 | $graph->Stroke(); |
---|
30 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.