- Timestamp:
- 04/10/13 13:29:24 (12 years ago)
- Location:
- branches/OaaS/HeuristicLab.Services.Optimization.Web/Content
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/experiment.view.js
r9335 r9350 824 824 var datatableSelect = $('.datatableOptions', ele); 825 825 826 var names = _.reduce(this.model.models, function (arr, model) { 827 return _.union(arr, _.map(model.get('results'), function (elem) { return elem.Name })); 828 }, []); 829 826 var names = []; 827 var previouslyFound = { results: {}, params: {} }; 828 _.each(this.model.models, function (model) { 829 _.each(model.get('results'), function (res) { 830 if (!previouslyFound['results'][res.Name]) { 831 previouslyFound['results'][res.Name] = true; 832 names.push({ name: res.Name, source: 'results' }); 833 } 834 }); 835 _.each(model.get('params'), function (res) { 836 if (!previouslyFound['params'][res.Name]) { 837 previouslyFound['params'][res.Name] = true; 838 names.push({ name: res.Name, source: 'params' }); 839 } 840 }); 841 }); 842 previouslyFound = {}; 843 this.options.modelMapping = names; 830 844 this.bubbleSelect = $('select[class="bubbleSize"]', ele); 831 845 832 _.each(names, function ( name) {833 var option = $("<option />", { value: name, text:name });846 _.each(names, function (entry) { 847 var option = $("<option />", { value: entry.name, text: entry.name }); 834 848 option.clone().appendTo(xAxisSelect); 835 849 option.clone().appendTo(yAxisSelect); … … 837 851 var rowNames = null; 838 852 var foundModel = _.find(self.model.models, function (model) { 839 var e ntry = _.find(model.get('results'), function (entry) { return entry.Name == name && entry.RowNames });840 if (e ntry)841 rowNames = e ntry.RowNames;842 return e ntry && entry.RowNames;853 var e = _.find(model.get(entry.source), function (e) { return e.Name == entry.name && e.RowNames }); 854 if (e) 855 rowNames = e.RowNames; 856 return e && e.RowNames; 843 857 }); 844 858 if (rowNames) { 845 self.options.datatables[ name] = rowNames;846 $('<option />', { value: name, text:name }).appendTo(datatableSelect);859 self.options.datatables[entry.name] = rowNames; 860 $('<option />', { value: entry.name, text: entry.name }).appendTo(datatableSelect); 847 861 } 848 862 }); … … 852 866 this.options.xAxis = this.model.models[0].get('results')[0].Name; 853 867 this.options.yAxis = this.options.xAxis; 868 this.options.selectedXIndex = 0; 869 this.options.selectedYIndex = 0; 854 870 this.options.plot = 'Boxplot'; 855 871 $('div[class="bubbleSlider"]', ele).slider({ … … 909 925 xAxisSelected: function (evt) { 910 926 var target = $(evt.target); 927 this.options.selectedXIndex = target.prop("selectedIndex"); 911 928 this.options.xAxis = target.val(); 912 929 this.createPlot(); … … 914 931 yAxisSelected: function (evt) { 915 932 var target = $(evt.target); 933 this.options.selectedYIndex = target.prop("selectedIndex"); 916 934 this.options.yAxis = target.val(); 917 935 this.createPlot(); … … 967 985 createBoxplot: function () { 968 986 var self = this; 969 987 var parameterXSource = this.options.modelMapping[this.options.selectedXIndex].source; // either 'params' or 'results' 988 var parameterYSource = this.options.modelMapping[this.options.selectedYIndex].source; // either 'params' or 'results' 970 989 // prepare data for boxplot 971 990 var values = {}; 972 991 for (var i = 0; i < this.model.models.length; i++) { 973 var xlabel = _.find(this.model.models[i].get( 'results'), function (itm) { return itm.Name == self.options.xAxis });992 var xlabel = _.find(this.model.models[i].get(parameterXSource), function (itm) { return itm.Name == self.options.xAxis }); 974 993 if (!xlabel) 975 994 continue; 976 995 977 996 if ($.isArray(xlabel.Value)) 978 values[ xlabel.Name + ' = ' + xlabel.Value[0]] = [];997 values[parameterXSource + '.' + xlabel.Name + ' = ' + xlabel.Value[0]] = []; 979 998 else 980 values[ xlabel.Name + ' = ' + xlabel.Value] = [];999 values[parameterXSource + '.' + xlabel.Name + ' = ' + xlabel.Value] = []; 981 1000 } 982 1001 983 1002 for (var i = 0; i < this.model.models.length; i++) { 984 var xlabel = _.find(this.model.models[i].get( 'results'), function (itm) { return itm.Name == self.options.xAxis });985 var entry = _.find(this.model.models[i].get( 'results'), function (itm) { return itm.Name == self.options.yAxis });1003 var xlabel = _.find(this.model.models[i].get(parameterXSource), function (itm) { return itm.Name == self.options.xAxis }); 1004 var entry = _.find(this.model.models[i].get(parameterYSource), function (itm) { return itm.Name == self.options.yAxis }); 986 1005 if (!xlabel || !entry || !entry.Value) 987 1006 continue; 988 1007 989 var index = xlabel.Name + ' = ' + ($.isArray(xlabel.Value) ? xlabel.Value[0] : xlabel.Value);1008 var index = parameterXSource + '.' + xlabel.Name + ' = ' + ($.isArray(xlabel.Value) ? xlabel.Value[0] : xlabel.Value); 990 1009 991 1010 if ($.isArray(entry.Value)) … … 1003 1022 createBubblechart: function () { 1004 1023 var self = this; 1005 1024 var parameterXSource = this.options.modelMapping[this.options.selectedXIndex].source; // either 'params' or 'results' 1025 var parameterYSource = this.options.modelMapping[this.options.selectedYIndex].source; // either 'params' or 'results' 1006 1026 // prepare data for bubble chart 1007 1027 var values = []; 1008 1028 var autoscaleBubbles = this.bubbleSelect.val() != 'Constant'; 1009 1029 for (var i = 0; i < this.model.models.length; i++) { 1010 var xValue = _.find(this.model.models[i].get( 'results'), function (itm) { return itm.Name == self.options.xAxis });1011 var yValue = _.find(this.model.models[i].get( 'results'), function (itm) { return itm.Name == self.options.yAxis });1030 var xValue = _.find(this.model.models[i].get(parameterXSource), function (itm) { return itm.Name == self.options.xAxis }); 1031 var yValue = _.find(this.model.models[i].get(parameterYSource), function (itm) { return itm.Name == self.options.yAxis }); 1012 1032 if (!xValue || !yValue) 1013 1033 continue; … … 1019 1039 } else { 1020 1040 var valueProvider = _.find(this.model.models[i].get('results'), function (itm) { return itm.Name == self.bubbleSelect.val(); }); 1021 if (!valueProvider) { 1041 if (!valueProvider) 1042 valueProvider = _.find(this.model.models[i].get('params'), function (itm) { return itm.Name == self.bubbleSelect.val(); }); 1043 1044 if (!valueProvider) { 1022 1045 size = this.options.bubbleSize; 1023 1046 } else { … … 1055 1078 for (var i = 0; i < this.model.models.length; i++) { 1056 1079 var table = _.find(this.model.models[i].get('results'), function (itm) { return itm.Name == self.options.selectedDatatable }); 1080 if (!table) 1081 table = _.find(this.model.models[i].get('params'), function (itm) { return itm.Name == self.options.selectedDatatable }); 1082 1057 1083 if (!table) 1058 1084 continue; -
branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/job.model.js
r9324 r9350 37 37 poll: function () { 38 38 var self = this; 39 this.fetch({ cache: false, update: true, success: function () {39 this.fetch({ cache: false, reset: true, success: function () { 40 40 self._poll(); 41 41 } -
branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/job.view.js
r9335 r9350 16 16 initialize: function () { 17 17 this.collection.bind('remove', this.render, this); 18 //this.collection.bind('a', this.render, this);19 18 }, 20 19 render: function () { … … 89 88 rcv.render(); 90 89 for (var i = 0; i < this.model.models.length; i++) { 90 $('<h3></h3>').text(this.model.models[i].get('name')).appendTo(this.$el); 91 91 var rev = new my.ResultEntryView({ model: this.model.models[i], el: this.$el }); 92 92 rev.render(); … … 150 150 initialize: function () { 151 151 this.plotted = {}; 152 this.plotted['params'] = {}; 153 this.plotted['results'] = {}; 152 154 }, 153 155 render: function () { 154 156 this.template = _.template($('#runTemplate').html()); 155 157 var table = $(this.template(this.model.attributes)); 156 var body = $( "tbody", table);158 var body = $('tbody[class="results"]', table); 157 159 table.appendTo(this.$el); 160 // render the results of the model 158 161 var results = this.model.get('results'); 159 162 for (var i = 0; i < results.length; i++) { 160 var row = $('<tr/>').attr('data-index', i); 161 $('<td/>').text(results[i].Name).appendTo(row); 162 if ($.isArray(results[i].Value)) { 163 var col = $('<td/>').appendTo(row); 164 var tevDiv = $('<div/>'); 165 var plotDiv = $('<div/>').appendTo($('#tmp'));; 166 this.plotted[i] = {}; 167 var tv = new my.TabView({ 168 model: [ 169 { name: 'Table', content: tevDiv }, 170 { name: 'Plot', content: plotDiv }, 171 ], 172 el: col 173 }); 174 this.listenTo(tv, 'tab-activated', this.tabActivated); 175 tv.render(); 176 177 } 178 else { 179 $('<td/>').text(results[i].Value).appendTo(row); 180 } 181 row.appendTo(body); 182 } 163 this.renderModelEntry(results[i], i, body, 'results'); 164 } 165 166 var inputs = this.model.get('params'); 167 body = $('tbody[class="inputs"]', table); 168 for (var i = 0; i < inputs.length; i++) { 169 this.renderModelEntry(inputs[i], i, body, 'params'); 170 } 171 172 var av = new my.AccordionView({el: $(table)}); 173 av.render(); 174 }, 175 renderModelEntry: function(entry, index, body, attribute) { 176 var row = $('<tr/>').attr('data-index', index).attr('data-attribute', attribute); 177 $('<td/>').text(entry.Name).appendTo(row); 178 if ($.isArray(entry.Value)) { 179 var col = $('<td/>').appendTo(row); 180 var tevDiv = $('<div/>'); 181 var plotDiv = $('<div/>').appendTo($('#tmp')); 182 this.plotted[attribute][index] = {}; 183 var tv = new my.TabView({ 184 model: [ 185 { name: 'Table', content: tevDiv }, 186 { name: 'Plot', content: plotDiv }, 187 ], 188 el: col 189 }); 190 this.listenTo(tv, 'tab-activated', this.tabActivated); 191 tv.render(); 192 } 193 else { 194 $('<td/>').text(entry.Value).appendTo(row); 195 } 196 row.appendTo(body); 183 197 }, 184 198 tabActivated: function (evt) { 185 199 var index = parseInt(evt.element.parents('tr').attr('data-index')); 186 if (evt.name == 'Plot' && !this.plotted[index].Plot) { 187 this.plotted[index].Plot = true; 200 var attribute = evt.element.parents('tr').attr('data-attribute'); 201 if (evt.name == 'Plot' && !this.plotted[attribute][index].Plot) { 202 this.plotted[attribute][index].Plot = true; 188 203 var plotDiv = $('<div/>').appendTo($('#tmp')); 189 var pv = new my.PlotView({ model: this.model.get( 'results')[index], el: plotDiv, transpose: true });204 var pv = new my.PlotView({ model: this.model.get(attribute)[index], el: plotDiv, transpose: true }); 190 205 pv.render(); 191 206 plotDiv.appendTo(evt.element); … … 198 213 }); 199 214 rv.render(); 200 } else if (evt.name == 'Table' && !this.plotted[index].Table) { 201 this.plotted[index].Table = true; 202 var tevDiv = $('<div/>'); 203 var tev = new my.TableEditView({ model: this.model.get('results')[index].Value, rowNames: this.model.get('results')[index].RowNames, useDatatable: true, el: tevDiv }); 215 plotDiv.width(rv.$el.width()); 216 plotDiv.height(rv.$el.height()); 217 pv.refresh(); 218 } else if (evt.name == 'Table' && !this.plotted[attribute][index].Table) { 219 this.plotted[attribute][index].Table = true; 220 var tevDiv = $('<div/>').css('overflow', 'scroll'); 221 var tev = new my.TableEditView({ model: this.model.get(attribute)[index].Value, rowNames: this.model.get(attribute)[index].RowNames, useDatatable: true, el: tevDiv }); 204 222 tev.render(); 205 223 tevDiv.appendTo(evt.element)
Note: See TracChangeset
for help on using the changeset viewer.