koolreport icon indicating copy to clipboard operation
koolreport copied to clipboard

GoogleChart: get type from column definition to support date string representation

Open mranner opened this issue 6 years ago • 1 comments

You only take the label for the column defintion in Chart::prepareData(), so you cannot support date string representation for hAxis and therefore no trendlines.

With this patch, you will also respect the type definition from columns, allowing us to format datetime as date string representation, which is necessary for trendlines on datetime based datasets.

Index: vendor/koolphp/koolreport/src/widgets/google/Chart.php
===================================================================
--- vendor/koolphp/koolreport/src/widgets/google/Chart.php      (revision 4508)
+++ vendor/koolphp/koolreport/src/widgets/google/Chart.php      (working copy)
@@ -183,7 +183,11 @@
         $header = array();
         $columnExtraRoles = array("annotation", "annotationText", "certainty", "emphasis", "interval", "scope", "style", "tooltip");
         foreach ($columns as $cKey => $cSetting) {
-            array_push($header, "" . Utility::get($cSetting, "label", $cKey));
+                       $header_column = [ 'label' => "" . Utility::get($cSetting, "label", $cKey) ];
+                       if ($type = Utility::get($cSetting, "type", $cKey)) {
+                               $header_column['type'] = $type;
+                       }
+            array_push($header, $header_column);
             foreach ($columnExtraRoles as $cRole) {
                 if (isset($cSetting[$cRole])) {
                     array_push(

mranner avatar Mar 22 '19 12:03 mranner

Thank you very much!

koolphp avatar Mar 25 '19 08:03 koolphp