Changeset 2058


Ignore:
Timestamp:
Oct 13, 2011, 2:46:21 PM (11 years ago)
Author:
taco@…
Message:

visualization/VisualizeController.groovy, 'formatData' function, the 'sort' closure now uses the String representations of the objects it sorts. This is good, because otherwise it doesn't actually sort the items alphabetically.

File:
1 edited

Legend:

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

    r2056 r2058  
    343343            returnData = formatData( inputData.visualizationType, groupedData, fields, groupAxisType, valueAxisType ); // Don't indicate axis ordering, standard <"x", "y"> will be used
    344344        }
    345         println "returnData: "+returnData
    346345        return sendResults(returnData)
    347346        }
     
    672671         */
    673672        def formatData( type, groupedData, fields, groupAxisType, valueAxisType, groupAxis = "x", valueAxis = "y", errorName = "error" ) {
    674                 // We want to sort the data based on the group-axis, but keep the values on the value-axis in sync. 
     673                // We want to sort the data based on the group-axis, but keep the values on the value-axis in sync.
    675674                // The only way seems to be to combine data from both axes.
    676675        def combined = []
     
    679678                combined << [ "group": group, "data": groupedData[ 'data' ][ i ] ]
    680679            }
    681             combined.sort { it.group }
     680            combined.sort { it.group.toString() }
    682681            groupedData[groupAxis] = renderTimesAndDatesHumanReadable(combined*.group, groupAxisType)
    683682            groupedData[valueAxis] = renderTimesAndDatesHumanReadable(groupedData[valueAxis], valueAxisType)
     
    687686                combined << [ "group": group, "value": groupedData[ valueAxis ][ i ] ]
    688687            }
    689             combined.sort { it.group }
     688            combined.sort { it.group.toString() }
    690689            groupedData[groupAxis] = renderTimesAndDatesHumanReadable(combined*.group, groupAxisType)
    691690            groupedData[valueAxis] = renderTimesAndDatesHumanReadable(combined*.value, valueAxisType)
    692691        }
    693 
    694692        // TODO: Handle name and unit of fields correctly
    695693        def valueAxisTypeString = (valueAxisType==CATEGORICALDATA || valueAxisType==DATE || valueAxisType==RELTIME ? "categorical" : "numerical")
     
    735733    def renderTimesAndDatesHumanReadable(data, axisType){
    736734        if(axisType==RELTIME){
    737             println "RELTIME"
    738735            data = renderTimesHumanReadable(data)
    739736        }
    740737        if(axisType==DATE){
    741             println "DATE"
    742738           data = renderDatesHumanReadable(data)
    743739        }
    744         println "NO JOY"
    745740        return data
    746741    }
     
    754749        def tmpTimeContainer = []
    755750        data. each {
    756             println "\t"+it
    757751            if(it instanceof Number) {
    758752                try{
     
    776770        def tmpDateContainer = []
    777771        data. each {
    778             println "\t"+it
    779772            if(it instanceof Number) {
    780773                try{
Note: See TracChangeset for help on using the changeset viewer.