0
回答
Open Flash Chart 使用分享
华为云4核8G,高性能云服务器,免费试用   

近期找到一套免費又有超強功能的圖表軟體 Open Flash Chart

稍微修改一下該網站提供的範例,就可以在網頁上秀出如下曲線圖

貼上php程式碼
//if ($_POST["dip1024"]=="on")
//{ echo "dip use 1024x768
"; }
//echo "dip1680:".$_POST["dip1680"] . "
";
echo "t1:".$_POST["t1"] . "
";

//echo "byear:".$_POST["byear"] . "
";
//echo "max Temp.:" . $_POST["maxtemp"]."
";
}
include_once( '../ofc-library/open-flash-chart.php' );
include_once( '../sqlconf/conn.php' );

switch ($_POST["roomselect"])
{
case "room1":
$hd71id=0;
$roomname="ROOM 1";
break;
case "room2":
$hd71id=1;
$roomname="ROOM 2";
break;
case "room3":
$hd71id=2;
$roomname="ROOM 3";
break;
case "room4":
$hd71id=3;
$roomname="ROOM 4";
break;
case "room5":
$hd71id=4;
$roomname="ROOM 5";
break;
case "room6":
$hd71id=5;
$roomname="ROOM 6";
break;
case "room7":
$hd71id=6;
$roomname="ROOM 7";
break;
case "room8":
$hd71id=7;
$roomname="ROOM 8";
break;
case "room9":
$hd71id=8;
$roomname="ROOM 9";
break;
case "room10":
$hd71id=9;
$roomname="ROOM 10";
break;
case "room11":
$hd71id=10;
$roomname="ROOM 11";
break;
case "room12":
$hd71id=11;
$roomname="ROOM 12";
break;
case "room13":
$hd71id=12;
$roomname="ROOM 13";
break;
case "room14":
$hd71id=13;
$roomname="ROOM 14";
break;
case "room15":
$hd71id=14;
$roomname="ROOM 15";
break;
case "room16":
$hd71id=15;
$roomname="ROOM 16";
break;
case "room17":
$hd71id=16;
$roomname="ROOM 17";
break;
case "room18":
$hd71id=17;
$roomname="實驗室 1";
break;
case "room19":
$hd71id=18;
$roomname="實驗室 2";
break;
case "room20":
$hd71id=19;
$roomname="實驗室 3";
break;
}


$conn = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database, $conn);
$querysql = "SELECT * FROM hd71_v61 where savetime ";
$querysql .= " between '".$_POST["byear"]."-";
$querysql .= $_POST["bmonth"]."-";
$querysql .= $_POST["bday"]. " ";
$querysql .= $_POST["bhour"].":";
$querysql .= $_POST["bmin"].":00' and '";
$querysql .= $_POST["eyear"]."-";
$querysql .= $_POST["emonth"]."-";
$querysql .= $_POST["eday"]." ";
$querysql .= $_POST["ehour"].":";
$querysql .= $_POST["emin"].":59' and hd71id='";
$querysql .= $hd71id ."'";
if ($kdebug==1)
{ echo $querysql."
"; }

$rs = mysql_query($querysql, $conn) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
//
//
//t1 檢查t1是否被勾選
if (isset($_POST["t1"])){
if ($_POST["t1"] == "t1checked") {
$lineT1 = new line(1,'0x0099CC');
$lineT1->key('T1',10); }
}
//===================================================================================
//
//
//t2 檢查t2是否被勾選
if (isset($_POST["t2"])){
if ($_POST["t2"] == "t2checked") {
$lineT2 = new line(1,'0xCE0000');
$lineT2->key('T2',10); }
}
//===================================================================================
//
//
//
//t3 檢查t3是否被勾選
if (isset($_POST["t3"])){
if ($_POST["t3"] == "t3checked") {
$lineT3 = new line(1,'0x9900FF');
$lineT3->key('T3',10); }
}
//===================================================================================
//t4檢查t4是否被勾選
if (isset($_POST["t4"])){
if ($_POST["t4"] == "t4checked") {
$lineT4 = new line(1,'0x999999');
$lineT4->key('T4',10); }
}
//===================================================================================
//
//temm檢查temm是否被勾選
if (isset($_POST["temm"])){
if ($_POST["temm"] == "temmchecked") {
$lineTemm = new line(1,'0x009999');
$lineTemm->key('TEMM',10); }
}
//===================================================================================
//
//SETM 檢查 SETM 是否被勾選
if (isset($_POST["setm"])){
if ($_POST["setm"] == "setmchecked") {
$linesetm = new line(1,'0x000000');
$linesetm->key('SETM',10); }
}
//===================================================================================
//Pco2 檢查 pco2 是否被勾選
if (isset($_POST["pco2"])){
if ($_POST["pco2"] == "pco2checked") {
$linepco2 = new line(1,'0x0099CC');
$linepco2->key('PCO2',10); }
}
//===================================================================================
//setc 檢查 setc 是否被勾選
if (isset($_POST["setc"])){
if ($_POST["setc"] == "setcchecked") {
$linesetc = new line(1,'0x000000');
$linesetc->key('SETC',10); }
}
//===================================================================================
// TWET 檢查 TWET 是否被勾選
if (isset($_POST["twet"])){
if ($_POST["twet"] == "twetchecked") {
$linetwet = new line(1,'0x0000FF');
$linetwet->key('TWET',10); }
}
//===================================================================================
// HUMY 檢查 HUMY 是否被勾選
if (isset($_POST["humy"])){
if ($_POST["humy"] == "humychecked") {
$linehumy = new line(1,'0x0099CC');
$linehumy->key('HUMY',10); }
}
//===================================================================================
//$lineT9 = new line( 1, '0x9933CC'); //寬度,顏色
//KEY('T9',10); 'T9' 左上角說明文字 , 10 : 字型大小
//$lineT9->key( 'T9', 10 );

//$data = array();
$labels = array();

do
{
//
// -------------------------------------------------------------------------
if ($_POST["t1"] == "t1checked")
{ $lineT1->data[]=$row_rs['c5']; }
//--------------------------------------------------------------------------
//
//
// -------------------------------------------------------------------------
if ($_POST["t2"] == "t2checked")
{ $lineT2->data[]=$row_rs['c7']; }
//--------------------------------------------------------------------------
//
// -------------------------------------------------------------------------
if ($_POST["t3"] == "t3checked")
{ $lineT3->data[]=$row_rs['c9']; }
//--------------------------------------------------------------------------
//
// -------------------------------------------------------------------------
if ($_POST["t4"] == "t4checked")
{ $lineT4->data[]=$row_rs['cb']; }
//--------------------------------------------------------------------------
// -------------------------------------------------------------------------
if ($_POST["temm"] == "temmchecked")
{ $lineTemm->data[]=$row_rs['cd']; }
//--------------------------------------------------------------------------
// -------------------------------------------------------------------------
if ($_POST["setm"] == "setmchecked")
{ $linesetm->data[]=$row_rs['c1']; }
//--------------------------------------------------------------------------
// -------------------------------------------------------------------------
if ($_POST["pco2"] == "pco2checked")
{ $linepco2->data[]=$row_rs['d1']; }
//--------------------------------------------------------------------------
// -------------------------------------------------------------------------
if ($_POST["setc"] == "setcchecked")
{ $linesetc->data[]=$row_rs['c3']; }
//--------------------------------------------------------------------------
// -------------------------------------------------------------------------
if ($_POST["twet"] == "twetchecked")
{ $linetwet->data[]=$row_rs['d3']; }
//--------------------------------------------------------------------------
// -------------------------------------------------------------------------
if ($_POST["humy"] == "humychecked")
{ $linehumy->data[]=$row_rs['cf']; }
//--------------------------------------------------------------------------
//$lineT9->data[]=$row_rs['c5'];

$labels[] = $row_rs['savetime'];

} while ($row_rs = mysql_fetch_assoc($rs));

//--------------------------------------------------------------------
mysql_close($conn);

//
// ----
//
$g = new graph();
$m_title=$roomname . " 曲線圖".$_POST["byear"]."-".$_POST["bmonth"]."-";
$m_title .= $_POST["bday"]. " " . $_POST["bhour"].":" .$_POST["bmin"].":00 ~ ";
$m_title .= $_POST["eyear"]."-" . $_POST["emonth"]."-" . $_POST["eday"]." ";
$m_title .= $_POST["ehour"].":" . $_POST["emin"].":59";
$g->title( $m_title, '{font-size: 18px; color: #A0A0A0;}' );
//Default string is: "#x_label#
#val#" \n
//需要判斷目前顯示溫度,溼度%,co2(ppm)

$g->set_tool_tip( '#x_label#
#val#度' );

if ($_POST["pco2"] == "pco2checked")
{ $g->set_tool_tip( '#x_label#
#val#ppm' ); }
//-------------------------------------------------------------------------------------
if ($_POST["humy"] == "humychecked")
{ $g->set_tool_tip( '#x_label#
#val#%' ); }
//-------------------------------------------------------------------------------------
//

// set the X axis labels
$g->set_x_labels( $labels );

//$g->set_data( $data );
//$g->bar_sketch( 50, 6, '#99FF00', '#7030A0', '% Complete', 10 );

//
// add the bar object to the graph
//
//t1 若被checked , 秀出t1
//
if ($_POST["t1"] == "t1checked")
{ $g->data_sets[] = $lineT1; }
//--------------------------------------------------------------------

//t2 若被checked , 秀出t2
//
if ($_POST["t2"] == "t2checked")
{ $g->data_sets[] = $lineT2; }
//--------------------------------------------------------------------
//t3 若被checked , 秀出t3
//
if ($_POST["t3"] == "t3checked")
{ $g->data_sets[] = $lineT3; }
//--------------------------------------------------------------------
//t4 若被checked , 秀出t4
//
if ($_POST["t4"] == "t4checked")
{ $g->data_sets[] = $lineT4; }
//--------------------------------------------------------------------
//temm 若被checked , 秀出temm
//
if ($_POST["temm"] == "temmchecked")
{ $g->data_sets[] = $lineTemm; }
//--------------------------------------------------------------------
//setm 若被checked , 秀出setm
//
if ($_POST["setm"] == "setmchecked")
{ $g->data_sets[] = $linesetm; }
//--------------------------------------------------------------------
//pco2 若被checked , 秀出pco2
//
if ($_POST["pco2"] == "pco2checked")
{ $g->data_sets[] = $linepco2; }
//--------------------------------------------------------------------
//setc 若被checked , 秀出setc
//
if ($_POST["setc"] == "setcchecked")
{ $g->data_sets[] = $linesetc; }
//--------------------------------------------------------------------
//twet 若被checked , 秀出twet
//
if ($_POST["twet"] == "twetchecked")
{ $g->data_sets[] = $linetwet; }
//--------------------------------------------------------------------
//humy 若被checked , 秀出 humy
//
if ($_POST["humy"] == "humychecked")
{ $g->data_sets[] = $linehumy; }
//--------------------------------------------------------------------
//$g->data_sets[] = $lineT9;


$g->set_x_label_style( 8, '0x9933CC', 2 , 10 , '#00A000');

$g->set_y_label_style( 10, '#A0A0A0' );
$g->x_axis_colour( '#A0A0A0', '#FFFFFF' );

$g->set_x_legend( 'Time', 10, '#A0A0A0' ); //x軸標註 說明,字型大小,顏色
//--------------------------------------------------------------------------------------------------------------------------------
//需要判斷目前顯示溫度,溼度%,co2(ppm)
$g->set_y_legend( 'Temperature', 10, '#A0A0A0' ); //y軸標註
if ($_POST["pco2"] == "pco2checked")
{ $g->set_y_legend( 'ppm', 10, '#A0A0A0' ); }
if ($_POST["humy"] == "humychecked")
{ $g->set_y_legend( 'Percent', 10, '#A0A0A0' ); }
//-----------------------------------------------------------------------------------------------------------------------------
$g->y_axis_colour( '#A0A0A0', '#FFFFFF' );

//最低溫度可以變更設定
if (isset($_POST["mintemp"])){
$g->set_y_min( $_POST["mintemp"] );}
else {
$g->set_y_min( 0 );}
//=============================================================================
//最高溫度可以變更設定 $_POST["maxtemp"]
if (isset($_POST["maxtemp"]))
{ $g->set_y_max( $_POST["maxtemp"] ); }
else
{ $g->set_y_max( 110 );}
//==============================================================================
$g->y_label_steps( 10 );

$g->set_x_axis_steps( 10 );

//設定曲線圖長寬
$m_width=980;
$m_height=570;
switch ($_POST["dip"]) {
case 1024:
$m_width=980;
$m_height=570;
break;
case 1680:
$m_width=1560;
$m_height=880;
break;
default:
$m_width=980;
$m_height=570;
}
$g->set_width( $m_width );
$g->set_height( $m_height );
/*if (isset($_POST["dip"])){
if ($_POST["dip"]==1024)
{
$g->set_width( 980 );
$g->set_height( 570 );}
if ($_POST["dip"]==1680)
{
$g->set_width( 1560 );
$g->set_height( 880 );}
}
else
{
$g->set_width( 980 );
$g->set_height( 570 );
}*/
//-----------------------------------------------------
$g->set_js_path('../js/');
$g->set_swf_path('/');
$g->set_output_type('js');
echo $g->render();
?>
連線到資料庫抓取資料,就可以將文字資料圖形化,讓看的人相當容易就可以得到數據資訊,
而不是看到一堆文字,還真是好ㄚ!
天天都有不一樣的免費軟體,開放原碼軟體;
我們該為這個世界做些什麼呢?

举报
红薯
发帖于10年前 0回/2K+阅
顶部