1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/5ca863b3b300/ Changeset: 5ca863b3b300 User: guerler Date: 2014-04-17 16:45:18 Summary: Charts: Improve handling of different scales/distributions Affected #: 1 file diff -r c055181847a46dc3199458d899d28d559ae43c38 -r 5ca863b3b300a552a44f1607cc565842538894c6 config/plugins/visualizations/charts/static/charts/nvd3_histogram/nvd3_histogram.js --- a/config/plugins/visualizations/charts/static/charts/nvd3_histogram/nvd3_histogram.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3_histogram/nvd3_histogram.js @@ -26,9 +26,56 @@ }, } } - + + // link this + var self = this; + + // load nvd3 var nvd3 = new NVD3(this.app, this.options); - nvd3.draw(process_id, nv.models.multiBarChart(), chart, request_dictionary); + nvd3.draw(process_id, nv.models.multiBarChart(), chart, request_dictionary, function() { + // ensure data consistency + self._fix_partial_data(request_dictionary.groups); + }); + }, + + // the histogram module might generate partial data i.e. length(col1) = 10, length(col2) = 11, length(col3) = 12. + // this function ensures that data is consistent, such that all columns have the same length. + _fix_partial_data: function(groups) { + // x-values + var x_list = {}; + + // identify all x values + for (var i in groups) { + var x_sub = this._identify_x_values(groups[i].values); + x_list = _.extend(x_list, x_sub); + } + + // identify all x values + for (var i in groups) { + var values = groups[i].values; + var x_sub = this._identify_x_values(values); + for (var x in x_list) { + if (x_sub[x] === undefined) { + values.push({ + x: parseFloat(x), + y: 0.0 + }); + } + } + values.sort(function(a, b) {return a.x - b.x}) + } + }, + + // identify available x-values + _identify_x_values: function(values) { + var x_list = {}; + for (var j in values) { + var x_value = values[j].x; + if (x_value !== undefined && x_value !== null) { + x_list[x_value] = true; + } + } + return x_list; } }); 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.