2017-02-09 4 views
1

は穏やかなX軸上の値..Pchartは、二重X軸上に印刷された値のRPI結果にpchartを使用してチャートを印刷するために以下のコードを使用して二重

を印刷します。

私の好ましい結果は、わずかに回転した単一のx軸の値ですが、下のコードで変更したものは良い結果を得ません。

ご了承ください。自分の間違いを発見されました

モーリス

<?php 

ini_set('display_errors', 'On'); 
error_reporting(E_ALL | E_STRICT); 

include("class/pDraw.class.php"); 
include("class/pImage.class.php"); 
include("class/pData.class.php"); 

$db = new PDO("sqlite:/home/pi/sensor.db"); 

$MyData = new pData(); 

$tijd=""; 
$lucht=""; 

$result = $db->query('SELECT tijd, lucht FROM waarden WHERE lucht > 40'); 
foreach($result as $row) 
{ 
    $tijd[] = $row["tijd"]; 
    $lucht[] = $row["lucht"]; 
} 

$MyData->addPoints($lucht,"lucht"); 
$MyData->setSerieOnAxis("lucht", 0); 
$MyData->setAxisName(0,"lucht"); 
$MyData->setAxisUnit(0,"%"); 

$MyData->addPoints($tijd,"tijd"); 
$MyData->setSerieDescription("tijd","Tijden"); 
$MyData->setAbscissa("tijd"); 

$myPicture = new pImage(800,330,$MyData); 
$myPicture->setFontProperties(array("FontName"=>"fonts/Forgotte.ttf","FontSize"=>11)); 
$myPicture->setGraphArea(60,40,740,290); 
$myPicture->drawScale(array("AutoAxisLabels"=>FALSE,"RemoveXAxis"=>FALSE)); 
$myPicture->drawLineChart(); 

//rotate the xaxis values 
$myPicture->drawScale(array("DrawSubTicks"=>False, "LabelRotation"=>20)); 

$myPicture->autoOutput("mypic.png"); 
$db = null; 
?> 

enter image description here

答えて

0

に思える私の二重の命令

$myPicture->drawScale(array(" 
時の初期化で

とあまりうまく処理されないと、その二重のX軸ラベル

で結果正しいコード:

<?php 

ini_set('display_errors', 'On'); 
error_reporting(E_ALL | E_STRICT); 

include("class/pDraw.class.php"); 
include("class/pImage.class.php"); 
include("class/pData.class.php"); 

$db = new PDO("sqlite:/home/pi/sensor.db"); 

$MyData = new pData(); 

$tijd=""; 
$lucht=""; 

$result = $db->query('SELECT tijd, lucht FROM waarden WHERE lucht > 40'); 
foreach($result as $row) 
{ 
    $tijd[] = $row["tijd"]; 
    $lucht[] = $row["lucht"]; 
} 

$MyData->addPoints($lucht,"lucht"); 
$MyData->setSerieOnAxis("lucht", 0); 
$MyData->setAxisName(0,"lucht"); 
$MyData->setAxisUnit(0,"%"); 

$MyData->addPoints($tijd,"tijd"); 
$MyData->setAbscissa("tijd"); 
$MyData->setAbscissaName("Time of Reading"); 

$myPicture = new pImage(800,330,$MyData); 
$myPicture->setFontProperties(array("FontName"=>"fonts/Forgotte.ttf","FontSize"=>11)); 
$myPicture->setGraphArea(60,40,740,290); 

//Remove line below to avoid double Xaxis values 
//$myPicture->drawScale(array("AutoAxisLabels"=>FALSE,"RemoveXAxis"=>FALSE)); 
$myPicture->drawScale(array("DrawSubTicks"=>False, "LabelRotation"=>20)); 
$myPicture->drawLineChart(); 
$myPicture->autoOutput("mypic.png"); 
$db = null; 
?> 
関連する問題