Changeset 2056
- Timestamp:
- Oct 13, 2011, 12:57:58 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/visualization/VisualizeController.groovy
r2055 r2056 332 332 groupedData = groupFieldData( inputData.visualizationType, data ); // Don't indicate axis ordering, standard <"x", "y"> will be used 333 333 } 334 335 334 // Format data so it can be rendered as JSON 336 335 def returnData … … 344 343 returnData = formatData( inputData.visualizationType, groupedData, fields, groupAxisType, valueAxisType ); // Don't indicate axis ordering, standard <"x", "y"> will be used 345 344 } 345 println "returnData: "+returnData 346 346 return sendResults(returnData) 347 347 } … … 674 674 // We want to sort the data based on the group-axis, but keep the values on the value-axis in sync. 675 675 // The only way seems to be to combine data from both axes. 676 def combined = [] 677 groupedData[ groupAxis ].eachWithIndex { group, i -> 678 combined << [ "group": group, "value": groupedData[ valueAxis ][ i ] ] 679 } 680 combined.sort { it.group } 681 676 def combined = [] 677 if(type=="table"){ 678 groupedData[ groupAxis ].eachWithIndex { group, i -> 679 combined << [ "group": group, "data": groupedData[ 'data' ][ i ] ] 680 } 681 combined.sort { it.group } 682 groupedData[groupAxis] = renderTimesAndDatesHumanReadable(combined*.group, groupAxisType) 683 groupedData[valueAxis] = renderTimesAndDatesHumanReadable(groupedData[valueAxis], valueAxisType) 684 groupedData["data"] = combined*.data 685 } else { 686 groupedData[ groupAxis ].eachWithIndex { group, i -> 687 combined << [ "group": group, "value": groupedData[ valueAxis ][ i ] ] 688 } 689 combined.sort { it.group } 690 groupedData[groupAxis] = renderTimesAndDatesHumanReadable(combined*.group, groupAxisType) 691 groupedData[valueAxis] = renderTimesAndDatesHumanReadable(combined*.value, valueAxisType) 692 } 693 682 694 // TODO: Handle name and unit of fields correctly 683 695 def valueAxisTypeString = (valueAxisType==CATEGORICALDATA || valueAxisType==DATE || valueAxisType==RELTIME ? "categorical" : "numerical") 684 696 def groupAxisTypeString = (groupAxisType==CATEGORICALDATA || groupAxisType==DATE || groupAxisType==RELTIME ? "categorical" : "numerical") 685 groupedData[groupAxis] = renderTimesAndDatesHumanReadable(combined*.group, groupAxisType)686 groupedData[valueAxis] = renderTimesAndDatesHumanReadable(combined*.value, valueAxisType)687 697 688 698 if(type=="table"){ … … 725 735 def renderTimesAndDatesHumanReadable(data, axisType){ 726 736 if(axisType==RELTIME){ 737 println "RELTIME" 727 738 data = renderTimesHumanReadable(data) 728 739 } 729 740 if(axisType==DATE){ 741 println "DATE" 730 742 data = renderDatesHumanReadable(data) 731 743 } 744 println "NO JOY" 732 745 return data 733 746 } … … 741 754 def tmpTimeContainer = [] 742 755 data. each { 756 println "\t"+it 743 757 if(it instanceof Number) { 744 758 try{ … … 762 776 def tmpDateContainer = [] 763 777 data. each { 778 println "\t"+it 764 779 if(it instanceof Number) { 765 780 try{
Note: See TracChangeset
for help on using the changeset viewer.