Skip to content
Browse files

Initial version

  • Loading branch information...
0 parents commit 128b74562b5d5840c056940fcfdc92a8a62cfa19 bmuschko committed May 28, 2010
Showing with 16,313 additions and 0 deletions.
  1. +65 −0 GoogleVisualizationGrailsPlugin.groovy
  2. +13 −0 LICENSE.txt
  3. +6 −0 application.properties
  4. +14 −0 dependencies.groovy
  5. +24 −0 grails-app/controllers/org/grails/plugins/google/visualization/DeprecatedController.groovy
  6. +24 −0 grails-app/controllers/org/grails/plugins/google/visualization/FormatterController.groovy
  7. 0 grails-app/i18n/messages.properties
  8. +38 −0 ...s-app/taglib/org/grails/plugins/google/visualization/GoogleVisualizationDataRendererTagLib.groovy
  9. +160 −0 grails-app/taglib/org/grails/plugins/google/visualization/GoogleVisualizationTagLib.groovy
  10. +21 −0 grails-app/views/_formatter.gsp
  11. +26 −0 grails-app/views/_visualization_javascript.gsp
  12. +76 −0 grails-app/views/deprecated/index.gsp
  13. +99 −0 grails-app/views/formatter/index.gsp
  14. +169 −0 grails-app/views/index.gsp
  15. BIN grails-google-visualization-0.1.zip
  16. +20 −0 plugin.xml
  17. +10 −0 scripts/_Install.groovy
  18. +5 −0 scripts/_Uninstall.groovy
  19. +10 −0 scripts/_Upgrade.groovy
  20. +88 −0 src/groovy/org/grails/plugins/google/visualization/GoogleVisualization.groovy
  21. +135 −0 src/groovy/org/grails/plugins/google/visualization/GoogleVisualizationBuilder.groovy
  22. +24 −0 src/groovy/org/grails/plugins/google/visualization/GoogleVisualizationColumnType.groovy
  23. +40 −0 src/groovy/org/grails/plugins/google/visualization/VisualizationBuilder.groovy
  24. +37 −0 src/groovy/org/grails/plugins/google/visualization/VisualizationData.groovy
  25. +45 −0 src/groovy/org/grails/plugins/google/visualization/VisualizationDataDirector.groovy
  26. +49 −0 src/groovy/org/grails/plugins/google/visualization/event/AnnotatedTimeLineEvent.groovy
  27. +49 −0 src/groovy/org/grails/plugins/google/visualization/event/DefaultEvent.groovy
  28. +49 −0 src/groovy/org/grails/plugins/google/visualization/event/GeoMapEvent.groovy
  29. +49 −0 src/groovy/org/grails/plugins/google/visualization/event/IntensityMapEvent.groovy
  30. +49 −0 src/groovy/org/grails/plugins/google/visualization/event/MapEvent.groovy
  31. +49 −0 src/groovy/org/grails/plugins/google/visualization/event/MotionChartEvent.groovy
  32. +49 −0 src/groovy/org/grails/plugins/google/visualization/event/OrgChartEvent.groovy
  33. +49 −0 src/groovy/org/grails/plugins/google/visualization/event/TableEvent.groovy
  34. +38 −0 src/groovy/org/grails/plugins/google/visualization/formatter/ArrowFormatter.groovy
  35. +46 −0 src/groovy/org/grails/plugins/google/visualization/formatter/BarFormatter.groovy
  36. +60 −0 src/groovy/org/grails/plugins/google/visualization/formatter/ColorFormatter.groovy
  37. +34 −0 src/groovy/org/grails/plugins/google/visualization/formatter/ColorRange.groovy
  38. +40 −0 src/groovy/org/grails/plugins/google/visualization/formatter/DateFormatter.groovy
  39. +25 −0 src/groovy/org/grails/plugins/google/visualization/formatter/Formatter.groovy
  40. +28 −0 src/groovy/org/grails/plugins/google/visualization/formatter/GradientRange.groovy
  41. +45 −0 src/groovy/org/grails/plugins/google/visualization/formatter/NumberFormatter.groovy
  42. +41 −0 src/groovy/org/grails/plugins/google/visualization/formatter/PatternFormatter.groovy
  43. +65 −0 src/groovy/org/grails/plugins/google/visualization/formatter/StandardFormatter.groovy
  44. +72 −0 src/groovy/org/grails/plugins/google/visualization/option/AnnotatedTimeLineConfigOption.groovy
  45. +76 −0 src/groovy/org/grails/plugins/google/visualization/option/AreaChartConfigOption.groovy
  46. +75 −0 src/groovy/org/grails/plugins/google/visualization/option/BarChartConfigOption.groovy
  47. +75 −0 src/groovy/org/grails/plugins/google/visualization/option/ColumnChartConfigOption.groovy
  48. +58 −0 src/groovy/org/grails/plugins/google/visualization/option/GaugeConfigOption.groovy
  49. +55 −0 src/groovy/org/grails/plugins/google/visualization/option/GeoMapConfigOption.groovy
  50. +24 −0 src/groovy/org/grails/plugins/google/visualization/option/GoogleVisualizationConfigOptionType.groovy
  51. +51 −0 src/groovy/org/grails/plugins/google/visualization/option/IntensityMapConfigOption.groovy
  52. +76 −0 src/groovy/org/grails/plugins/google/visualization/option/LineChartConfigOption.groovy
  53. +53 −0 src/groovy/org/grails/plugins/google/visualization/option/MapConfigOption.groovy
  54. +58 −0 src/groovy/org/grails/plugins/google/visualization/option/MotionChartConfigOption.groovy
  55. +51 −0 src/groovy/org/grails/plugins/google/visualization/option/OrgChartConfigOption.groovy
  56. +66 −0 src/groovy/org/grails/plugins/google/visualization/option/PieChartConfigOption.groovy
  57. +74 −0 src/groovy/org/grails/plugins/google/visualization/option/ScatterChartConfigOption.groovy
  58. +61 −0 src/groovy/org/grails/plugins/google/visualization/option/TableConfigOption.groovy
  59. +66 −0 src/groovy/org/grails/plugins/google/visualization/option/core/AreaCoreChartConfigOption.groovy
  60. +64 −0 src/groovy/org/grails/plugins/google/visualization/option/core/BarCoreChartConfigOption.groovy
  61. +64 −0 src/groovy/org/grails/plugins/google/visualization/option/core/ColumnCoreChartConfigOption.groovy
  62. +66 −0 src/groovy/org/grails/plugins/google/visualization/option/core/LineCoreChartConfigOption.groovy
  63. +61 −0 src/groovy/org/grails/plugins/google/visualization/option/core/PieCoreChartConfigOption.groovy
  64. +66 −0 src/groovy/org/grails/plugins/google/visualization/option/core/ScatterCoreChartConfigOption.groovy
  65. +27 −0 src/groovy/org/grails/plugins/google/visualization/util/BooleanUtils.groovy
  66. +157 −0 src/groovy/org/grails/plugins/google/visualization/util/ConfigOptionRendererUtil.groovy
  67. +35 −0 src/groovy/org/grails/plugins/google/visualization/util/DataRepresentationUtil.groovy
  68. +86 −0 src/groovy/org/grails/plugins/google/visualization/util/DateUtil.groovy
  69. +35 −0 src/groovy/org/grails/plugins/google/visualization/util/ResolvedConfigOption.groovy
  70. +148 −0 test/unit/org/grails/plugins/google/visualization/GoogleVisualizationBuilderTests.groovy
  71. +94 −0 test/unit/org/grails/plugins/google/visualization/GoogleVisualizationDataRendererTagLibTests.groovy
  72. +110 −0 test/unit/org/grails/plugins/google/visualization/GoogleVisualizationTagLibTests.groovy
  73. +56 −0 test/unit/org/grails/plugins/google/visualization/GoogleVisualizationTests.groovy
  74. +66 −0 test/unit/org/grails/plugins/google/visualization/VisualizationDataDirectorTests.groovy
  75. +105 −0 test/unit/org/grails/plugins/google/visualization/util/ConfigOptionRendererUtilTests.groovy
  76. +32 −0 test/unit/org/grails/plugins/google/visualization/util/DataRepresentationUtilTests.groovy
  77. +64 −0 test/unit/org/grails/plugins/google/visualization/util/DateUtilTests.groovy
  78. +270 −0 web-app/css/main.css
  79. BIN web-app/images/favicon.ico
  80. BIN web-app/images/grails_logo.jpg
  81. BIN web-app/images/grails_logo.png
  82. BIN web-app/images/leftnav_btm.png
  83. BIN web-app/images/leftnav_midstretch.png
  84. BIN web-app/images/leftnav_top.png
  85. BIN web-app/images/skin/database_add.png
  86. BIN web-app/images/skin/database_delete.png
  87. BIN web-app/images/skin/database_edit.png
  88. BIN web-app/images/skin/database_save.png
  89. BIN web-app/images/skin/database_table.png
  90. BIN web-app/images/skin/exclamation.png
  91. BIN web-app/images/skin/house.png
  92. BIN web-app/images/skin/information.png
  93. BIN web-app/images/skin/shadow.jpg
  94. BIN web-app/images/skin/sorted_asc.gif
  95. BIN web-app/images/skin/sorted_desc.gif
  96. BIN web-app/images/spinner.gif
  97. BIN web-app/images/springsource.png
  98. +13 −0 web-app/js/application.js
  99. +7 −0 web-app/js/prototype/animation.js
  100. +136 −0 web-app/js/prototype/builder.js
  101. +965 −0 web-app/js/prototype/controls.js
  102. +974 −0 web-app/js/prototype/dragdrop.js
  103. +1,123 −0 web-app/js/prototype/effects.js
  104. +4,874 −0 web-app/js/prototype/prototype.js
  105. +2,691 −0 web-app/js/prototype/rico.js
  106. +68 −0 web-app/js/prototype/scriptaculous.js
  107. +275 −0 web-app/js/prototype/slider.js
  108. +59 −0 web-app/js/prototype/sound.js
  109. +568 −0 web-app/js/prototype/unittest.js
