将生成好的JSON数据传递给前端,前端通过JS来实现切换效果
例子。
include '../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_2Don't forget to 'view source' to see how the Javascript JSON data is loaded.