0

嗨,所以我一直在努力制作我想要的图表,我已经非常接近了。

首先,我有应该在 YAXIS #1 上的股票投资组合的业绩数据……这很好。然后我想在 YAXIS #2 上做一个基准测试……线图有效,但比例很奇怪:

在此处输入图像描述

请注意它是如何从 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();
?>

如果有人可以提供帮助,那就太好了,无法弄清楚这一点。谢谢

4

1 回答 1

0

我是一个新手,但一分钟前我自己也遇到了同样的问题。右边少了零?尝试更改边距设置?

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

于 2013-09-25T18:53:25.787 回答