From 1bd1614381bcaf439cc9e1d5fea6c44e04768351 Mon Sep 17 00:00:00 2001 From: KoolPHPSupport Date: Fri, 20 Apr 2018 16:14:30 +0700 Subject: [PATCH] v2.43.0 Fix: issue with GoogleChart when working with numeric column but in string form. --- composer.json | 2 +- koolreport/CHANGELOG.md | 3 +++ koolreport/composer.json | 2 +- koolreport/processes/CalculatedColumn.php | 5 ++++- koolreport/widgets/google/Chart.php | 14 ++++++++++---- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 909e3e5..d2afa66 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "koolphp/koolreport", - "version":"2.42.0", + "version":"2.43.0", "description": "An Open Source PHP Reporting Framework for easier and faster report delivery.", "keywords": ["php reporting framework","php reporting tools","data processing","data visualization","charts and graphs"], "homepage": "https://www.koolreport.com", diff --git a/koolreport/CHANGELOG.md b/koolreport/CHANGELOG.md index c6a08f1..6cfd114 100644 --- a/koolreport/CHANGELOG.md +++ b/koolreport/CHANGELOG.md @@ -1,3 +1,6 @@ +# Version 2.43.0 + 1. Fix issue with GoogleChart when working with numeric column but in string form. + # Version 2.42.0 1. Change namespace `::class` to use classname in string so that `KoolReport` is compatible with PHP 5.4 2. `PdoDataSource`: Fix `charset` issue with `PostgreSQL` diff --git a/koolreport/composer.json b/koolreport/composer.json index 19c6769..ab8bf29 100644 --- a/koolreport/composer.json +++ b/koolreport/composer.json @@ -1,6 +1,6 @@ { "name": "KoolReport", - "version":"2.42.0", + "version":"2.43.0", "description": "An Open Source PHP Reporting Framework for easier and faster report delivery", "keywords": ["php reporting framework","php reporting tools","data reporting","charts and graphs"], "homepage": "https://www.koolreport.com", diff --git a/koolreport/processes/CalculatedColumn.php b/koolreport/processes/CalculatedColumn.php index ce302f8..ae4629a 100644 --- a/koolreport/processes/CalculatedColumn.php +++ b/koolreport/processes/CalculatedColumn.php @@ -84,6 +84,7 @@ protected function onMetaReceived($metaData) protected function onInput($data) { + // print_r($data); $this->rowNum++; foreach($this->params as $cKey=>$cValue) { @@ -91,13 +92,15 @@ protected function onInput($data) { case "string": $expression = $cValue["exp"]; + // echo $expression . ' || '; foreach($data as $k=>$v) + if (is_string($v) || is_numeric($v)) { $expression = str_replace("{".$k."}",$v,$expression); } //predefined row $expression = str_replace("{#}",$this->rowNum,$expression); - + // echo $expression . '
'; eval('$data[$cKey]='.$expression.';'); break; case "object": diff --git a/koolreport/widgets/google/Chart.php b/koolreport/widgets/google/Chart.php index a4fe176..2f252ec 100644 --- a/koolreport/widgets/google/Chart.php +++ b/koolreport/widgets/google/Chart.php @@ -202,12 +202,18 @@ protected function prepareData() $gRow = array(); foreach($columns as $cKey=>$cSetting) { - $fValue = Utility::format($row[$cKey],$cSetting); + $value = $row[$cKey]; + $cType = Utility::get($cSetting,"type","unknown"); + if($cType==="number") + { + $value = floatval($value); + } + $fValue = Utility::format($value,$cSetting); array_push($gRow, - ($fValue===$row[$cKey])? - $row[$cKey]: - array("v"=>$row[$cKey],"f"=>$fValue) + ($fValue===$value)? + $value: + array("v"=>$value,"f"=>$fValue) ); foreach($columnExtraRoles as $cRole)