65 GoogleVisualizationGrailsPlugin.groovy
@@ -0,0 +1,65 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+class GoogleVisualizationGrailsPlugin {
+ // the plugin version
+ def version = "0.1"
+ // the version or versions of Grails the plugin is designed for
+ def grailsVersion = "1.2 > *"
+ // the other plugins this plugin depends on
+ def dependsOn = [:]
+ // resources that are excluded from plugin packaging
+ def pluginExcludes = [
+ "grails-app/views/error.gsp"
+ ]
+
+ def author = "Benjamin Muschko"
+ def authorEmail = "benjamin.muschko@gmail.com"
+ def title = "Google Visualization API Plugin"
+ def description = '''\\
+This is a plugin for Google Visualization API.
+'''
+
+ // URL to the plugin's documentation
+ def documentation = "http://grails.org/org.grails.plugins.google.visualization.GoogleVisualization+Plugin"
+
+ def doWithSpring = {
+ // TODO Implement runtime spring config (optional)
+ }
+
+ def doWithApplicationContext = { applicationContext ->
+ // TODO Implement post initialization spring config (optional)
+ }
+
+ def doWithWebDescriptor = { xml ->
+ // TODO Implement additions to web.xml (optional)
+ }
+
+ def doWithDynamicMethods = { ctx ->
+ // TODO Implement registering dynamic methods to classes (optional)
+ }
+
+ def onChange = { event ->
+ // TODO Implement code that is executed when any artefact that this plugin is
+ // watching is modified and reloaded. The event contains: event.source,
+ // event.application, event.manager, event.ctx, and event.plugin.
+ }
+
+ def onConfigChange = { event ->
+ // TODO Implement code that is executed when the project configuration changes.
+ // The event is the same as for 'onChange'.
+ }
+}
13 LICENSE.txt
@@ -0,0 +1,13 @@
+Copyright 2010 Benjamin Muschko.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
6 application.properties
@@ -0,0 +1,6 @@
+#Grails Metadata file
+#Mon May 17 22:31:18 EDT 2010
+app.grails.version=1.3.1
+app.name=google-visualization
+plugins.hibernate=1.3.1
+plugins.tomcat=1.3.1
14 dependencies.groovy
@@ -0,0 +1,14 @@
+grails.project.dependency.resolution = {
+ inherits "global"
+ log "warn"
+
+ repositories {
+ grailsHome()
+ }
+
+ dependencies {
+ compile('commons-lang:commons-lang:2.4') {
+ exported = false
+ }
+ }
+}
24 grails-app/controllers/org/grails/plugins/google/visualization/DeprecatedController.groovy
@@ -0,0 +1,24 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization
+
+/**
+ * Controller for displaying deprecated visualization
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+class DeprecatedController {
+ def index = { }
+}
24 grails-app/controllers/org/grails/plugins/google/visualization/FormatterController.groovy
@@ -0,0 +1,24 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization
+
+/**
+ * Controller for displaying formatters
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+class FormatterController {
+ def index = { }
+}
0 grails-app/i18n/messages.properties
No changes.
38 ...glib/org/grails/plugins/google/visualization/GoogleVisualizationDataRendererTagLib.groovy
@@ -0,0 +1,38 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization
+
+/**
+ * Taglib for rendering the data based on the visualization type
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+class GoogleVisualizationDataRendererTagLib {
+ static namespace = "gvisualizationinternal"
+ final CELL_PACKAGE_NAMES = [GoogleVisualization.TABLE.packageName, GoogleVisualization.MAP.packageName, GoogleVisualization.ANNOTATED_TIME_LINE.packageName] as Set
+
+ def renderData = { attrs, body ->
+ if(isCellSetter(attrs.packageName)) {
+ out << "data.setCell(${attrs.row});"
+ }
+ else {
+ out << "data.setValue(${attrs.row});"
+ }
+ }
+
+ def isCellSetter(packageName) {
+ CELL_PACKAGE_NAMES.contains(packageName) ? true : false
+ }
+}
160 grails-app/taglib/org/grails/plugins/google/visualization/GoogleVisualizationTagLib.groovy
@@ -0,0 +1,160 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization
+
+/**
+ * Taglib for rendering Google visualizations
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+class GoogleVisualizationTagLib {
+ static namespace = "gvisualization"
+ static final PLUGIN_NAME = 'google-visualization'
+ static final VISUALIZATION_JAVASCRIPT_TEMPLATE = '/visualization_javascript'
+ final BASIC_ATTRIBUTES = ['name', 'elementId', 'language', 'columns', 'data'] as Set
+
+ def pieChart = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.PIE_CHART)
+ }
+
+ def barChart = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.BAR_CHART)
+ }
+
+ def columnChart = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.COLUMN_CHART)
+ }
+
+ def areaChart = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.AREA_CHART)
+ }
+
+ def lineChart = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.LINE_CHART)
+ }
+
+ def scatterChart = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.SCATTER_CHART)
+ }
+
+ def gauge = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.GAUGE)
+ }
+
+ def table = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.TABLE, ['formatters'])
+ }
+
+ def map = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.MAP)
+ }
+
+ def annotatedTimeLine = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.ANNOTATED_TIME_LINE)
+ }
+
+ def orgChart = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.ORG_CHART)
+ }
+
+ def intensityMap = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.INTENSITY_MAP)
+ }
+
+ def geoMap = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.GEO_MAP)
+ }
+
+ def motionChart = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.MOTION_CHART)
+ }
+
+ def pieCoreChart = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.PIE_CORE_CHART)
+ }
+
+ def barCoreChart = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.BAR_CORE_CHART)
+ }
+
+ def columnCoreChart = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.COLUMN_CORE_CHART)
+ }
+
+ def areaCoreChart = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.AREA_CORE_CHART)
+ }
+
+ def lineCoreChart = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.LINE_CORE_CHART)
+ }
+
+ def scatterCoreChart = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.SCATTER_CORE_CHART)
+ }
+
+ private validateAndRender(attrs, googleVisualization) {
+ validateAttributes(attrs, googleVisualization)
+ renderVisualization(attrs, googleVisualization)
+ }
+
+ private validateAndRender(attrs, googleVisualization, optionalAttributes) {
+ validateAttributes(attrs, googleVisualization, optionalAttributes)
+ renderVisualization(attrs, googleVisualization)
+ }
+
+ private validateAttributes(attrs, googleVisualization) {
+ attrs.each { key, value ->
+ if(!isValidAttribute(key, googleVisualization)) {
+ throw new IllegalArgumentException(getInvalidOptionExceptionMessage(key, googleVisualization))
+ }
+ }
+ }
+
+ def validateAttributes(attrs, googleVisualization, optionalAttributes) {
+ attrs.each { key, value ->
+ if(!isValidAttribute(key, googleVisualization, optionalAttributes)) {
+ throw new IllegalArgumentException(getInvalidOptionExceptionMessage(key, googleVisualization))
+ }
+ }
+ }
+
+ private isValidAttribute(key, googleVisualization) {
+ def valid = true
+
+ if(!BASIC_ATTRIBUTES.contains(key) && !googleVisualization.configOptions.containsKey(key)
+ && !googleVisualization.events.containsKey(key)) {
+ valid = false
+ }
+
+ valid
+ }
+
+ private isValidAttribute(key, googleVisualization, optionalAttributes) {
+ isValidAttribute(key, googleVisualization) || optionalAttributes.contains(key)
+ }
+
+ private getInvalidOptionExceptionMessage(key, googleVisualization) {
+ "Attribute '${key}' is not a valid option for Google Visualization '${googleVisualization.object}'!"
+ }
+
+ private renderVisualization(attrs, googleVisualization) {
+ def visualizationDataDirector = new VisualizationDataDirector()
+ visualizationDataDirector.setVisualizationBuilder(new GoogleVisualizationBuilder())
+ visualizationDataDirector.constructVisualizationData(attrs, googleVisualization)
+ def visualizationData = visualizationDataDirector.getVisualizationData()
+ out << render(template: VISUALIZATION_JAVASCRIPT_TEMPLATE, model: [visualizationData: visualizationData], plugin: PLUGIN_NAME)
+ }
+}
21 grails-app/views/_formatter.gsp
@@ -0,0 +1,21 @@
+<%@ page import="org.grails.plugins.google.visualization.formatter.ColorFormatter; org.grails.plugins.google.visualization.formatter.PatternFormatter" %>
+
+<g:each var="formatter" in="${visualizationData.formatters}" status="i">
+ <g:set var="index" value="${i + 1}"/>
+ var formatter_${index} = new ${formatter.object}(${formatter.options});
+ <g:if test="${formatter instanceof PatternFormatter}">
+ formatter_${index}.format(data, ${formatter.srcColumnIndices}<g:if test="${formatter.dstColumnIndex}">, ${formatter.dstColumnIndex}</g:if>);
+ </g:if>
+ <g:elseif test="${formatter instanceof ColorFormatter}">
+ <g:each var="range" in="${formatter.getFormattedRanges()}">
+ formatter_${index}.addRange(${range});
+ </g:each>
+ <g:each var="gradientRange" in="${formatter.getFormattedGradientRanges()}">
+ formatter_${index}.addGradientRange(${gradientRange});
+ </g:each>
+ formatter_${index}.format(data, ${formatter.column});
+ </g:elseif>
+ <g:else>
+ formatter_${index}.format(data, ${formatter.column});
+ </g:else>
+</g:each>
26 grails-app/views/_visualization_javascript.gsp
@@ -0,0 +1,26 @@
+<script type="text/javascript">
+ google.load('visualization', '1', {'packages': ['${visualizationData.visualization.packageName}']<g:if test="${visualizationData.language}">, 'language': '${visualizationData.language}'</g:if>});
+ google.setOnLoadCallback(drawVisualization);
+ var ${visualizationData.name};
+
+ function drawVisualization() {
+ var data = new google.visualization.DataTable();
+ <g:each var="column" in="${visualizationData.columns}">
+ data.addColumn('${column[0]}', '${column[1]}');
+ </g:each>
+ data.addRows(${visualizationData.rowSize});
+ <g:each var="row" in="${visualizationData.rows}">
+ <gvisualizationinternal:renderData packageName="${visualizationData.visualization.packageName}" row="${row}"/>
+ </g:each>
+
+ ${visualizationData.name} = new ${visualizationData.visualization.object}(document.getElementById('${visualizationData.elementId}'));
+
+ <g:render template="/formatter" model="[visualizationData: visualizationData]" plugin="google-visualization"/>
+
+ ${visualizationData.name}.draw(data, ${visualizationData.options});
+
+ <g:each var="event" in="${visualizationData.events}">
+ google.visualization.events.addListener(${visualizationData.name}, '${event.key}', ${event.value});
+ </g:each>
+ }
+</script>
76 grails-app/views/deprecated/index.gsp
@@ -0,0 +1,76 @@
+<%@ page import="org.grails.plugins.google.visualization.formatter.PatternFormatter; org.grails.plugins.google.visualization.formatter.NumberFormatter; org.grails.plugins.google.visualization.formatter.DateFormatter; org.grails.plugins.google.visualization.formatter.ColorRange; org.grails.plugins.google.visualization.formatter.ColorFormatter; org.grails.plugins.google.visualization.formatter.BarFormatter; org.grails.plugins.google.visualization.formatter.ArrowFormatter; org.grails.plugins.google.visualization.util.DateUtil" %>
+
+<html>
+ <head>
+ <title>Google Visualization API plugin</title>
+ <meta name="layout" content="main" />
+ <script type="text/javascript" src="http://www.google.com/jsapi"></script>
+ </head>
+ <body>
+ <%
+ def myDailyActivitiesColumns = [['string', 'Task'], ['number', 'Hours per Day']]
+ def myDailyActivitiesData = [['Work', 11], ['Eat', 2], ['Commute', 2], ['Watch TV', 2], ['Sleep', 7]]
+ def companyPerformanceColumns = [['string', 'Year'], ['number', 'Sales'], ['number', 'Expenses']]
+ def companyPerformanceData = [['2004', 1000, 400], ['2005', 1170, 460], ['2006', 660, 1120], ['2007', 1030, 540]]
+ def weightByAgeColumns = [['number', 'Age'], ['number', 'Weight']]
+ def weightByAgeData = [[8, 12], [4, 5.5], [11, 14], [4, 5], [3, 3.5], [6.5, 7]]
+ %>
+ <h2>Deprecated Chart Examples</h2>
+ <gvisualization:pieChart elementId="piechart" title="My Daily Activities" width="${400}" height="${240}" is3D="${true}" columns="${myDailyActivitiesColumns}" data="${myDailyActivitiesData}" />
+ <gvisualization:barChart elementId="barchart" title="Company Performance" width="${400}" height="${240}" is3D="${true}" columns="${companyPerformanceColumns}" data="${companyPerformanceData}" />
+ <gvisualization:columnChart elementId="columnchart" title="Company Performance" width="${400}" height="${240}" is3D="${true}" columns="${companyPerformanceColumns}" data="${companyPerformanceData}" />
+ <gvisualization:areaChart elementId="areachart" title="Company Performance" width="${400}" height="${240}" legend="bottom" columns="${companyPerformanceColumns}" data="${companyPerformanceData}" />
+ <gvisualization:lineChart elementId="linechart" width="${400}" height="${240}" title="Company Performance" legend="bottom" columns="${companyPerformanceColumns}" data="${companyPerformanceData}" />
+ <gvisualization:scatterChart elementId="scatterchart" width="${400}" height="${240}" titleX="Age" titleY="Weight" legend="none" pointSize="${5}" columns="${weightByAgeColumns}" data="${weightByAgeData}" />
+ <table cellpadding="2" cellspacing="0">
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/piechart_old.html">Pie Chart</a>
+ </td>
+ <td>
+ <div id="piechart"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/barchart_old.html">Bar Chart</a>
+ </td>
+ <td>
+ <div id="barchart"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/columnchart_old.html">Column Chart</a>
+ </td>
+ <td>
+ <div id="columnchart"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/areachart_old.html">Area Chart</a>
+ </td>
+ <td>
+ <div id="areachart"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/linechart_old.html">Line Chart</a>
+ </td>
+ <td>
+ <div id="linechart"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/scatterchart_old.html">Scatter Chart</a>
+ </td>
+ <td>
+ <div id="scatterchart"></div>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
99 grails-app/views/formatter/index.gsp
@@ -0,0 +1,99 @@
+<%@ page import="org.grails.plugins.google.visualization.formatter.PatternFormatter; org.grails.plugins.google.visualization.formatter.NumberFormatter; org.grails.plugins.google.visualization.formatter.DateFormatter; org.grails.plugins.google.visualization.formatter.ColorRange; org.grails.plugins.google.visualization.formatter.ColorFormatter; org.grails.plugins.google.visualization.formatter.BarFormatter; org.grails.plugins.google.visualization.formatter.ArrowFormatter; org.grails.plugins.google.visualization.util.DateUtil" %>
+
+<html>
+ <head>
+ <title>Google Visualization API plugin</title>
+ <meta name="layout" content="main" />
+ <script type="text/javascript" src="http://www.google.com/jsapi"></script>
+ </head>
+ <body>
+ <%
+ def departmentRevenueChangeColumns = [['string', 'Department'], ['number', 'Revenues Change']]
+ def departmentRevenueChangeData = [['Shoes', 12], ['Sports', -7.3], ['Toys', 0], ['Electronics', -2.1], ['Food', 22]]
+ def departmentRevenueColumns = [['string', 'Department'], ['number', 'Revenues']]
+ def departmentRevenueData = [['Shoes', 10700], ['Sports', -15400], ['Toys', 12500], ['Electronics', -2100], ['Food', 22600], ['Art', 1100]]
+ def employeeDatesColumns = [['string', 'Employee Name'], ['date', 'Start Date (Long)'], ['date', 'Start Date (Medium)'], ['date', 'Start Date (Short)']]
+ def employeeDatesData = [['Mike', DateUtil.createDate(2008, 1, 28, 0, 31, 26, 0), DateUtil.createDate(2008, 1, 28, 0, 31, 26, 0), DateUtil.createDate(2008, 1, 28, 0, 31, 26, 0)], ['Bob', DateUtil.createDate(2007, 5, 1), DateUtil.createDate(2007, 5, 1), DateUtil.createDate(2007, 5, 1)], ['Alice', DateUtil.createDate(2006, 7, 16), DateUtil.createDate(2006, 7, 16), DateUtil.createDate(2006, 7, 16)]]
+ def peopleEmailColumns = [['string', 'Name'], ['string', 'Email']]
+ def peopleEmailData = [['John Lennon', 'john@beatles.co.uk'], ['Paul McCartney', 'paul@beatles.co.uk'], ['George Harrison', 'george@beatles.co.uk'], ['Ringo Starr', 'ringo@beatles.co.uk']]
+ def arrowFormatters = [new ArrowFormatter(1)]
+ def barFormatter = new BarFormatter(1)
+ barFormatter.width = 120
+ def barFormatters = [barFormatter]
+ def colorFormatter = new ColorFormatter(1)
+ colorFormatter.ranges = [new ColorRange(-20000, 0, 'white', 'orange'), new ColorRange(20000, null, 'red', '#33ff33')]
+ def colorFormatters = [colorFormatter]
+ def longDateFormatter = new DateFormatter(1)
+ longDateFormatter.formatType = 'long'
+ def mediumDateFormatter = new DateFormatter(2)
+ mediumDateFormatter.formatType = 'medium'
+ def shortDateFormatter = new DateFormatter(3)
+ shortDateFormatter.formatType = 'short'
+ def dateFormatters = [longDateFormatter, mediumDateFormatter, shortDateFormatter]
+ def numberFormatter = new NumberFormatter(1)
+ numberFormatter.prefix = '$'
+ numberFormatter.negativeColor = 'red'
+ numberFormatter.negativeParens = true
+ def numberFormatters = [numberFormatter]
+ def patternFormatter = new PatternFormatter('<a href=\"mailto:{1}\">{0}</a>', [0, 1])
+ def patternFormatters = [patternFormatter]
+ %>
+ <h2>Table Formatter Examples</h2>
+ <gvisualization:table elementId="arrowformat_div" allowHtml="${true}" showRowNumber="${true}" columns="${departmentRevenueChangeColumns}" data="${departmentRevenueChangeData}" formatters="${arrowFormatters}"/>
+ <gvisualization:table elementId="barformat_div" allowHtml="${true}" showRowNumber="${true}" columns="${departmentRevenueColumns}" data="${departmentRevenueData}" formatters="${barFormatters}"/>
+ <gvisualization:table elementId="colorformat_div" allowHtml="${true}" showRowNumber="${true}" columns="${departmentRevenueColumns}" data="${departmentRevenueData}" formatters="${colorFormatters}"/>
+ <gvisualization:table elementId="dateformat_div" showRowNumber="${true}" columns="${employeeDatesColumns}" data="${employeeDatesData}" formatters="${dateFormatters}"/>
+ <gvisualization:table elementId="numberformat_div" allowHtml="${true}" showRowNumber="${true}" columns="${departmentRevenueColumns}" data="${departmentRevenueData}" formatters="${numberFormatters}"/>
+ <gvisualization:table elementId="patternformat_div" allowHtml="${true}" showRowNumber="${true}" columns="${peopleEmailColumns}" data="${peopleEmailData}" formatters="${patternFormatters}"/>
+ <table cellpadding="2" cellspacing="0">
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/reference.html#arrowformatter">Arrow Formatter</a>
+ </td>
+ <td>
+ <div id="arrowformat_div"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/reference.html#barformatter">Bar Formatter</a>
+ </td>
+ <td>
+ <div id="barformat_div"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/reference.html#colorformatter">Color Formatter</a>
+ </td>
+ <td>
+ <div id="colorformat_div"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/reference.html#dateformatter">Date Formatter</a>
+ </td>
+ <td>
+ <div id="dateformat_div"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/reference.html#numberformatter">Number Formatter</a>
+ </td>
+ <td>
+ <div id="numberformat_div"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/reference.html#patternformatter">Pattern Formatter</a>
+ </td>
+ <td>
+ <div id="patternformat_div"></div>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
169 grails-app/views/index.gsp
@@ -0,0 +1,169 @@
+<%@ page import="org.grails.plugins.google.visualization.util.DateUtil" %>
+<html>
+ <head>
+ <title>Google Visualization API plugin</title>
+ <meta name="layout" content="main" />
+ <script src="http://maps.google.com/maps?file=api&v=2&key=ABCDEFG" type="text/javascript"></script>
+ <script type="text/javascript" src="http://www.google.com/jsapi"></script>
+ </head>
+ <body>
+ <%
+ def myDailyActivitiesColumns = [['string', 'Task'], ['number', 'Hours per Day']]
+ def myDailyActivitiesData = [['Work', 11], ['Eat', 2], ['Commute', 2], ['Watch TV', 2], ['Sleep', 7]]
+ def companyPerformanceColumns = [['string', 'Year'], ['number', 'Sales'], ['number', 'Expenses']]
+ def companyPerformanceData = [['2004', 1000, 400], ['2005', 1170, 460], ['2006', 660, 1120], ['2007', 1030, 540]]
+ def weightByAgeColumns = [['number', 'Age'], ['number', 'Weight']]
+ def weightByAgeData = [[8, 12], [4, 5.5], [11, 14], [4, 5], [3, 3.5], [6.5, 7]]
+ def systemPerformanceColumns = [['string', 'Label'], ['number', 'Value']]
+ def systemPerformanceData = [['Memory', 80], ['CPU', 55], ['Network', 68]]
+ def employeeColumns = [['string', 'Name'], ['string', 'Salary'], ['boolean', 'Full Time Employee']]
+ def employeeData = [['Mike', '$10,000', true], ['Jim', '$8,000', false], ['Alice', '$12,500', true], ['Bob', '$7,000', true]]
+ def mapColumns = [['number', 'Lat'], ['number', 'Lon'], ['string', 'Name']]
+ def mapData = [[37.4232, -122.0853, 'Work'], [37.4289, -122.1697, 'University'], [37.6153, -122.3900, 'Airport'], [37.4422, -122.1731, 'Shopping']]
+ def pensColumns = [['date', 'Date'], ['number', 'Sold Pencils'], ['string', 'title1'], ['string', 'text1'], ['number', 'Sold Pens'], ['string', 'title2'], ['string', 'text2']]
+ def pensData = [[DateUtil.createDate(2008, 1, 1), 30000, null, null, 40645, null, null], [DateUtil.createDate(2008, 1, 2), 14045, null, null, 20374, null, null], [DateUtil.createDate(2008, 1, 3), 55022, null, null, 50766, null, null], [DateUtil.createDate(2008, 1, 4), 75284, null, null, 14334, 'Out of Stock','Ran out of stock on pens at 4pm'], [DateUtil.createDate(2008, 1, 5), 41476, 'Bought Pens','Bought 200k pens', 66467, null, null], [DateUtil.createDate(2008, 1, 6), 33322, null, null, 39463, null, null]]
+ def orgColumns = [['string', 'Name'], ['string', 'Manager'], ['string', 'ToolTip']]
+ def orgData = [['Mike', '', 'The President'], ['Jim', 'Mike', 'VP'], ['Alice', 'Mike', ''], ['Bob', 'Jim', 'Bob Sponge'], ['Carol', 'Bob', '']]
+ def populationColumns = [['string', '', 'Country'], ['number', 'Population (mil)', 'a'], ['number', 'Area (km2)', 'b']]
+ def populationData = [['CN', 1324, 9640821], ['IN', 1133, 3287263], ['US', 304, 9629091], ['ID', 232, 1904569], ['BR', 187, 8514877]]
+ def popularityColumns = [['string', 'Country'], ['number', 'Popularity']]
+ def popularityData = [['Germany', 200], ['United States', 300], ['Brazil', 400], ['Canada', 500], ['France', 600], ['RU', 700]]
+ def fruitColumns = [['string', 'Fruit'], ['date', 'Date'], ['number', 'Sales'], ['number', 'Expenses'], ['string', 'Location']]
+ def fruitData = [['Apples', DateUtil.createDate(1988, 0, 1), 1000, 300, 'East'], ['Oranges', DateUtil.createDate(1988, 0, 1), 1150, 200, 'West'], ['Bananas', DateUtil.createDate(1988, 0, 1), 300, 250, 'West'], ['Apples', DateUtil.createDate(1989, 6, 1), 1200, 400, 'East'], ['Oranges', DateUtil.createDate(1989, 6, 1), 750, 150, 'West'], ['Bananas', DateUtil.createDate(1989, 6, 1), 788, 617, 'West']]
+ %>
+ <script type="text/javascript">
+ function selectHandler(e) {
+ alert('A table row was selected');
+ }
+ </script>
+ <h2>Google Visualization API Examples</h2>
+ <gvisualization:pieCoreChart elementId="piechart" title="My Daily Activities" width="${450}" height="${300}" columns="${myDailyActivitiesColumns}" data="${myDailyActivitiesData}" />
+ <gvisualization:barCoreChart elementId="barchart" title="Company Performance" width="${400}" height="${240}" vAxis="${new Expando(title: 'Year', titleColor: 'red')}" columns="${companyPerformanceColumns}" data="${companyPerformanceData}" />
+ <gvisualization:columnCoreChart elementId="columnchart" title="Company Performance" width="${400}" height="${240}" hAxis="${new Expando(title: 'Year', titleColor: 'red')}" columns="${companyPerformanceColumns}" data="${companyPerformanceData}" />
+ <gvisualization:areaCoreChart elementId="areachart" title="Company Performance" width="${400}" height="${240}" hAxis="${new Expando(title: 'Year', titleColor: 'red')}" columns="${companyPerformanceColumns}" data="${companyPerformanceData}" />
+ <gvisualization:lineCoreChart elementId="linechart" width="${400}" height="${240}" title="Company Performance" columns="${companyPerformanceColumns}" data="${companyPerformanceData}" />
+ <gvisualization:scatterCoreChart elementId="scatterchart" width="${400}" height="${240}" title="Age vs. Weight comparison" hAxis="${new Expando(title: 'Age', minValue: 0, maxValue: 15)}" vAxis="${new Expando(title: 'Weight', minValue: 0, maxValue: 15)}" legend="none" columns="${weightByAgeColumns}" data="${weightByAgeData}" />
+ <gvisualization:gauge elementId="gauge" width="${400}" height="${120}" redFrom="${90}" redTo="${100}" yellowFrom="${75}" yellowTo="${90}" minorTicks="${5}" columns="${systemPerformanceColumns}" data="${systemPerformanceData}" />
+ <gvisualization:table elementId="table" width="${400}" height="${130}" columns="${employeeColumns}" data="${employeeData}" select="selectHandler" />
+ <gvisualization:map elementId="map" columns="${mapColumns}" data="${mapData}" />
+ <gvisualization:annotatedTimeLine elementId="annotatedtimeline" columns="${pensColumns}" data="${pensData}" />
+ <gvisualization:orgChart elementId="orgchart" columns="${orgColumns}" data="${orgData}" />
+ <gvisualization:intensityMap elementId="intensitymap" columns="${populationColumns}" data="${populationData}" />
+ <gvisualization:geoMap elementId="geomap" columns="${popularityColumns}" data="${popularityData}" />
+ <gvisualization:motionChart elementId="motionchart" columns="${fruitColumns}" data="${fruitData}" />
+ <table cellpadding="2" cellspacing="0">
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/piechart.html">Pie Chart</a>
+ </td>
+ <td>
+ <div id="piechart"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/barchart.html">Bar Chart</a>
+ </td>
+ <td>
+ <div id="barchart"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/columnchart.html">Column Chart</a>
+ </td>
+ <td>
+ <div id="columnchart"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/areachart.html">Area Chart</a>
+ </td>
+ <td>
+ <div id="areachart"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/linechart.html">Line Chart</a>
+ </td>
+ <td>
+ <div id="linechart"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/scatterchart.html">Scatter Chart</a>
+ </td>
+ <td>
+ <div id="scatterchart"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/gauge.html">Gauge</a>
+ </td>
+ <td>
+ <div id="gauge"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/table.html">Table</a>
+ </td>
+ <td>
+ <div id="table"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/map.html">Map</a>
+ </td>
+ <td>
+ <div id="map" style="width: 400px; height: 300px"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/annotatedtimeline.html">Annotated Time Line</a>
+ </td>
+ <td>
+ <div id="annotatedtimeline" style='width: 700px; height: 240px;'></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/orgchart.html">Organizational Chart</a>
+ </td>
+ <td>
+ <div id="orgchart"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/intensitymap.html">Intensity Map</a>
+ </td>
+ <td>
+ <div id="intensitymap"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/geomap.html">Geo Map</a>
+ </td>
+ <td>
+ <div id="geomap"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a href="http://code.google.com/apis/visualization/documentation/gallery/motionchart.html">Motion Chart</a>
+ </td>
+ <td>
+ <div id="motionchart"></div>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
BIN grails-google-visualization-0.1.zip
Binary file not shown.
20 plugin.xml
@@ -0,0 +1,20 @@
+<plugin name='google-visualization' version='0.1' grailsVersion='1.2 &gt; *'>
+ <author>Benjamin Muschko</author>
+ <authorEmail>benjamin.muschko@gmail.com</authorEmail>
+ <title>Google Visualization API Plugin</title>
+ <description>\
+This is a plugin for Google Visualization API.
+</description>
+ <documentation>http://grails.org/org.grails.plugins.google.visualization.GoogleVisualization+Plugin</documentation>
+ <resources>
+ <resource>BuildConfig</resource>
+ <resource>DataSource</resource>
+ <resource>UrlMappings</resource>
+ <resource>org.grails.plugins.google.visualization.DeprecatedController</resource>
+ <resource>org.grails.plugins.google.visualization.FormatterController</resource>
+ <resource>org.grails.plugins.google.visualization.GoogleVisualizationDataRendererTagLib</resource>
+ <resource>org.grails.plugins.google.visualization.GoogleVisualizationTagLib</resource>
+ </resources>
+ <dependencies />
+ <behavior />
+</plugin>
10 scripts/_Install.groovy
@@ -0,0 +1,10 @@
+//
+// This script is executed by Grails after plugin was installed to project.
+// This script is a Gant script so you can use all special variables provided
+// by Gant (such as 'baseDir' which points on project base dir). You can
+// use 'ant' to access a global instance of AntBuilder
+//
+// For example you can create directory under project tree:
+//
+// ant.mkdir(dir:"${basedir}/grails-app/jobs")
+//
5 scripts/_Uninstall.groovy
@@ -0,0 +1,5 @@
+//
+// This script is executed by Grails when the plugin is uninstalled from project.
+// Use this script if you intend to do any additional clean-up on uninstall, but
+// beware of messing up SVN directories!
+//
10 scripts/_Upgrade.groovy
@@ -0,0 +1,10 @@
+//
+// This script is executed by Grails during application upgrade ('grails upgrade'
+// command). This script is a Gant script so you can use all special variables
+// provided by Gant (such as 'baseDir' which points on project base dir). You can
+// use 'ant' to access a global instance of AntBuilder
+//
+// For example you can create directory under project tree:
+//
+// ant.mkdir(dir:"${basedir}/grails-app/jobs")
+//
88 src/groovy/org/grails/plugins/google/visualization/GoogleVisualization.groovy
@@ -0,0 +1,88 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization
+
+import org.apache.commons.logging.Log
+import org.apache.commons.logging.LogFactory
+import org.grails.plugins.google.visualization.event.*
+import org.grails.plugins.google.visualization.option.*
+import org.grails.plugins.google.visualization.option.core.*
+
+/**
+ * Google visualizations
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+enum GoogleVisualization {
+ PIE_CHART('piechart', 'google.visualization.PieChart', PieChartConfigOption.configOptions, DefaultEvent.events),
+ BAR_CHART('barchart', 'google.visualization.BarChart', BarChartConfigOption.configOptions, DefaultEvent.events),
+ COLUMN_CHART('columnchart', 'google.visualization.ColumnChart', ColumnChartConfigOption.configOptions, DefaultEvent.events),
+ AREA_CHART('areachart', 'google.visualization.AreaChart', AreaChartConfigOption.configOptions, DefaultEvent.events),
+ SCATTER_CHART('scatterchart', 'google.visualization.ScatterChart', ScatterChartConfigOption.configOptions, DefaultEvent.events),
+ GAUGE('gauge', 'google.visualization.Gauge', GaugeConfigOption.configOptions, [:]),
+ LINE_CHART('linechart', 'google.visualization.LineChart', LineChartConfigOption.configOptions, DefaultEvent.events),
+ TABLE('table', 'google.visualization.Table', TableConfigOption.configOptions, TableEvent.events),
+ MAP('map', 'google.visualization.Map', MapConfigOption.configOptions, MapEvent.events),
+ ANNOTATED_TIME_LINE('annotatedtimeline', 'google.visualization.AnnotatedTimeLine', AnnotatedTimeLineConfigOption.configOptions, AnnotatedTimeLineEvent.events),
+ ORG_CHART('orgchart', 'google.visualization.OrgChart', OrgChartConfigOption.configOptions, OrgChartEvent.events),
+ INTENSITY_MAP('intensitymap', 'google.visualization.IntensityMap', IntensityMapConfigOption.configOptions, IntensityMapEvent.events),
+ GEO_MAP('geomap', 'google.visualization.GeoMap', GeoMapConfigOption.configOptions, GeoMapEvent.events),
+ MOTION_CHART('motionchart', 'google.visualization.MotionChart', MotionChartConfigOption.configOptions, MotionChartEvent.events),
+ PIE_CORE_CHART('corechart', 'google.visualization.PieChart', PieCoreChartConfigOption.configOptions, DefaultEvent.events),
+ BAR_CORE_CHART('corechart', 'google.visualization.BarChart', BarCoreChartConfigOption.configOptions, DefaultEvent.events),
+ COLUMN_CORE_CHART('corechart', 'google.visualization.ColumnChart', ColumnCoreChartConfigOption.configOptions, DefaultEvent.events),
+ AREA_CORE_CHART('corechart', 'google.visualization.AreaChart', AreaCoreChartConfigOption.configOptions, DefaultEvent.events),
+ LINE_CORE_CHART('corechart', 'google.visualization.LineChart', LineCoreChartConfigOption.configOptions, DefaultEvent.events),
+ SCATTER_CORE_CHART('corechart', 'google.visualization.ScatterChart', ScatterCoreChartConfigOption.configOptions, DefaultEvent.events)
+
+ static final Log log = LogFactory.getLog(GoogleVisualization)
+ static final Map googleVisualizations
+
+ static {
+ googleVisualizations = [:]
+
+ values().each { googleVisualization ->
+ googleVisualizations.put(googleVisualization.packageName, googleVisualization)
+ }
+ }
+
+ private final packageName
+ private final object
+ private final configOptions
+ private final events
+
+ GoogleVisualization(packageName, object, configOptions, events) {
+ this.packageName = packageName
+ this.object = object
+ this.configOptions = configOptions
+ this.events = events
+ }
+
+ static getGoogleVisualizationForPackageName(packageName) {
+ def googleVisualization = googleVisualizations[packageName]
+
+ if(googleVisualization == null) {
+ log.error "Unknown Google visualization: ${packageName}"
+ throw new IllegalArgumentException('Unknown Google visualization')
+ }
+
+ googleVisualization
+ }
+
+ @Override
+ public String toString() {
+ "GoogleVisualization{packageName='${packageName}', object='${object}', configOptions='${configOptions}', events='${events}'}"
+ }
+}
135 src/groovy/org/grails/plugins/google/visualization/GoogleVisualizationBuilder.groovy
@@ -0,0 +1,135 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization
+
+import org.apache.commons.lang.StringUtils
+import org.grails.plugins.google.visualization.util.ConfigOptionRendererUtil
+import org.grails.plugins.google.visualization.util.DateUtil
+
+/**
+ * Google visualization builder. Takes in all passed in taglib attributes and knows how to prepare/render the data
+ * for the visualization.
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+class GoogleVisualizationBuilder extends VisualizationBuilder {
+ final DEFAULT_NAME = 'visualization'
+
+ @Override
+ def buildName() {
+ visualizationData.name = attrs.name ? attrs.name : DEFAULT_NAME
+ }
+
+ @Override
+ def buildElementId() {
+ visualizationData.elementId = attrs.elementId
+ }
+
+ @Override
+ def buildLanguage() {
+ if(attrs.language) {
+ visualizationData.language = attrs.language
+ }
+ }
+
+ @Override
+ def buildOptions() {
+ def visualizationOptions = []
+
+ attrs.each() { key, value ->
+ // Attribute is a configuration option
+ if(visualizationData.visualization.configOptions.containsKey(key)) {
+ def configOption = visualizationData.visualization.configOptions.get(key)
+ def resolvedConfigOption = ConfigOptionRendererUtil.render(configOption, value)
+ visualizationOptions << "${key}: ${resolvedConfigOption.value}"
+ }
+ }
+
+ def visualizationOptionsString = (visualizationOptions.size() == 0) ? '{}' : "{${StringUtils.join(visualizationOptions, ', ')}}"
+ visualizationData.options = visualizationOptionsString
+ }
+
+ @Override
+ def buildColumns() {
+ visualizationData.columns = attrs.columns
+ }
+
+ @Override
+ def buildRowSize() {
+ visualizationData.rowSize = attrs.data.size()
+ }
+
+ /**
+ * Builds rows
+ * Allowed data types are 'string', 'number', 'boolean', 'date', 'datetime' or 'timeofday'.
+ *
+ * @return Row data
+ */
+ @Override
+ def buildRows() {
+ def rowsData = []
+
+ attrs.data.eachWithIndex { it, dataIndex ->
+ it.toList().eachWithIndex { row, rowIndex ->
+ def dataType = attrs.columns[rowIndex][0]
+ def param
+
+ if(row != null) {
+ if(dataType == GoogleVisualizationColumnType.STRING.toString().toLowerCase()) {
+ param = "'${row}'"
+ }
+ else if(dataType == GoogleVisualizationColumnType.DATE.toString().toLowerCase()) {
+ param = DateUtil.createDateJavaScriptObject(row)
+ }
+ else if(dataType == GoogleVisualizationColumnType.DATETIME.toString().toLowerCase()) {
+ param = DateUtil.createDateTimeJavaScriptObject(row)
+ }
+ else if(dataType == GoogleVisualizationColumnType.TIMEOFDAY.toString().toLowerCase()) {
+ param = DateUtil.createTimeOfDayJavaScriptObject(row)
+ }
+ else {
+ param = row
+ }
+ }
+ else {
+ param = 'undefined'
+ }
+
+ rowsData << "${dataIndex}, ${rowIndex}, ${param}"
+ }
+ }
+
+ visualizationData.rows = rowsData
+ }
+
+ @Override
+ def buildEvents() {
+ def events = [:]
+
+ attrs.each() { key, value ->
+ // Attribute is a event
+ if(visualizationData.visualization.events.containsKey(key)) {
+ events[key] = value
+ }
+ }
+
+ visualizationData.events = events
+ }
+
+ @Override
+ def buildFormatters() {
+ visualizationData.formatters = attrs.formatters
+ }
+}
24 src/groovy/org/grails/plugins/google/visualization/GoogleVisualizationColumnType.groovy
@@ -0,0 +1,24 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization
+
+/**
+ * Google visualization column data types
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+enum GoogleVisualizationColumnType {
+ STRING, NUMBER, BOOLEAN, DATE, DATETIME, TIMEOFDAY
+}
40 src/groovy/org/grails/plugins/google/visualization/VisualizationBuilder.groovy
@@ -0,0 +1,40 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization
+
+/**
+ * Visualization builder
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+abstract class VisualizationBuilder {
+ def visualizationData
+ def attrs
+
+ def createNewVisualizationData(attrs, visualization) {
+ visualizationData = new VisualizationData(visualization)
+ this.attrs = attrs
+ }
+
+ abstract buildName()
+ abstract buildElementId()
+ abstract buildLanguage()
+ abstract buildOptions()
+ abstract buildColumns()
+ abstract buildRowSize()
+ abstract buildRows()
+ abstract buildEvents()
+ abstract buildFormatters()
+}
37 src/groovy/org/grails/plugins/google/visualization/VisualizationData.groovy
@@ -0,0 +1,37 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization
+
+/**
+ * Visualization data
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+class VisualizationData {
+ final visualization
+ def name
+ def elementId
+ def language
+ def options
+ def columns
+ def rowSize
+ def rows
+ def events
+ def formatters
+
+ VisualizationData(visualization) {
+ this.visualization = visualization
+ }
+}
45 src/groovy/org/grails/plugins/google/visualization/VisualizationDataDirector.groovy
@@ -0,0 +1,45 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization
+
+/**
+ * Visualization data director. Hides building details.
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+class VisualizationDataDirector {
+ def visualizationBuilder
+
+ def setVisualizationDataBuilder(visualizationBuilder) {
+ this.visualizationBuilder = visualizationBuilder
+ }
+
+ def constructVisualizationData(attrs, visualization) {
+ visualizationBuilder.createNewVisualizationData(attrs, visualization)
+ visualizationBuilder.buildName()
+ visualizationBuilder.buildElementId()
+ visualizationBuilder.buildLanguage()
+ visualizationBuilder.buildOptions()
+ visualizationBuilder.buildColumns()
+ visualizationBuilder.buildRowSize()
+ visualizationBuilder.buildRows()
+ visualizationBuilder.buildEvents()
+ visualizationBuilder.buildFormatters()
+ }
+
+ def getVisualizationData() {
+ visualizationBuilder.visualizationData
+ }
+}
49 src/groovy/org/grails/plugins/google/visualization/event/AnnotatedTimeLineEvent.groovy
@@ -0,0 +1,49 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization.event
+
+import org.apache.commons.logging.LogFactory
+import org.apache.commons.logging.Log
+
+/**
+ * Available events for visualization "Annotated Time Line"
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+enum AnnotatedTimeLineEvent {
+ RANGECHANGE('rangechange'), READY('ready'), SELECT('select')
+
+ static final Log log = LogFactory.getLog(AnnotatedTimeLineEvent)
+ static final Map events
+
+ static {
+ events = [:]
+
+ values().each { event ->
+ events.put(event.name, event)
+ }
+ }
+
+ private final name
+
+ AnnotatedTimeLineEvent(name) {
+ this.name = name
+ }
+
+ @Override
+ public String toString() {
+ "AnnotatedTimeLineEvent{name='${name}'}"
+ }
+}
49 src/groovy/org/grails/plugins/google/visualization/event/DefaultEvent.groovy
@@ -0,0 +1,49 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization.event
+
+import org.apache.commons.logging.LogFactory
+import org.apache.commons.logging.Log
+
+/**
+ * Available events for most of the visualizations
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+enum DefaultEvent {
+ ONMOUSEOVER('onmouseover'), ONMOUSEOUT('onmouseout'), READY('ready'), SELECT('select')
+
+ static final Log log = LogFactory.getLog(DefaultEvent)
+ static final Map events
+
+ static {
+ events = [:]
+
+ values().each { event ->
+ events.put(event.name, event)
+ }
+ }
+
+ private final name
+
+ DefaultEvent(name) {
+ this.name = name
+ }
+
+ @Override
+ public String toString() {
+ "AreaChartEvent{name='${name}'}"
+ }
+}
49 src/groovy/org/grails/plugins/google/visualization/event/GeoMapEvent.groovy
@@ -0,0 +1,49 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization.event
+
+import org.apache.commons.logging.LogFactory
+import org.apache.commons.logging.Log
+
+/**
+ * Available events for visualization "Geo Map"
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+enum GeoMapEvent {
+ SELECT('select'), REGIONCLICK('regionClick'), ZOOMOUT('zoomOut'), DRAWINGDONE('drawingDone')
+
+ static final Log log = LogFactory.getLog(GeoMapEvent)
+ static final Map events
+
+ static {
+ events = [:]
+
+ values().each { event ->
+ events.put(event.name, event)
+ }
+ }
+
+ private final name
+
+ GeoMapEvent(name) {
+ this.name = name
+ }
+
+ @Override
+ public String toString() {
+ "GeoMapEvent{name='${name}'}"
+ }
+}
49 src/groovy/org/grails/plugins/google/visualization/event/IntensityMapEvent.groovy
@@ -0,0 +1,49 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization.event
+
+import org.apache.commons.logging.LogFactory
+import org.apache.commons.logging.Log
+
+/**
+ * Available events for visualization "Intensity Map"
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+enum IntensityMapEvent {
+ READY('ready'), SELECT('select')
+
+ static final Log log = LogFactory.getLog(IntensityMapEvent)
+ static final Map events
+
+ static {
+ events = [:]
+
+ values().each { event ->
+ events.put(event.name, event)
+ }
+ }
+
+ private final name
+
+ IntensityMapEvent(name) {
+ this.name = name
+ }
+
+ @Override
+ public String toString() {
+ "IntensityMapEvent{name='${name}'}"
+ }
+}
49 src/groovy/org/grails/plugins/google/visualization/event/MapEvent.groovy
@@ -0,0 +1,49 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization.event
+
+import org.apache.commons.logging.LogFactory
+import org.apache.commons.logging.Log
+
+/**
+ * Available events for visualization "Map"
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+enum MapEvent {
+ SELECT('select')
+
+ static final Log log = LogFactory.getLog(MapEvent)
+ static final Map events
+
+ static {
+ events = [:]
+
+ values().each { event ->
+ events.put(event.name, event)
+ }
+ }
+
+ private final name
+
+ MapEvent(name) {
+ this.name = name
+ }
+
+ @Override
+ public String toString() {
+ "MapEvent{name='${name}'}"
+ }
+}
49 src/groovy/org/grails/plugins/google/visualization/event/MotionChartEvent.groovy
@@ -0,0 +1,49 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization.event
+
+import org.apache.commons.logging.LogFactory
+import org.apache.commons.logging.Log
+
+/**
+ * Available events for visualization "Motion Chart"
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+enum MotionChartEvent {
+ READY('ready'), STATECHANGE('statechange')
+
+ static final Log log = LogFactory.getLog(MotionChartEvent)
+ static final Map events
+
+ static {
+ events = [:]
+
+ values().each { event ->
+ events.put(event.name, event)
+ }
+ }
+
+ private final name
+
+ MotionChartEvent(name) {
+ this.name = name
+ }
+
+ @Override
+ public String toString() {
+ "MotionChartEvent{name='${name}'}"
+ }
+}
49 src/groovy/org/grails/plugins/google/visualization/event/OrgChartEvent.groovy
@@ -0,0 +1,49 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization.event
+
+import org.apache.commons.logging.LogFactory
+import org.apache.commons.logging.Log
+
+/**
+ * Available events for visualization "Organizational Chart"
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+enum OrgChartEvent {
+ COLLAPSE('collapse'), ONMOUSEOVER('onmouseover'), ONMOUSEOUT('onmouseout'), READY('ready'), SELECT('select')
+
+ static final Log log = LogFactory.getLog(OrgChartEvent)
+ static final Map events
+
+ static {
+ events = [:]
+
+ values().each { event ->
+ events.put(event.name, event)
+ }
+ }
+
+ private final name
+
+ OrgChartEvent(name) {
+ this.name = name
+ }
+
+ @Override
+ public String toString() {
+ "OrgChartEvent{name='${name}'}"
+ }
+}
49 src/groovy/org/grails/plugins/google/visualization/event/TableEvent.groovy
@@ -0,0 +1,49 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization.event
+
+import org.apache.commons.logging.LogFactory
+import org.apache.commons.logging.Log
+
+/**
+ * Available events for visualization "Table"
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+enum TableEvent {
+ SELECT('select'), PAGE('page'), SORT('sort'), READY('ready')
+
+ static final Log log = LogFactory.getLog(TableEvent)
+ static final Map events
+
+ static {
+ events = [:]
+
+ values().each { event ->
+ events.put(event.name, event)
+ }
+ }
+
+ private final name
+
+ TableEvent(name) {
+ this.name = name
+ }
+
+ @Override
+ public String toString() {
+ "TableEvent{name='${name}'}"
+ }
+}
38 src/groovy/org/grails/plugins/google/visualization/formatter/ArrowFormatter.groovy
@@ -0,0 +1,38 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization.formatter
+
+/**
+ * Arrow formatter
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+class ArrowFormatter extends StandardFormatter {
+ def base
+
+ ArrowFormatter(column) {
+ super(column)
+ }
+
+ @Override
+ def getObject() {
+ 'google.visualization.ArrowFormat'
+ }
+
+ @Override
+ def getFormatterOptions() {
+ ['base': base]
+ }
+}
46 src/groovy/org/grails/plugins/google/visualization/formatter/BarFormatter.groovy
@@ -0,0 +1,46 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization.formatter
+
+/**
+ * Bar formatter
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+class BarFormatter extends StandardFormatter {
+ def base
+ def colorNegative
+ def colorPositive
+ def drawZeroLine
+ def max
+ def min
+ def showValue
+ def width
+
+ BarFormatter(column) {
+ super(column)
+ }
+
+ @Override
+ def getObject() {
+ 'google.visualization.BarFormat'
+ }
+
+ @Override
+ def getFormatterOptions() {
+ ['base': base, 'colorNegative': colorNegative, 'colorPositive': colorPositive,
+ 'drawZeroLine': drawZeroLine, 'max': max, 'min': min, 'showValue': showValue, 'width': width]
+ }
+}
60 src/groovy/org/grails/plugins/google/visualization/formatter/ColorFormatter.groovy
@@ -0,0 +1,60 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization.formatter
+
+/**
+ * Color formatter
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+class ColorFormatter implements Formatter {
+ final column
+ def ranges
+ def gradientRanges
+
+ ColorFormatter(column) {
+ this.column = column
+ }
+
+ @Override
+ def getObject() {
+ 'google.visualization.ColorFormat'
+ }
+
+ @Override
+ def getOptions() {
+ ""
+ }
+
+ def getFormattedRanges() {
+ def formattedColorRanges = []
+
+ ranges.each { colorRange ->
+ formattedColorRanges << "${colorRange.from}, ${colorRange.to}, '${colorRange.color}', '${colorRange.bgcolor}'"
+ }
+
+ formattedColorRanges
+ }
+
+ def getFormattedGradientRanges() {
+ def formattedGradientRanges = []
+
+ gradientRanges.each { gradientRange ->
+ formattedGradientRanges << "${gradientRange.from}, ${gradientRange.to}, '${gradientRange.color}', '${gradientRange.fromBgColor}', '${gradientRange.toBgColor}'"
+ }
+
+ formattedGradientRanges
+ }
+}
34 src/groovy/org/grails/plugins/google/visualization/formatter/ColorRange.groovy
@@ -0,0 +1,34 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization.formatter
+
+/**
+ * Color range used by color formatter
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+class ColorRange {
+ final from
+ final to
+ final color
+ final bgcolor
+
+ ColorRange(from, to, color, bgcolor) {
+ this.from = from
+ this.to = to
+ this.color = color
+ this.bgcolor = bgcolor
+ }
+}
40 src/groovy/org/grails/plugins/google/visualization/formatter/DateFormatter.groovy
@@ -0,0 +1,40 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization.formatter
+
+/**
+ * Date formatter
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+class DateFormatter extends StandardFormatter {
+ def formatType
+ def pattern
+ def timeZone
+
+ DateFormatter(column) {
+ super(column)
+ }
+
+ @Override
+ def getObject() {
+ 'google.visualization.DateFormat'
+ }
+
+ @Override
+ def getFormatterOptions() {
+ ['formatType': formatType, 'pattern': pattern, 'timeZone': timeZone]
+ }
+}
25 src/groovy/org/grails/plugins/google/visualization/formatter/Formatter.groovy
@@ -0,0 +1,25 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization.formatter
+
+/**
+ * Formatter interface
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+interface Formatter {
+ def getObject()
+ def getOptions()
+}
28 src/groovy/org/grails/plugins/google/visualization/formatter/GradientRange.groovy
@@ -0,0 +1,28 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization.formatter
+
+/**
+ * Gradient range used by color formatter
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+class GradientRange {
+ def from
+ def to
+ def color
+ def fromBgColor
+ def toBgColor
+}
45 src/groovy/org/grails/plugins/google/visualization/formatter/NumberFormatter.groovy
@@ -0,0 +1,45 @@
+/* Copyright 2010 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.grails.plugins.google.visualization.formatter
+
+/**
+ * Number formatter
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+class NumberFormatter extends StandardFormatter {
+ def decimalSymbol
+ def fractionDigits
+ def groupingSymbol
+ def negativeColor
+ def negativeParens
+ def prefix
+ def suffix
+
+ NumberFormatter(column) {
+ super(column)