Charts - Scatter charts - Scatter Chart

Documentation: scatter.

This goes into the <head> of the page:

<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">

swfobject.embedSWF(
"open-flash-chart.swf", "my_chart",
"600", "400", "9.0.0", "expressInstall.swf",
{"data-file":"gallery/scatter-on-click.php", "id":"1"} );


function chart_click( chart_id, value )
{
alert( 'Chart '+chart_id +': '+ value );
}
</script>
This writes the chart into a div with id="my_chart", right click and view source to see it in action, [the tutorials have more details]

gallery/scatter-on-click.php
<?php

include '../php-ofc-library/open-flash-chart.php';
// also include the sugar (helper funtions)
include '../php-ofc-library/ofc_sugar.php';


function 
make_star($x$y$click)
{
    
$tmp = new star();
    
$tmp->position($x$y);
    
$tmp->on_click('chart_click');
    return 
$tmp;
}

$chart = new open_flash_chart();

$title = new titledate("D M d Y") );
$chart->set_title$title );

$scatter = new scatter'#FFD600'10 );
$scatter->set_default_dot_style( new s_star('#8B1D55'10) );
$scatter->set_values(
    array(
        
make_star00'0,0' )
        )
    );

$chart->add_element$scatter );


//
// plot a circle
//
$s2 = new scatter'#D600FF');
$s2->set_default_dot_style( new s_box('#D600FF'4) );

$v = array();
for( 
$i=0$i<360$i+=)
{
    
$v[] = new scatter_value(
        
number_format(sin(deg2rad($i)) *.92'.'''),
        
number_format(cos(deg2rad($i)) *.92'.''') );    
}
$s2->set_values$v );
//$chart->add_element( $s2 );

$x = new x_axis();
$x->set_range( -1);
$chart->set_x_axis$x );

$y = new x_axis();
$y->set_range( -1);
$chart->add_y_axis$y );


echo 
$chart->toPrettyString();
To see the data produced : gallery/scatter-on-click.php, then 'view source'.
Support This Project

Open Flash Chart logo by numb.me.uk. | Syntax highlights are by GeSHi