该图的数据如下所示。
$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();
如何更改它以获得这样的情节。
答案 0 :(得分:1)
我从未使用甘特,但通过查看我可以猜测的代码 我保存了以前的标签并查看它是否与下一个标签匹配,如果是,我使用之前的数字和标签值。
$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();
试一试,看看它是否有效。