Open Flash Chart For PHP
OFC是一款功能强大的Flash图表控件,
网上有诸多关于它的介绍,其中官方还提供了Java/Perl/Php/.Net的相关类。
以前就想在asp.net环境下使用这款控件,但由于缺乏文档,官方的介绍比较少,一直没有真正去使用它提供的c#类库。
今天又重拾这款控件,不过是在php环境下。
可以在这里下载PHP类:
http://teethgrinder.co.uk/open-flash-chart/perl-python.php
官方上提供的数据源大多是已经格式化好的.txt文件,但在实际运用的环境中,基本上是从数据库中读取数据再展示。
展示部分基本上搞定了,但目前还不知道如何去添加onclick事件。
先看在线的demo
http://demo.yibin001.com/chart/chart.php
数据是随机生成的,
<?php
date_default_timezone_set('PRC');
require_once('ofc_library/open-flash-chart.php');
$tmpx = array(); //X轴数据
$i = 0;
for($i=0;$i<24;$i++)
{
$tmpx[] = "{$i}时";
}
$tmpy = array(); //Y轴数据
$bar2_arr = array();
$i = 1;
while($i<25)
{
$tmpy[] = rand(20,180);
$bar2_arr[] = rand(25,120);
$i++;
}
$title = new title( date('r') );
$title->set_style("font-size:12px;");
$bar = new bar_glass();
$bar->text= '访问量';
$bar->set_values( $tmpy );
$bar->set_tooltip('访问量:<br>#val#');
$bar->set_alpha('0.3');
$bar2 = new bar_glass();
$bar2->text='IP';
$bar2->set_values($bar2_arr);
$bar2->set_colour('#FF0000');
$bar2->set_tooltip('IP<br>#val#');
$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( "www.yibin001.com" );
$yl->set_style( "color:#000; font-size:11px;" );
$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->add_element($bar2);
echo $chart->toPrettyString();
?>
哪位达人告诉我如何添加事件-,-
ps. google pagerank今天好像更新了,yibin001.com从3到了4,自把lemongtree.com做了301跳转后,lemongtree.com成0了。
Good job and nice site….. :up: