0
我想使用pChart來呈現樣本值與日期的簡單線圖。我有基本的工作,但我該如何處理日期的差距?樣本已經平均到四分之一年,但不是每個季度都有樣本。有時它會跳過四分之一或二分之一。帶間隙的pChart時間軸
當前,這些間隙在X軸上被一個接一個地壓縮,而不是按照它們在數字行中的自然順序間隔開。
數據來自MySQL數據庫。我可能錯過了一些簡單的東西。誰能幫忙?
#Array variables.
$date = "";
$value = "";
#Fetch the database rows, and sort them into arrays.
while ($row = mysql_fetch_array($result))
{
$date[] = $row["date"];
$value[] = $row["value"];
}
#Create a chart data object.
$MyData = new pData();
#Pass the data to the chart.
$MyData->addPoints($date, "Date");
$MyData->addPoints($value, "Value");
#Configure labels.
$MyData->setAxisName(0,"Value");
#Set the date as the X axis.
$MyData->setAbscissa("Date");
$MyData->setAbscissaName("Date");
這可能取決於你的MSQL查詢 - 這是因爲'值'可能會返回NULL例如?在這種情況下,您可以使用pChart的'VOID'關鍵字來填充空值。 – MackieeE