2009年5月24日 星期日

[php] Open Flash Chart

其實這篇可以不只是php XD
他還有perl, python, ruby, java, .NET的函式庫可以用 超級強大

Tutorial
Download
真的很強大阿XD

使用:
※OFC 2的版本我怎麼用都不對 怎麼搞都沒有畫面出來阿 囧
所以我就用了1.9.7 這個就夠漂亮夠我用啦~~

<?php
include_once("./open-flash-chart/php-ofc-library/open_flash_chart_object.php");
open_flash_chart_object( 600, 400, './open-flash-chart/chart-data.php', false );
?>


然後在/open-flash-chart裡面 create一個chart-data.php
內容:
<?
$bar = new bar_sketch( 55, 6, '#d070ac', '#000000' );
for( $i=0; $i<count($count); $i++ )
$bar->data[] .= $count[$i];

$g = new graph();
$g->title( 'performance', '{font-size:20px; color: #ffffff; margin:10px; background-color: #d070ac; padding: 5px 15px 5px 15px;}' );
$g->bg_colour = '#FDFDFD';

//
// add the bar object to the graph
//

$g->data_sets[] = $bar;

$g->x_axis_colour( '#e0e0e0', '#e0e0e0' );
$g->set_x_tick_size( 9 );
$g->y_axis_colour( '#e0e0e0', '#e0e0e0' );

$g->set_x_labels( $name );

$g->set_inner_background( '#E3F0FD', '#CBD7E6', 90 );
$g->set_y_max( 10 );
$g->y_label_steps( 2 );
echo $g->render();
?>


$count和$name是從資料庫抓的東西

這樣就好了 一個很可愛的長條圖 我喜歡阿!!

沒有留言:

張貼留言