[英]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.