【问题标题】:JPGraph adding series values togetherJPGraph 将系列值加在一起
【发布时间】:2011-03-31 20:03:37
【问题描述】:

我确定我在这里做了一些愚蠢的事情,但有人可以解释为什么 jpgraph 将两个系列值相加吗?我专门讨论的是值 $a1[3] 和 $a2[3] 以及 $a1[10] 和 $a2[10] 被加在一起。可以see the graphs here,代码贴在下面:

<?php
require_once ('src/jpgraph.php');
require_once ('src/jpgraph_date.php');
require_once ('src/jpgraph_line.php');

$x = array(
'8/4/2010',
'8/5/2010',
'8/6/2010',
'8/10/2010',
'8/11/2010',
'8/12/2010',
'8/13/2010',
'8/14/2010',
'8/15/2010',
'8/16/2010',
'8/17/2010');


$a1 = array(
'474',
'18113',
'14420',
'16651',
'11129',
'12112',
'14441',
'0',
'0',
'10206',
'11702');

$a2 = array(
'0',
'0',
'0',
'8003',
'0',
'504',
'0',
'9204',
'783',
'0',
'7892'
);

// Create the graph. 
$graph  = new Graph(600, 400);
$graph->title->Set('A2');
$graph->SetScale('intlin');
$graph->SetMargin(60,30,60,120);
$graph->xaxis->SetTickSide(SIDE_BOTTOM);
$graph->yaxis->SetTickSide(SIDE_LEFT);

$p0 =new LinePlot($a1);
$p0->value->Show();
$p0->SetLegend('A1');
$p0->setWeight( 3 );
$p0->SetColor('red');

$p1 =new LinePlot($a2);
$p1->value->Show();
$p1->SetLegend('A2');
$p1->setWeight( 3 );
$p1->SetColor('blue');


$ap = new AccLinePlot(array($p1, $p0));

$graph->xaxis->SetTickLabels($x);
$graph->xaxis->SetTextLabelInterval(4);
$graph->Add($ap);
$graph->xaxis->SetLabelAngle(90); 
$graph->Stroke();

【问题讨论】:

    标签: php graphics jpgraph


    【解决方案1】:

    我认为您缺少图表->添加。请尝试以下操作:

    $p0 = new LinePlot($a1);
    $p0->value->Show();
    $p0->SetLegend('A1');
    $p0->setWeight( 3 );
    $p0->SetColor('red');
    $graph->Add($p0);
    
    $p1 = new LinePlot($a2);
    $p1->value->Show();
    $p1->SetLegend('A2');
    $p1->setWeight( 3 );
    $p1->SetColor('blue');
    $graph->AddY(0,$p1);
    $graph->ynaxis[0]->SetColor('blue');
    
    $graph->Stroke();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-15
      • 1970-01-01
      • 1970-01-01
      • 2017-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多