Changeset 2047


Ignore:
Timestamp:
Oct 3, 2011, 10:39:37 AM (11 years ago)
Author:
robert@…
Message:

Small visualization bugfixes, added sorting to visualization and added visualization to main menu

Location:
trunk/grails-app
Files:
2 edited

Legend:

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

    r2045 r2047  
    3535         */
    3636        def index = {
    37                 println determineCategoryFromData( [ 0, 10, 20, null ] )
    38                 println determineCategoryFromData( [ null ] )
    39                 println determineCategoryFromData( [ 0, 10, 20, null ] )
    40                 println determineCategoryFromData( [ 0, 10, 20, null ] )
    41                
    4237                [ studies: Study.giveReadableStudies( authenticationService.getLoggedInUser() )]
    4338        }
     
    326321        }
    327322               
    328                 println "Data: " + data;
    329                 println "Grouped: " + groupedData
    330 
    331323        // Format data so it can be rendered as JSON
    332324        def returnData
     
    440432        def getModuleData( study, samples, assay_id, fieldName ) {
    441433                def data = []
    442                 //println "assay_id: "+assay_id+", fieldName: "+fieldName
     434               
    443435                // TODO: Handle values that should be retrieved from multiple assays
    444436        def assay = Assay.get(assay_id);
     
    646638         */
    647639        def formatData( type, groupedData, fields, groupAxisType, valueAxisType, groupAxis = "x", valueAxis = "y", errorName = "error" ) {
     640                // We want to sort the data based on the group-axis, but keep the values on the value-axis in sync.
     641                // The only way seems to be to combine data from both axes.
     642                def combined = []
     643                groupedData[ groupAxis ].eachWithIndex { group, i ->
     644                        combined << [ "group": group, "value": groupedData[ valueAxis ][ i ] ]
     645                }
     646                combined.sort { it.group }
     647               
    648648        // TODO: Handle name and unit of fields correctly
    649 
    650649        def valueAxisTypeString = (valueAxisType==CATEGORICALDATA || valueAxisType==DATE || valueAxisType==RELTIME ? "categorical" : "numerical")
    651650        def groupAxisTypeString = (groupAxisType==CATEGORICALDATA || groupAxisType==DATE || groupAxisType==RELTIME ? "categorical" : "numerical")
    652         groupedData[groupAxis] = renderTimesAndDatesHumanReadable(groupedData[groupAxis], groupAxisType)
    653         groupedData[valueAxis] = renderTimesAndDatesHumanReadable(groupedData[valueAxis], valueAxisType)
     651        groupedData[groupAxis] = renderTimesAndDatesHumanReadable(combined*.group, groupAxisType)
     652        groupedData[valueAxis] = renderTimesAndDatesHumanReadable(combined*.value, valueAxisType)
    654653
    655654        if(type=="table"){
     
    10711070    protected int determineCategoryFromData(inputObject){
    10721071        def results = []
     1072               
    10731073        if(inputObject instanceof Collection){
    10741074            // This data is more complex than a single value, so we will call ourselves again so we c
     
    10781078            }
    10791079        } else {
    1080                         if( inputObject != null ) {
     1080                        // Unfortunately, the JSON null object doesn't resolve to false or equals null. For that reason, we
     1081                        // exclude those objects explicitly here.
     1082                        if( inputObject != null && inputObject?.class != org.codehaus.groovy.grails.web.json.JSONObject$Null ) {
    10811083                    if(inputObject.toString().isDouble()){
    10821084                        results << NUMERICALDATA
     
    10991101        }
    11001102
    1101         return results[0]
     1103                return results[0]
    11021104    }
    11031105
  • trunk/grails-app/views/common/_topnav.gsp

    r1921 r2047  
    6363                                </ul>
    6464                        </li>
     65                        <li><g:link controller="visualize" action="index">Visualizations</g:link></li>
     66                       
    6567                </ul>
    6668        </li>
Note: See TracChangeset for help on using the changeset viewer.