【问题标题】:JPGraph: Not Plotting line with xy dataJPGraph:没有用 xy 数据绘制线
【发布时间】:2015-07-18 14:23:26
【问题描述】:

我已经开始使用 JPGraph 并尝试了以下简单的线图示例。我只添加了一个新变量 $xdata 来绘制 xy 图。但是,它没有绘制正确的图形(x 轴上的值显示为 1、2、3、4,因此,不代表 $xdata 中的值)。此外,y 值显示不正确。

如果我在没有 x 轴值的情况下进行绘图,则绘图工作正常,即 $p1 = new LinePlot($datay1);

  <?php // content="text/plain; charset=utf-8"
        require_once ('jpgraph/jpgraph.php');
        require_once ('jpgraph/jpgraph_line.php');

        $datay1 = array(20,15,23,15);
        $datay2 = array(12,9,42,8);
        $datax = array(0,10,20,30);

        // Setup the graph
        $graph = new Graph(300,250);
        $graph->SetScale("textlin");

        $theme_class=new UniversalTheme;

        $graph->SetTheme($theme_class);
        $graph->img->SetAntiAliasing(false);
        $graph->title->Set('Filled Y-grid');
        $graph->SetBox(false);
        $graph->img->SetAntiAliasing();
        $graph->yaxis->HideZeroLabel();
        $graph->yaxis->HideLine(false);
        $graph->yaxis->HideTicks(false,false);

        $graph->xgrid->Show();
        $graph->xgrid->SetLineStyle("solid");
        $graph->xgrid->SetColor('#E3E3E3');

        // Create the first line
        $p1 = new LinePlot($datay1,$datax);
        $graph->Add($p1);
        $p1->SetColor("#6495ED");
        $p1->SetLegend('Line 1');

        // Create the second line
        $p2 = new LinePlot($datay2,$datax);
        $graph->Add($p2);
        $p2->SetColor("#B22222");
        $p2->SetLegend('Line 2');

        $graph->legend->SetFrameWeight(1);
        // Output line
        $graph->Stroke();
      ?>

【问题讨论】:

    标签: php jpgraph


    【解决方案1】:

    对于 xy 数据,我建议使用 ScatterPlot:

    http://jpgraph.net/download/manuals/chunkhtml/ch15s05.html

    【讨论】:

      猜你喜欢
      • 2017-10-21
      • 2020-08-07
      • 1970-01-01
      • 2011-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-21
      • 1970-01-01
      相关资源
      最近更新 更多