commit/galaxy-central: guerler: Charts: Improve job handling and heatmaps
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/7c9b64b44298/ Changeset: 7c9b64b44298 User: guerler Date: 2014-05-09 07:09:54 Summary: Charts: Improve job handling and heatmaps Affected #: 5 files diff -r 96242495c567a287bdb4bc26e05b70403c732f24 -r 7c9b64b44298ceef9d5d9935ce5cd3736f9b36f6 config/plugins/visualizations/charts/static/charts/heatmap/config.js --- a/config/plugins/visualizations/charts/static/charts/heatmap/config.js +++ b/config/plugins/visualizations/charts/static/charts/heatmap/config.js @@ -5,15 +5,16 @@ library : '', tag : 'div', use_panels : true, + execute : 'heatmap', // columns columns : { - col_label : { - title : 'Columns', + row_label : { + title : 'Row labels', is_label : true }, - row_label : { - title : 'Rows', + col_label : { + title : 'Column labels', is_label : true }, value : { @@ -23,6 +24,50 @@ // settings settings: { + /*limit : { + title : 'Limit', + info : 'Which to ranked clusters would you like to visualize', + type : 'select', + init : '20', + data : [ + { + label : '20', + value : '20' + }, + { + label : '30', + value : '30' + }, + { + label : '40', + value : '40' + }, + { + label : '50', + value : '50' + }, + { + label : '60', + value : '60' + }, + { + label : '70', + value : '70' + }, + { + label : '80', + value : '80' + }, + { + label : '90', + value : '90' + }, + { + label : '100', + value : '100' + } + ] + },*/ color_set : { title : 'Color scheme', info : 'Select a color scheme for your heatmap', diff -r 96242495c567a287bdb4bc26e05b70403c732f24 -r 7c9b64b44298ceef9d5d9935ce5cd3736f9b36f6 config/plugins/visualizations/charts/static/charts/heatmap/heatmap.js --- a/config/plugins/visualizations/charts/static/charts/heatmap/heatmap.js +++ b/config/plugins/visualizations/charts/static/charts/heatmap/heatmap.js @@ -14,12 +14,35 @@ // render draw : function(process_id, chart, request_dictionary) { - // request data + // link this var self = this; - this.app.datasets.request(request_dictionary, function() { + + // loop through data groups + var index = 0; + for (var group_index in request_dictionary.groups) { - // loop through data groups - for (var group_index in request_dictionary.groups) { + // configure request + for (var i in request_dictionary.groups) { + var group = request_dictionary.groups[i]; + group.columns = null; + group.columns = { + row_label: { + index : index++, + is_label : true + }, + col_label: { + index : index++, + is_label : true + }, + value: { + index : index++ + } + } + } + + // request data + this.app.datasets.request(request_dictionary, function() { + // get group var group = request_dictionary.groups[group_index]; var div = self.options.canvas[group_index]; @@ -31,14 +54,17 @@ 'data' : group.values, 'div' : div }); - } - - // set chart state - chart.state('ok', 'Heat map drawn.'); - // unregister process - chart.deferred.done(process_id); - }); + // check if done + if (group_index == request_dictionary.groups.length - 1) { + // set chart state + chart.state('ok', 'Heat map drawn.'); + + // unregister process + chart.deferred.done(process_id); + } + }); + } } }); diff -r 96242495c567a287bdb4bc26e05b70403c732f24 -r 7c9b64b44298ceef9d5d9935ce5cd3736f9b36f6 config/plugins/visualizations/charts/static/charts/types.js --- a/config/plugins/visualizations/charts/static/charts/types.js +++ b/config/plugins/visualizations/charts/static/charts/types.js @@ -27,8 +27,8 @@ // types defaults: { 'nvd3_bardiagram' : nvd3_bardiagram, + 'nvd3_horizontal' : nvd3_horizontal, 'heatmap' : heatmap, - 'nvd3_horizontal' : nvd3_horizontal, 'nvd3_histogram' : nvd3_histogram, 'nvd3_line' : nvd3_line, 'nvd3_linewithfocus' : nvd3_linewithfocus, diff -r 96242495c567a287bdb4bc26e05b70403c732f24 -r 7c9b64b44298ceef9d5d9935ce5cd3736f9b36f6 config/plugins/visualizations/charts/static/library/jobs.js --- a/config/plugins/visualizations/charts/static/library/jobs.js +++ b/config/plugins/visualizations/charts/static/library/jobs.js @@ -13,12 +13,33 @@ this.options = Utils.merge(options, this.optionsDefault); }, + // request job results + request: function(chart, settings_string, columns_string, success, error) { + // link this + var self = this; + + // set chart state + chart.state('wait', 'Requesting job results...'); + + // get dataset job id if already set + var dataset_id_job = chart.get('dataset_id_job'); + if (dataset_id_job != '') { + // wait for job completion + self._wait(chart, success, error); + } else { + // post job + self._submit(chart, settings_string, columns_string, success, error); + } + }, + // clean cleanup: function(chart) { + // link this + var self = this; + // cleanup previous dataset file var previous = chart.get('dataset_id_job'); if (previous != '') { - var self = this; Utils.request('PUT', config.root + 'api/histories/none/contents/' + previous, { deleted: true }, function() { // update galaxy history self._refreshHdas(); @@ -30,13 +51,13 @@ }, // create job - submit: function(chart, settings_string, columns_string, success, error) { + _submit: function(chart, settings_string, columns_string, success, error) { // link this var self = this; // backup chart details - var chart_id = chart.id; - var chart_type = chart.get('type'); + var chart_id = chart.id; + var chart_type = chart.get('type'); // get chart settings var chart_settings = this.app.types.get(chart_type); @@ -75,7 +96,7 @@ var job = response.outputs[0]; // check dataset - chart.state('wait', 'Job has been queued...'); + chart.state('wait', 'Your job has been queued. You may close the browser window. The job will run in the background.'); // backup resulting dataset id chart.set('dataset_id_job', job.id); @@ -84,34 +105,7 @@ this.app.storage.save(); // wait for job completion - self._loop(job.id, function(job) { - switch (job.state) { - case 'ok': - // update state - chart.state('wait', 'Job completed successfully...'); - - // execute success - success(job); - - // stop loop - return true; - case 'error': - // update state - chart.state('failed', 'Job has failed. Please check the history for details.'); - - // call error - error && error(); - - // stop loop - return true; - case 'running': - // wait - chart.state('wait', 'Job is running...'); - - // continue loop - return false; - } - }); + self._wait(chart, success, error); } }, // error handler @@ -132,11 +126,42 @@ }, // request job details - _loop: function(id, callback) { + _wait: function(chart, success, error) { var self = this; - Utils.request('GET', config.root + 'api/datasets/' + id, {}, function(job) { - if (!callback(job)) { - setTimeout(function() { self._loop(id, callback); }, self.app.config.get('query_timeout')); + Utils.request('GET', config.root + 'api/datasets/' + chart.get('dataset_id_job'), {}, function(dataset) { + // check dataset state + var ready = false; + switch (dataset.state) { + case 'ok': + // update state + chart.state('wait', 'Job completed successfully...'); + + // execute success + success && success(dataset); + + // stop loop + ready = true; + break; + case 'error': + // update state + chart.state('failed', 'Job has failed. Please check the history for details.'); + + // call error + error && error(dataset); + + // stop loop + ready = true; + break; + case 'running': + // wait + chart.state('wait', 'Your job is running. You may close the browser window. The job will continue in the background.'); + } + + // wait and try again + if (!ready) { + setTimeout(function() { + self._wait(chart, success, error); + }, self.app.config.get('query_timeout')); } }); }, diff -r 96242495c567a287bdb4bc26e05b70403c732f24 -r 7c9b64b44298ceef9d5d9935ce5cd3736f9b36f6 config/plugins/visualizations/charts/static/views/viewport.js --- a/config/plugins/visualizations/charts/static/views/viewport.js +++ b/config/plugins/visualizations/charts/static/views/viewport.js @@ -173,19 +173,14 @@ // request data if (self.chart_settings.execute) { - if (chart.get('dataset_id_job') == '') { - // submit job - self.app.jobs.submit(chart, self._defaultSettingsString(chart), self._defaultRequestString(chart), - function() { - view.draw(process_id, chart, self._defaultRequestDictionary(chart)); - }, - function() { - chart.deferred.done(process_id); - }); - } else { - // load data into view - view.draw(process_id, chart, self._defaultRequestDictionary(chart)); - } + self.app.jobs.request(chart, self._defaultSettingsString(chart), self._defaultRequestString(chart), + function() { + view.draw(process_id, chart, self._defaultRequestDictionary(chart)); + }, + function() { + chart.deferred.done(process_id); + } + ); } else { // load data into view view.draw(process_id, chart, self._defaultRequestDictionary(chart)); Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org