Location: PHPKode > projects > Monyet > plotter/jpgraph-2.2/src/Examples/balloonex2.php
include ("../jpgraph.php");
include ("../jpgraph_scatter.php");

// Each ballon is specificed by four values. 
// (X,Y,Size,Color)
$data = array(

// We need to create X,Y data vectors suitable for the
// library from the above raw data.
$n = count($data);
for( $i=0; $i < $n; ++$i ) {
    $datax[$i] = $data[$i][0];
    $datay[$i] = $data[$i][1];

    // Create a faster lookup array so we don't have to search
    // for the correct values in the callback function
    $format[strval($datax[$i])][strval($datay[$i])] = array($data[$i][2],$data[$i][3]);

// Callback for markers
// Must return array(width,border_color,fill_color,filename,imgscale)
// If any of the returned values are '' then the
// default value for that parameter will be used (possible empty)
function FCallback($aYVal,$aXVal) {
    global $format;
    return array($format[strval($aXVal)][strval($aYVal)][0],'',

// Setup a basic graph
$graph = new Graph(450,300,'auto');

$graph->title->Set("Example of ballon scatter plot with X,Y callback");

// Use a lot of grace to get large scales since the ballon have
// size and we don't want them to collide with the X-axis

// Make sure X-axis as at the bottom of the graph and not at the default Y=0

// Set X-scale to start at 0

// Create the scatter plot
$sp1 = new ScatterPlot($datay,$datax);

// Uncomment the following two lines to display the values

// Specify the callback

// Add the scatter plot to the graph

// ... and send to browser


Return current item: Monyet