Skip to content

Instantly share code, notes, and snippets.

@tajmorton
Created December 30, 2013 03:32
Show Gist options
  • Save tajmorton/8177481 to your computer and use it in GitHub Desktop.
Save tajmorton/8177481 to your computer and use it in GitHub Desktop.
Adds support for vAxis, hAxis, and legend options to php-report.
diff --git a/classes/headers/ChartHeader.php b/classes/headers/ChartHeader.php
index cdbe6f2..c1ab410 100644
--- a/classes/headers/ChartHeader.php
+++ b/classes/headers/ChartHeader.php
@@ -80,7 +80,19 @@ class ChartHeader extends HeaderBase {
'options'=>array(
'type'=>'object',
'default'=>array()
- )
+ ),
+ 'vAxis'=>array(
+ 'type'=>'array',
+ 'default'=>array()
+ ),
+ 'hAxis'=>array(
+ 'type'=>'array',
+ 'default'=>array()
+ ),
+ 'legend'=>array(
+ 'type'=>'array',
+ 'default'=>array()
+ )
);
public static function init($params, &$report) {
diff --git a/templates/default/html/chart_report.twig b/templates/default/html/chart_report.twig
index d856762..d604b8b 100644
--- a/templates/default/html/chart_report.twig
+++ b/templates/default/html/chart_report.twig
@@ -58,7 +58,21 @@
displayAnnotations: true,
series: series_{{chart.num}},
colors: [],
- wmode: 'transparent'
+ wmode: 'transparent',
+
+ {% autoescape false %}
+ {% if chart.vAxis is not empty %}
+ vAxis: {{ chart.vAxis|json_encode() }},
+ {% endif %}
+
+ {% if chart.hAxis is not empty %}
+ hAxis: {{ chart.hAxis|json_encode() }},
+ {% endif %}
+
+ {% if chart.legend is not empty %}
+ legend: {{ chart.legend|json_encode() }},
+ {% endif %}
+ {% endautoescape %}
};
{% if chart.options %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment