主页 > 其他 > 将数据库中的信息图形显示

将数据库中的信息图形显示

2014年5月29日 将数据库中的信息图形显示无评论 阅读: 10,510 次

数据库:sqlite,图形引擎:SVGGraph,显示温度、湿度和时间数据:

<?php
require_once './SVGGraph/SVGGraph.php';

$dsn = 'sqlite:pi';
try{
$dbh = new pdo($dsn,$user,$password);

$dbh->beginTransaction();
$sth = $dbh->prepare('SELECT wen,shi,date FROM info order by num desc limit 50');
$sth->execute();
$result = $sth->fetchAll();
$settings=array(
'grid_division_h' => 10,
//'grid_division_v' => 2,
'axis_min_v' => 0,
//'show_axis_text_h'=> false,
//'axis_text_space_h'=>20,
//'axis_text_angle_h'=>20
);
$settings['structured_data'] = true;
$settings['structure'] = array(

'key' => 2,
'value' => array(0,1),
);

$graph = new SVGGraph(1000, 400,$settings);
//print_r($recordlist);
$dsn = null;
}catch (pdoexception $e){
echo 'Connection failed:'.$e->getmessage();
$dsn = null;
}

$graph->Values($result);

$graph->Render('MultiLineGraph');
?>

 

发表评论

新用户的评论需审核后才会显示;

电子邮件地址不会被公开;
必填项已用*标注