With pChart I can't draw barchart with less than 4 values

711 Views Asked by At

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();
?>
1

There are 1 best solutions below

0
On BEST ANSWER

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.