PHPを使用してGDライブラリを使用して管理パネルにグラフを表示したい..データベースから日付を取得しますが、ライブラリを使用してこの結果を折れ線グラフで表示すると、機能せず、エラーも表示されませんでした。私が間違ったことがわからないのですか?誰でも私を助けることができますか?
<?php
include ("../setting.php");
include("../classes/phpgraphlib.php");
$result = mysql_query("SELECT DATE_FORMAT(log_date, '%Y-%m-%d') as Date,count(*) as Count FROM log
where operation_type='Add' and user_id='82' and faculty_code='0' group by log_date order by log_date") or die(mysql_error());
$MultiDimArray = array();
$data = array();
while( $row = mysql_fetch_array($result , MYSQL_BOTH) )
{
$MultiDimArray[] = array ( 'Date' => $row['Date'], 'Count' => $row['Count'] );
}
foreach($MultiDimArray as $value)
{
if ( !array_key_exists($value['Date'], $data) ) {
$data[$value['Date']] = $value['Count'];
}
else{ $data[$value['Date']] += (string)$value['Count'];}
}
$data = array_map('strval', $data);
$graph = new PHPGraphLib(400,300);
$graph->addData($data);
$graph->setTitle("Site Statistics");
$graph->setBars(false);
$graph->setLine(true);
$graph->setDataPoints(true);
$graph->setDataPointColor("maroon");
$graph->setDatadata(true);
$graph->setDataValueColor("maroon");
$graph->setGoalLine(.0025);
$graph->setGoalLineColor("red");
$graph->setXdataHorizontal(true);
$graph->createGraph();
?> `
$data 配列の出力は次のようになります。
array'2013-05-13' => string '7' (length=1)'2013-05-15' => string '3' (length=1)'2013-05-16' => string '5' (length=1)'2013-05-18' => string '8' (length=1)'2013-05-19' => string '2' (length=1)'2013-05-21' => string '2' (length=1)'2013-05-22' => string '10' (length=2)'2013-05-23' => string '2' (length=1)'2013-05-25' => string '1' (length=1)'2013-05-26' => string '8' (length=1)'2013-05-27' => string '19' (length=2)'2013-05-28' => string '7' (length=1)'2013-05-29' => string '3' (length=1)'2013-06-02' => string '11' (length=2)'2013-06-03' => string '2' (length=1)'2013-06-04' => string '7' (length=1)'2013-06-05' => string '3' (length=1)'2013-06-06' => string '2' (length=1)'2013-06-09' => string '15' (length=2)'2013-06-10' => string '5' (length=1)'2013-06-11' => string '1' (length=1)'2013-06-12' => string '3' (length=1)'2013-06-15' => string '10' (length=2)'2013-06-16' => string '3' (length=1)'2013-06-19' => string '2' (length=1)