Changeset 2029


Ignore:
Timestamp:
Sep 22, 2011, 4:10:30 PM (9 years ago)
Author:
taco@…
Message:

visualization/VisualizeController.groovy, updating the 'getData' function according to 'VIS-19 Change getData to return data for more visualization types'. The 'table' functionality has not been implemented yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/visualization/VisualizeController.groovy

    r2023 r2029  
    297297   
    298298        // Format data so it can be rendered as JSON
    299         def returnData = formatData( groupedData, fields );
     299        def returnData = formatData( inputData.visualizationType, groupedData, fields );
    300300        return sendResults(returnData)
    301301        }
     
    519519                        {
    520520                                "type": "barchart",
    521                                 "x": [ "Q1", "Q2", "Q3", "Q4" ],
    522521                                "xaxis": { "title": "quarter 2011", "unit": "" },
    523522                                "yaxis": { "title": "temperature", "unit": "degrees C" },
     
    526525                                                "name": "series name",
    527526                                                "y": [ 5.1, 3.1, 20.6, 15.4 ],
     527                        "x": [ "Q1", "Q2", "Q3", "Q4" ],
    528528                                                "error": [ 0.5, 0.2, 0.4, 0.5 ]
    529529                                        },
     
    532532         *
    533533         */
    534         def formatData( groupedData, fields, groupAxis = "x", valueAxis = "y", errorName = "error" ) {
     534        def formatData( type, groupedData, fields, groupAxis = "x", valueAxis = "y", errorName = "error" ) {
    535535                // TODO: Handle name and unit of fields correctly
    536536                def xAxis = groupedData[ groupAxis ].collect { it.toString() };
     
    538538               
    539539                def return_data = [:]
    540                 return_data[ "type" ] = "barchart"
    541                 return_data[ "x" ] = xAxis
     540                return_data[ "type" ] = type
    542541                return_data.put("yaxis", ["title" : yName, "unit" : "" ])
    543542                return_data.put("xaxis", ["title" : parseFieldId( fields[ groupAxis ] ).name, "unit": "" ])
     
    729728       }
    730729    }
    731     Exception e
     730   
    732731        /**
    733732         * Return the numeric value of the given object, or null if no numeric value could be returned
     
    901900    }
    902901
    903 
    904902    /**
    905903     * Properly formats the object that will be returned to the client. Also adds an informational message, if that message has been set by a function. Resets the informational message to the empty String.
     
    976974     */
    977975    protected def formatCategoryData(inputData){
     976        // NOTE: This function is no longer up to date with the current inputData layout.
    978977        def series = []
    979978        inputData.eachWithIndex { it, i ->
Note: See TracChangeset for help on using the changeset viewer.