Added example JSON data object for single Visualization, and a sample JS iteration git-svn-id: http://soc.googlecode.com/svn/wiki@3161 5fae56a1-394a-0410-ba46-5107137fd53f
diff --git a/StatisticsModule.wiki b/StatisticsModule.wiki index 98d389f..bf46667 100644 --- a/StatisticsModule.wiki +++ b/StatisticsModule.wiki
@@ -35,6 +35,52 @@ * Results will be *raw JSON* (at this stage). _Need to decide precise format of this JSON data, (for clarity). An example here would help enormously._ +According to [http://code.google.com/apis/visualization/documentation/using_overview.html#embeddingavis what Google Visualization asks for], something roughly like: +{{{ +{ + "title": "Title of graph", + "columns": [ + { + "type": "string", + "name": "Country" + }, + { + "type": "number", + "name": "N. Students" + } + ], + "rows": [ + { + "rowdata": [ + "Country 1", + 30 + ] + }, + { + "rowdata": [ + "Country 2", + 40 + ] + } + ] +} +}}} + +In this way we can iterate through it as (take it as pseudo-JS-code, didn't test it yet): +{{{ +var data = new google.visualization.DataTable(); +for (var index in json.columns) { + data.addColumn(json.columns[index].type, json.columns[index].name); +} +data.addRows(json.rows.length); +for (var row_index in json.rows) { + for (var column_index in json.rows[row_index].rowdata) { + data.setValue(row_index, column_index, json.rows[row_index].rowdata[column_index]); + } +} + +}}} + === Later Goals for Job Control === * _...insert text here_