使用 pChart 我无法绘制少于 4 个值的条形图
以下代码使用 pChart,工作正常,但如果我将系列更改为少于 4 个值,我将没有得到任何返回,页面只是继续加载! 要重现该问题,只需取出该系列的最后一个数字: serie1 为 array(9,9,9),serie3 为 array(4,5,6)。
<?php
// Standard inclusions
include("pChart/pData.class");
include("pChart/pChart.class");
// Dataset definition
$DataSet = new pData;
$DataSet->AddPoint(array(9,9,9,10),"Serie1");
$DataSet->AddPoint(array(4,5,6,7),"Serie3");
$DataSet->AddAllSeries();
$DataSet->RemoveSerie("Serie3");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetSerieName("January","Serie1");
$DataSet->SetYAxisName("Temperature");
$DataSet->SetYAxisUnit("°C");
$DataSet->SetXAxisUnit("h");
// Initialise the graph
$Test = new pChart(350,230);
$Test->setGraphArea(10,20,240,220);
$Test->drawGraphArea(213,217,221,FALSE);
$Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,213,217,221,TRUE,0,2,TRUE);
// Draw the bar chart
$Test->drawBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),70);
// Render the picture
$Test->Stroke();
?>
The following code, that uses pChart, works fine, but if I change the series to have less than 4 values I don't get anything back, the page just keeps loading!
To reproduce the problem just take out the last numbers of the series:
array(9,9,9) for serie1 and array(4,5,6) for serie3.
<?php
// Standard inclusions
include("pChart/pData.class");
include("pChart/pChart.class");
// Dataset definition
$DataSet = new pData;
$DataSet->AddPoint(array(9,9,9,10),"Serie1");
$DataSet->AddPoint(array(4,5,6,7),"Serie3");
$DataSet->AddAllSeries();
$DataSet->RemoveSerie("Serie3");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetSerieName("January","Serie1");
$DataSet->SetYAxisName("Temperature");
$DataSet->SetYAxisUnit("°C");
$DataSet->SetXAxisUnit("h");
// Initialise the graph
$Test = new pChart(350,230);
$Test->setGraphArea(10,20,240,220);
$Test->drawGraphArea(213,217,221,FALSE);
$Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,213,217,221,TRUE,0,2,TRUE);
// Draw the bar chart
$Test->drawBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),70);
// Render the picture
$Test->Stroke();
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我用 pChart 1.27d 替换了 pChart 库版本 1.27b。这解决了问题。
所以这是旧库中的一个错误。
I replaced the pChart library version 1.27b with pChart 1.27d. This fixed the problem.
So it is a bug in the old library.