Php pChart,如何用月份显示周开始或结束日期,如;12/2-8“;在x轴上?
现在我的Php pChart,如何用月份显示周开始或结束日期,如;12/2-8“;在x轴上?,php,pchart,Php,Pchart,现在我的pchartweek图形显示如下 但是我想 在x轴12/2-8、12/9-15上显示周('month'后跟'/'后跟'start date',后跟'-',然后是'end date')”您可以生成图例 $weekLegend = getWeekLegend(); var_dump($weekLegend); // for debug purpose 输出 array (size=8) 0 => string '12/09-15' (length=8) 1 => s
pchart
week图形显示如下
但是我想
在x轴12/2-8、12/9-15上显示周('month'后跟'/'后跟'start date',后跟'-',然后是'end date')”您可以生成图例
$weekLegend = getWeekLegend();
var_dump($weekLegend); // for debug purpose
输出
array (size=8)
0 => string '12/09-15' (length=8)
1 => string '12/16-22' (length=8)
2 => string '12/23-29' (length=8)
3 => string '12/30-05' (length=8)
4 => string '01/06-12' (length=8)
5 => string '01/13-19' (length=8)
6 => string '01/20-26' (length=8)
7 => string '01/27-02' (length=8)
将其添加到数据集定义中
// Dataset definition
$DataSet = new pData;
$DataSet->AddPoint($data,"Serie1");
$DataSet->AddPoint(getWeekLegend(),"Serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("Serie2"); //<------ set pChat to use legend
function getWeekLegend($week = 8) {
$start = new DateTime();
$start->modify("last sunday");
while ( $week > 0 ) {
$date = $start->format("m");
$date .= "/";
$date .= $start->format("d");
$date .= "-";
$start->modify("+6 day");
$date .= $start->format("d");
$start->modify("+1 day");
$weekLegend[] = $date;
$week --;
}
return $weekLegend ;
}