【问题标题】:How to create a graph with jpgraph with random times on the x-axis如何使用 jpgraph 在 x 轴上创建具有随机时间的图形
【发布时间】:2012-11-16 20:57:55
【问题描述】:

我的数据由来自不同随机时间的仪表读数组成。

我想创建一个(线)图来显示仪表读数的变化,但是时间不规律 - 一天可能有 3 个,或者一周没有。

因此,我不确定如何最好地创建图表来显示这一点。由于时间的随机性,我不能按原样使用数据 - 如果读数之间是一周,则需要在 x 轴上表示为一周。

如果我给出一个任意的比例(例如,每个刻度 1 天),我不知道如何说“在这个刻度上没有数据”来说明哪里有差距。我也不确定我是否可以表示更小的粒度(例如,如果早上有一个,下午有一个,我认为它会出现在同一个地方,每个刻度为 1 天)

【问题讨论】:

    标签: php graph charts jpgraph


    【解决方案1】:

    我也有同样的问题。如果您检查类参考中的 LinePlot,您会看到您可以为 x 轴值设置第二个参数。显然,Y 轴和 X 轴数组必须具有相同数量的元素。我根据手册做了一些示例代码。该代码尚未经过测试,但它应该是这样工作的:

    function elevation_chart ($ydata, $xdata) {
      require_once('jpgraph/jpgraph.php');
      require_once('jpgraph/jpgraph_line.php');
      $width = 600; $height = 200;
      $graph = new Graph($width,$height);
      $graph->SetScale('intint');
      $graph->title->Set('Elevation profile');
      $graph->xaxis->title->Set('(Distance)');
      $graph->yaxis->title->Set('(Altitude)');
      $lineplot = new LinePlot($ydata, $xdata); //here you have to add $xdata as second argument
      $graph->Add($lineplot);
      $graph->Stroke();
    }
    

    【讨论】:

      猜你喜欢
      • 2021-11-09
      • 2017-09-14
      • 2021-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多