JPGraph第二轴不显示任何数据

时间:2016-05-07 11:31:37

标签: jpgraph

我还在学习JPGraph,但它是一个很棒的工具,但我发现它非常复杂。 无论如何,我可以绘制正确格式化X和Y轴的图形,但是当我添加Y2轴时,它会在右侧添加刻度,但不会显示数据。

感谢所有的帮助。

数据:

 [$chartXaxis    
  array (size=4) 
  0 => int 1456531200
  1 => int 1458345600
  2 => int 1460156400
  3 => int 1462057200][1]

  $chartYaxis
  array (size=4)
  0 => int 360
  1 => int 460
  2 => int 380
  3 => int 320

  $chartY2axis 
  array (size=4)
  0 => int 20
  1 => int 19
  2 => int 15
  3 => int 14

代码提取:

//set up X axis count
    $n = count($chartXaxis);
    $xmin = $chartXaxis[0];
    $xmax = $chartXaxis[$n-1];
//*******************************************************

    // Create the graph. These two calls are always required
    $graph = new Graph(500, 300);
    $graph->SetScale('datlin',0,0,$xmin,$xmax);

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

    // The labels should be formatted at dates with "Year-month"
    $graph->xaxis->SetLabelFormatString('My',true);

    $graph->title-> Set("Golf Scores Graph");

// Add a X-grid
    $graph->xgrid->Show();

// Create the linear plot
    $lineplot = new LinePlot($chartYaxis,$chartXaxis);
    $lineplot->SetColor('blue');

// Add the plot to the graph
    $graph->Add($lineplot);

    $graph->SetY2Scale('lin');
    $lineplot1 = new LinePlot($chartY2axis);
    $lineplot1->SetColor('red');
    $graph->AddY2($lineplot1);

//*******************************************************
    //set up filename
    $filename = "PersonChart".$PlayerKey.".png";

    // Get the handler to prevent the library from sending the
    // image to the browser
    $graph->Stroke($filename);

0 个答案:

没有答案