open flash chart2 同一页显示两个图形的方式

abloz 2012-11-23
2012-11-23

周海汉 2012.11.23

一、chart2_1.php

同时显示两个图:

<?php

include ‘openflash/php-ofc-library/open-flash-chart.php’;

$title = new title( date(“D M d Y”) );

$bar = new bar(); $bar->set_values( array(9,8,7,6,5,4,3,2,1) ); $bar->set_colour( ‘#94D700’ );

$chart_1 = new open_flash_chart(); $chart_1->set_title( $title ); $chart_1->add_element( $bar ); $data_1 = $chart_1->toPrettyString(); // // CHART 2 // // generate some random data srand((double)microtime()*1000000);

$tmp = array(); for( $i=0; $i<9; $i++ ) $tmp[] = rand(1,10);

$bar_2 = new bar(); $bar_2->set_values( $tmp );

$chart_2 = new open_flash_chart(); $chart_2->set_title( new title( “Chart 2 :-)” ) ); $chart_2->add_element( $bar_2 ); // // $data_2 = $chart_2->toPrettyString(); // ?>

二、chart2_2.php

一次只显示一个图表,点击显示另一个图表,用javascript控制

<?php // // This is the MODEL section: // include ‘openflash/php-ofc-library/open-flash-chart.php’;

$title = new title( date(“D M d Y”) );

$bar = new bar(); $bar->set_values( array(9,8,7,6,5,4,3,2,1) );

$chart_1 = new open_flash_chart(); $chart_1->set_title( $title ); $chart_1->add_element( $bar ); // generate some random data srand((double)microtime()*1000000);

$tmp = array(); for( $i=0; $i<9; $i++ ) $tmp[] = rand(1,10);

$bar_2 = new bar(); $bar_2->set_values( $tmp );

$chart_2 = new open_flash_chart(); $chart_2->set_title( new title( “Chart 2 :-)” ) ); $chart_2->add_element( $bar_2 ); // // This is the VIEW section: //

?>

Open Flash Chart


display data_1 || display data_2

Don't forget to 'view source' to see how the Javascript JSON data is loaded.


如非注明转载, 均为原创. 本站遵循知识共享CC协议,转载请注明来源