繁体   English   中英

具有非连续时间值的jpgraph甘特图

[英]jpgraph gantt chart with non continuous time values

通过阅读我管理的文档,确实可以绘制出这样的图。 在此处输入图片说明

该图的数据如下所示。

$data = array(
    array(0,"  Label 1", "2001-01-26 04:00","2001-01-26 14:00"),
    array(1,"  Label 2", "2001-01-26 10:00","2001-01-26 18:00"),
    array(2,"  Label 3", "2001-01-26","2001-01-26 10:00"),
    array(3,"  Label 3", "2001-01-26 13:20","2001-01-26 16:00")
);


for($i=0; $i<count($data); ++$i) {
    $bar = new GanttBar($data[$i][0],$data[$i][1],$data[$i][2],$data[$i][3],"",10);
    if( count($data[$i])>4 )
        $bar->title->SetFont($data[$i][4],$data[$i][5],$data[$i][6]);

    $graph1->Add($bar);
}

$graph1->Stroke();

我如何更改它以具有这样的情节。

在此处输入图片说明

我从未使用过甘特图,但是通过查看代码,我可以做出一个猜测。
我保存了上一个标签,然后查看它是否与下一个标签匹配,如果是,则使用数字和标签的前一个值。

$data = array(
    array(0,"  Label 1", "2001-01-26 04:00","2001-01-26 14:00"),
    array(1,"  Label 2", "2001-01-26 10:00","2001-01-26 18:00"),
    array(2,"  Label 3", "2001-01-26","2001-01-26 10:00"),
    array(3,"  Label 3", "2001-01-26 13:20","2001-01-26 16:00")
);
$prev ="";

for($i=0; $i<count($data); ++$i) {
    If($prev == $data[$i][1]){
        // Grab previous number and label.
        $bar = new GanttBar($data[$i-1][0],$data[$i-1][1],$data[$i][2],$data[$i][3],"",10);
    }Else{
        $bar = new GanttBar($data[$i][0],$data[$i][1],$data[$i][2],$data[$i][3],"",10);
    }
    if( count($data[$i])>4 )
        $bar->title->SetFont($data[$i][4],$data[$i][5],$data[$i][6]);

    $graph1->Add($bar);
    $prev = $data[$i][1]; // Label
}

$graph1->Stroke();

试试看,看看是否可行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM