nav-left cat-right
cat-right

open-flash-chart系列教程(7)–PHP类库的用法

例子如下:


require_once('includes/open-flash-chart2/php-ofc-library/open-flash-chart.php');
$tmpx = array();//x轴标签的数组
$tmpy = array();//从数据库查询得到y轴数据的数组
 $title = new title( '年销售统计图表' );
    $title->set_style("font-size:18px;");

    $bar = new bar();
    $bar->text= $city;
    $bar->set_values( $tmpy );

    $y = new y_axis();
    $y->set_range(0,ceil(max($tmpy)),20);

    $x = new x_axis();
    $x->set_labels_from_array( $tmpx );

    $yl =  new y_legend();
    $yl->y_legend( "chinaticket.com chart 1:10000" );
    $yl->set_style( "color:#736AEF; font-size:12px;" );

    $chart = new open_flash_chart();
    $chart->set_title( $title );

    $chart->set_y_axis( $y );
    $chart->set_x_axis( $x );
    $chart->set_y_legend($yl);

    $chart->add_element($bar);

$chart->toString();//生成json数据
$chart->toPrettyString();//生成适合阅读的数据格式

具体那一种图表格式可以打开相对应的class文件查询相关的参数、函数,用法都比较简单的。

12 条评论 »