diff --git a/grails-app/controllers/org/sacredheart/DashboardController.groovy b/grails-app/controllers/org/sacredheart/DashboardController.groovy
new file mode 100644
index 0000000..e6eb29e
--- /dev/null
+++ b/grails-app/controllers/org/sacredheart/DashboardController.groovy
@@ -0,0 +1,20 @@
+package org.sacredheart
+
+import grails.converters.JSON
+
+/**
+ * Dashboard data controller.
+ */
+class DashboardController {
+
+ /**
+ * Get the language data for all the patients.
+ */
+ def languageData() {
+ render Patient.LANGUAGE.collect { lang ->
+ def count = Patient.countByLanguage(lang)
+ def display = message(code:"patient.language.select.${lang}")
+ [display, count]
+ } as JSON
+ }
+}
diff --git a/grails-app/views/index.gsp b/grails-app/views/index.gsp
index 78f6bae..fb9807d 100644
--- a/grails-app/views/index.gsp
+++ b/grails-app/views/index.gsp
@@ -72,7 +72,7 @@
@@ -88,27 +88,7 @@
genderChart();
citizenChart();
raceChart();
- veteranChart();
- }
-
- function veteranChart() {
- // Create the data table.
- var data = new google.visualization.DataTable();
- data.addColumn('string', 'Population of Veterans');
- data.addColumn('number', '#');
- data.addRows([
- ['Veteran', ${Patient.countByVeteran(YesNo.Yes)}],
- ['Civilian', ${Patient.countByVeteran(YesNo.No)}]
- ]);
-
- // Set chart options
- var options = {'title':'Population of Veterans',
- 'width':400,
- 'height':300};
-
- // Instantiate and draw our chart, passing in some options.
- var chart = new google.visualization.PieChart(document.getElementById('veteran_chart'));
- chart.draw(data, options);
+ languageChart();
}
function raceChart() {
@@ -174,6 +154,21 @@
var chart = new google.visualization.PieChart(document.getElementById('gender_chart'));
chart.draw(data, options);
}
+
+ function languageChart() {
+ // Create the data table.
+ var data = new google.visualization.DataTable();
+ data.addColumn('string', 'Language');
+ data.addColumn('number', '#');
+ data.addRows(${g.include(controller:'dashboard', action:'languageData')});
+
+ // Set chart options
+ var options = {'title':'Language', 'width':400, 'height':300};
+
+ // Instantiate and draw our chart, passing in some options.
+ var chart = new google.visualization.PieChart(document.getElementById('language_chart'));
+ chart.draw(data, options);
+ }