【问题标题】:Multiple y axis in jpgraphjpgraph中的多个y轴
【发布时间】:2017-04-03 10:34:20
【问题描述】:

我在 PHP 中有一个用 jpg 图实现的多图:第一个图和第二个图具有相同的比例 e 左侧的轴,第三个图具有不同的比例或值范围,轴位于正确的。 附上代码:

  $width=700;
  $height=500;

// Create the graph and set a scale.
// These two calls are always required
$graph = new Graph($width, $height);

$graph->SetScale("intlin"); // X and Y axis
$graph->SetY2Scale("lin"); // Y2 axis
$theme_class=new UniversalTheme;

$graph->SetTheme($theme_class);
$graph->img->SetAntiAliasing(false);
$graph->title->Set('Filled Y-grid');
$graph->SetBox(false);

$graph->xaxis->title->Set("Days");
$graph->img->SetAntiAliasing();

// Create the first line
$p1 = new LinePlot($ydata1);
$graph->Add($p1);
$p1->SetColor("#0033FF");
$p1->SetLegend('Rain');

// Create the second line
$p2 = new LinePlot($ydata2);
$graph->Add($p2);
$p2->SetColor("#33FFFF");
$p2->SetLegend('Irrigation');

// Create the third line
$p3 = new LinePlot($ydata3);
$graph->AddY2($p3);
$p3->SetColor("#000000");
$p3->SetLegend('Relative Soil Moisture');

$graph->legend->SetFrameWeight(0);

// Setup a title for the graph
$graph->title->Set($titolo);
$nome_img=substr($titolo, 0, -10);

// Display the graph
$graph->Stroke("tmp/graph_$nome_img.png");

echo "<img src=\"tmp/graph_$nome_img.png\"> ";

我只有左边的轴,右边的轴没有出现。您会看到所附图像。 有什么错误吗? 谢谢。

【问题讨论】:

    标签: php jpgraph


    【解决方案1】:

    我认为,您必须设置图表的边距,所以请查看您的比例。有没有,只是不可见:

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

    【讨论】:

      猜你喜欢
      • 2014-06-08
      • 2013-04-29
      • 2012-09-06
      • 2014-03-06
      • 1970-01-01
      • 1970-01-01
      • 2018-01-11
      • 2012-05-12
      • 1970-01-01
      相关资源
      最近更新 更多