2013-05-06 85 views
0

嗨,我一直在努力製作我想要的圖表,並且我正在變得非常接近。jpgraph雙Y軸問題

首先,我有一個應該在YAXIS#1上的股票投資組合的業績數據......這很好。 然後我想在YAXIS#2 ...行情節工作的標杆,但規模是怪異:

enter image description here

注意它是如何開始於50和10進,15,20,等等。 。 事情是規模應該在3400和3800之間,因爲這是我的數據範圍。

這裏是我的代碼:

<?php // content="text/plain; charset=utf-8" 
require($_SERVER['DOCUMENT_ROOT'] . '/wp-blog-header.php'); 
require_once ('jpgraph.php'); 
require_once ('jpgraph_line.php'); 
require_once ('jpgraph_date.php'); 
require_once ('jpgraph_utils.inc.php'); 

// Get a dataset 
$data = get_transient('daily_nav'); 
$ydata = $data[1]; 
$xdata = $data[0]; 

$data2 = get_transient('CAC40_history'); 
$ydata2 = array_reverse($data2[1]); 
$xdata2 = array_reverse($data2[0]); 


$dateUtils = new DateScaleUtils(); 
list($tickPositions, $minTickPositions) = DateScaleUtils::GetTicks($xdata); 

// Setup a basic graph 
$width=800; $height=500; 
$graph = new Graph($width, $height); 
$graph->SetScale('datlin'); 

$graph->SetYScale(0,'lin'); 
$graph->SetYScale(1,'lin'); 

$graph->SetMargin(60,20,40,60); 
$graph->xaxis->SetPos('min'); 
$graph->xaxis->SetTickPositions($tickPositions,$minTickPositions); 

// Setup the titles 
$graph->title->SetFont(FF_GEORGIA,FS_NORMAL,16); 
$graph->title->Set('Performance vs. CAC40'); 
$graph->subtitle->SetFont(FF_ARIAL,FS_ITALIC,10); 
$graph->subtitle->Set('graphique journalier depuis la création en juin 2012'); 

// Setup the labels to be correctly format on the X-axis 
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8); 
$graph->xaxis->SetLabelAngle(30); 

// The second paramter set to 'true' will make the library interpret the 
// format string as a date format. We use a Month + Year format m-d-Y 
$graph->xaxis->SetLabelFormatString('m-Y',true); 


// And then add line. We use two plots in order to get a 
// more distinct border on the graph 
$lp2 = new LinePlot($ydata,$xdata); 
$lp2->SetColor('#71a7da'); 
$graph->Add($lp2); 
$graph->xgrid->Show(); 
$graph->AddY(0,$lp2); 

// second chart 
$lp3 = new LinePlot($ydata2, $xdata2); 
$lp3->SetColor('blue'); 
//$graph->Add($lp3); 
//$graph->xgrid->Show(); 
$graph->AddY(1,$lp3); 


// And send back to the client 
$graph->Stroke(); 
?> 

將是巨大的,如果有人能幫助,想不通這一個。 謝謝

回答

0

我是一個新手,但一分鐘前自己也有同樣的問題。 缺少右邊的零?嘗試更改保證金設置?

$ graph-> SetMargin(60,50 ,40,60);