iCE Breakers Matrix :: Open Flash Charts
Open Flash Charts Project
AJAX 'Live-Data' with Open Flash Charts
JavaScript
var timerID = 0; function reload() { if (timerID) { clearTimeout(timerID); } tmp = findSWF("chart"); x = tmp.reload("data.php"); timerID = setTimeout("reload()", 3000); } function findSWF(movieName) { if (navigator.appName.indexOf("Microsoft")!= -1) { return window[movieName]; } else { return document[movieName]; } } timerID = setTimeout("reload()", 3000);
PHP (index.php)
include_once('open_flash_chart_object.php'); open_flash_chart_object( 600, 250, 'http://'. $_SERVER['SERVER_NAME'] .'/~icebrkr/ofc/data.php', false );
PHP (data.php)
include_once('open_flash_chart.php'); srand((double)microtime()*1000000); $bar_1 = new bar_glass( 55, '#D54C78', '#C31812' ); $bar_1->key( '2006', 10 ); // add 10 bars with random heights for ($i = 0; $i < 10; $i++) { $bar_1->data[] = rand(2,25); } // // create a 2nd set of bars: // $bar_2 = new bar_glass( 155, '#5E83BF', '#424581' ); $bar_2->key( '2007', 10 ); // make 10 bars of random heights for ($i = 0; $i < 10; $i++) { $bar_2->data[] = rand(5,29); } // // create the chart: // $g = new graph(); $g->title( 'Widgets', '{ font-size:20px; color: #bcd6ff; margin:5px; background-color: #5E83BF; padding: 5px 25px 5px 25px;}' ); // add both sets of bars: $g->data_sets[] = $bar_1; $g->data_sets[] = $bar_2; // label the X axis (10 labels for 10 bars): $g->set_x_labels( array( 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sept,Oct' ) ); // colour the chart to make it pretty: $g->x_axis_colour( '#909090', '#D2D2FB' ); $g->y_axis_colour( '#909090', '#D2D2FB' ); $g->set_y_min( 0 ); $g->set_y_max( 50 ); $g->y_label_steps( 5 ); $g->set_y_legend( 'Open Flash Chart', 12, '#736AFF' ); echo $g->render();
iCE Breakers Matrix :: Open Flash Charts
Open Flash Charts Project