0

现在我的pchart周图是这样显示的,

在此处输入图像描述

但我想显示星期x-axis 12/2-8, 12/9-15('月'后跟'/'后跟'开始日期',然后是'-',然后是'结束日期')​​”

4

1 回答 1

1

您生成可以拥有的图例

$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 ;
}
于 2012-12-12T12:39:21.080 回答