KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Error returned on PieChart type graphs #3278

Closed TICGAL opened this topic on on Apr 9 - 1 comments

TICGAL commented on Apr 9

When one of the values is 0, the library returns the following error message:

Uncaught Exception DivisionByZeroError: Division by zero in /vendor/koolreport/chartjs/PieChart.php at line 58

The version of the library is 3.2.1 and the version of php is 8.1.2

KoolReport commented on Apr 15

I think the issue is when all the values are 0, not just one of them because the error happens when the sum of all values are 0. The simple way is to check the sum before enter data into chart to draw:

if($this->dataStore("yourStore")->sum("theColumnName")==0) {
    echo "No chart available"
} else {
    //Draw chart here
}

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
bug

ChartJS