Skip to content

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

Description

@mranner

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(

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions