http://teethgrinder.co.uk/open-flash-ch ... torial.php
1.拷貝 open-flash-chart.swf 及 js 目錄 及 php-ofc-library 至 apache 的根目錄
2.將 php-ofc-library 改名為 ofc-library
3.chart.php
<html>
<head>
<script></script>
<script>
swfobject.embedSWF("open-flash-chart.swf", "my_chart", "600", "400", "9.0.0");
</script>
</head>
<body>
<p>Hello World</p>
<div></div>
</body>
</html>
4.data.json
{
"title":{
"text": "大豐駕訓班",
"style": "{font-size: 20px; color:#0000ff; font-family: Verdana; text-align: center;}"
},
"y_legend":{
"text": "Open Flash Chart",
"style": "{color: #736AFF; font-size: 12px;}"
},
"elements":[
{
"type": "bar",
"alpha": 0.5,
"colour": "#9933CC",
"text": "Page views",
"font-size": 10,
"values" : [9,6,7,9,5,7,6,9,7]
},
{
"type": "bar",
"alpha": 0.5,
"colour": "#CC9933",
"text": "Page views 2",
"font-size": 10,
"values" : [6,7,9,5,7,6,9,7,3]
}
],
"x_axis":{
"stroke":1,
"tick_height":10,
"colour":"#d000d0",
"grid_colour":"#00ff00",
"labels": ["January","February","March","April","May","June","July","August","Spetember"]
},
"y_axis":{
"stroke": 4,
"tick_length": 3,
"colour": "#d000d0",
"grid_colour": "#00ff00",
"offset": 0,
"max": 20
}
}
5.看圖囉
http://127.0.0.1/chart.php??ofc=data.json
Open Flash Chart 使用
bar 圖不會出現
資料庫的數值要由文字轉為數字才畫的出來
define("RelativePath", "..");
define("PathToCurrentPage", "/ofc/");
include(RelativePath . "/Common.php");
include ("../php-ofc-library/open-flash-chart.php");
$query = "select s.same_trade,sum(r.person) as person from recruit_students r,same_trade s where r.same_trade_id = s.same_trade_id group by r.same_trade_id ";
$db->query($query);
while($db->next_record()){
$datay[] = round($db->f("person"));
$datax[] = $db->f("same_trade");
}
$title = new title("圖表");
$bar = new bar();
$bar->set_values( $datay );
$x = new x_axis();
$x->set_labels_from_array($datax);
$y = new y_axis();
$y->set_range( 0, 3000, 100 );
$chart = new open_flash_chart();
$chart->set_title( $title );
$chart->add_element( $bar );
$chart->set_x_axis( $x );
$chart->set_y_axis( $y );
echo $chart->toString();
define("RelativePath", "..");
define("PathToCurrentPage", "/ofc/");
include(RelativePath . "/Common.php");
include ("../php-ofc-library/open-flash-chart.php");
$query = "select s.same_trade,sum(r.person) as person from recruit_students r,same_trade s where r.same_trade_id = s.same_trade_id group by r.same_trade_id ";
$db->query($query);
while($db->next_record()){
$datay[] = round($db->f("person"));
$datax[] = $db->f("same_trade");
}
$title = new title("圖表");
$bar = new bar();
$bar->set_values( $datay );
$x = new x_axis();
$x->set_labels_from_array($datax);
$y = new y_axis();
$y->set_range( 0, 3000, 100 );
$chart = new open_flash_chart();
$chart->set_title( $title );
$chart->add_element( $bar );
$chart->set_x_axis( $x );
$chart->set_y_axis( $y );
echo $chart->toString();