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