From d78d554a0de108eda768ec2ffe7a6560403ab9a0 Mon Sep 17 00:00:00 2001 From: Filippo Date: Mon, 31 Oct 2022 09:41:44 +0100 Subject: [PATCH] Update PieChart.php Fix for the following error (PHP version 8.1.2): PHP Fatal error: Unparenthesized a ? b : c ? d : e is not supported. Use either (a ? b : c) ? d : e or a ? b : (c ? d : e) in /libchart/classes/view/chart/PieChart.php on line 67 --- libchart/classes/view/chart/PieChart.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libchart/classes/view/chart/PieChart.php b/libchart/classes/view/chart/PieChart.php index f2e5119..0ee8144 100644 --- a/libchart/classes/view/chart/PieChart.php +++ b/libchart/classes/view/chart/PieChart.php @@ -64,9 +64,15 @@ protected function computeLayout() { * @return integer result of the comparison */ protected function sortPie($v1, $v2) { - return $v1[0] == $v2[0] ? 0 : - $v1[0] > $v2[0] ? -1 : - 1; + if ($v1[0] == $v2[0]) { + return 0; + } + + if ($v1[0] > $v2[0]) { + return -1; + } + + return 1; } /** @@ -264,4 +270,4 @@ public function render($fileName = null) { $this->plot->render($fileName); } } -?> \ No newline at end of file +?>