Skip to content
Browse files

Added new GeoChart.

  • Loading branch information...
1 parent 6428a59 commit 667bb22efa61cec8eaf5cfe391958380ac5ecab0 @bmuschko committed May 18, 2011
View
4 grails-app/taglib/org/grails/plugins/google/visualization/GoogleVisualizationTagLib.groovy
@@ -77,6 +77,10 @@ class GoogleVisualizationTagLib {
validateAndRender(attrs, GoogleVisualization.GEO_MAP)
}
+ def geoChart = { attrs, body ->
+ validateAndRender(attrs, GoogleVisualization.GEO_CHART)
+ }
+
def motionChart = { attrs, body ->
validateAndRender(attrs, GoogleVisualization.MOTION_CHART)
}
View
9 grails-app/views/index.gsp
@@ -63,6 +63,7 @@
<gvisualization:orgChart elementId="orgchart" allowHtml="${true}" columns="${orgColumns}" data="${orgData}" />
<gvisualization:intensityMap elementId="intensitymap" columns="${populationColumns}" data="${populationData}" />
<gvisualization:geoMap elementId="geomap" columns="${popularityColumns}" data="${popularityData}" />
+ <gvisualization:geoChart elementId="geochart" width="${556}" height="${347}" columns="${popularityColumns}" data="${popularityData}" />
<gvisualization:motionChart elementId="motionchart" columns="${fruitColumns}" data="${fruitData}" />
<gvisualization:treeMap elementId="treemap" minColor="#f00" midColor="#ddd" maxColor="#0d0" headerHeight="${15}" fontColor="black" showScale="${true}" columns="${marketByRegionColumns}" data="${marketByRegionData}" />
<table cellpadding="2" cellspacing="0">
@@ -220,6 +221,14 @@
</tr>
<tr>
<td>
+ <a href="http://code.google.com/apis/chart/interactive/docs/gallery/geochart.html">Geo Chart</a>
+ </td>
+ <td>
+ <div id="geochart"></div>
+ </td>
+ </tr>
+ <tr>
+ <td>
<a href="http://code.google.com/apis/visualization/documentation/gallery/motionchart.html">Motion Chart</a>
</td>
<td>
View
1 src/groovy/org/grails/plugins/google/visualization/GoogleVisualization.groovy
@@ -41,6 +41,7 @@ enum GoogleVisualization {
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),
+ GEO_CHART('geochart', 'google.visualization.GeoChart', GeoChartConfigOption.configOptions, GeoChartEvent.events),
MOTION_CHART('motionchart', 'google.visualization.MotionChart', MotionChartConfigOption.configOptions, MotionChartEvent.events),
PIE_CORE_CHART('corechart', 'google.visualization.PieChart', PieCoreChartConfigOption.configOptions, ErrorAwareDefaultEvent.events),
BAR_CORE_CHART('corechart', 'google.visualization.BarChart', BarCoreChartConfigOption.configOptions, ErrorAwareDefaultEvent.events),
View
49 src/groovy/org/grails/plugins/google/visualization/event/GeoChartEvent.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.Log
+import org.apache.commons.logging.LogFactory
+
+/**
+ * Available events for visualization "Geo Chart"
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+enum GeoChartEvent {
+ ERROR('error'), SELECT('select'), REGIONCLICK('regionClick'), READY('ready')
+
+ static final Log log = LogFactory.getLog(GeoChartEvent)
+ static final Map events
+
+ static {
+ events = [:]
+
+ values().each { event ->
+ events.put(event.name, event)
+ }
+ }
+
+ private final name
+
+ GeoChartEvent(name) {
+ this.name = name
+ }
+
+ @Override
+ String toString() {
+ "GeoChartEvent{name='${name}'}"
+ }
+}
View
54 src/groovy/org/grails/plugins/google/visualization/option/GeoChartConfigOption.groovy
@@ -0,0 +1,54 @@
+/* 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.option
+
+import org.grails.plugins.google.visualization.data.DataType
+
+/**
+ * Geo Chart configuration options
+ *
+ * @author <a href='mailto:benjamin.muschko@gmail.com'>Benjamin Muschko</a>
+ */
+enum GeoChartConfigOption {
+ REGION("region", [DataType.STRING]),
+ WIDTH("width", [DataType.NUMBER]),
+ HEIGHT("height", [DataType.NUMBER]),
+ BACKGROUND_COLOR("colors", [DataType.STRING, DataType.OBJECT]),
+ COLORS("colors", [DataType.ARRAY]),
+ RESOLUTION("resolution", [DataType.STRING])
+
+ static final Map configOptions
+
+ static {
+ configOptions = [:]
+
+ values().each { configOption ->
+ configOptions.put(configOption.name, configOption)
+ }
+ }
+
+ private final name
+ private final types
+
+ GeoChartConfigOption(name, types) {
+ this.name = name
+ this.types = types
+ }
+
+ @Override
+ String toString() {
+ "GeoChartConfigOption{name='${name}', types='${types}'}"
+ }
+}
View
2 src/groovy/org/grails/plugins/google/visualization/option/GeoMapConfigOption.groovy
@@ -23,7 +23,7 @@ import org.grails.plugins.google.visualization.data.DataType
*/
enum GeoMapConfigOption {
REGION("region", [DataType.STRING]),
- DATE_MODE("dataMode", [DataType.STRING]),
+ DATA_MODE("dataMode", [DataType.STRING]),
WIDTH("width", [DataType.NUMBER]),
HEIGHT("height", [DataType.NUMBER]),
COLORS("colors", [DataType.ARRAY]),

0 comments on commit 667bb22

Please sign in to comment.
Something went wrong with that request. Please try again.