Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mranner opened this issue Mar 22, 2019 · 1 comment

Comments

@mranner
Copy link

mranner commented Mar 22, 2019

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(
@koolphp
Copy link
Owner

koolphp commented Mar 25, 2019

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants