1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/d18b0f6cac6c/ Changeset: d18b0f6cac6c User: guerler Date: 2014-05-22 04:48:11 Summary: Charts: Adds histograms for string columns/bins and generalizes column selection Affected #: 21 files diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/app.css --- a/config/plugins/visualizations/charts/static/app.css +++ b/config/plugins/visualizations/charts/static/app.css @@ -63,5 +63,6 @@ .charts-viewport .charts-viewport-canvas { display: block; width:100%; + min-height: 100px; height: inherit; } \ No newline at end of file diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/charts/heatmap/heatmap-plugin.js --- a/config/plugins/visualizations/charts/static/charts/heatmap/heatmap-plugin.js +++ b/config/plugins/visualizations/charts/static/charts/heatmap/heatmap-plugin.js @@ -285,14 +285,15 @@ } // prepare indices + dataRangeFormat = d3.format('.3f'); var dataRangeMin = 0; - var dataRangeMid = parseInt((dataRange.length - 1) / 2); + var dataRangeMid = ''; var dataRangeMax = dataRange.length - 1; // add labels - dataRange[dataRangeMin] = this.min; + dataRange[dataRangeMin] = dataRangeFormat(this.min); dataRange[dataRangeMid] = this.mid; - dataRange[dataRangeMax] = this.max; + dataRange[dataRangeMax] = dataRangeFormat(this.max); // create legend var legend = this.svg.selectAll('.legend') diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/charts/nvd3/config.js --- a/config/plugins/visualizations/charts/static/charts/nvd3/config.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3/config.js @@ -5,12 +5,7 @@ category : '', library : 'nvd3.js', tag : 'svg', - columns : { - y : { - title : 'Values for y-axis' - } - }, - settings : { + settings : { separator_label : { title : 'X axis', type : 'separator' diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/charts/nvd3/nvd3.js --- a/config/plugins/visualizations/charts/static/charts/nvd3/nvd3.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3/nvd3.js @@ -34,11 +34,13 @@ nvd3_model.options({showControls: false}); // legend - var legend_visible = true; - if (chart.settings.get('show_legend') == 'false') { - legend_visible = false; + if (nvd3_model.showLegend) { + var legend_visible = true; + if (chart.settings.get('show_legend') == 'false') { + legend_visible = false; + } + nvd3_model.showLegend(legend_visible); } - nvd3_model.showLegend(legend_visible); // custom callback if (callback) { diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/charts/nvd3_bar/config.js --- a/config/plugins/visualizations/charts/static/charts/nvd3_bar/config.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3_bar/config.js @@ -2,7 +2,17 @@ return $.extend(true, {}, nvd3_config, { title : 'Regular', - category : 'Bar diagrams' + category : 'Bar diagrams', + columns : { + x : { + title : 'Values for x-axis', + is_label: true, + is_auto : true + }, + y : { + title : 'Values for y-axis' + } + } }); }); \ No newline at end of file diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/charts/nvd3_bar_horizontal/config.js --- a/config/plugins/visualizations/charts/static/charts/nvd3_bar_horizontal/config.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3_bar_horizontal/config.js @@ -3,6 +3,16 @@ return $.extend(true, {}, nvd3_config, { title : 'Horizontal', category : 'Bar diagrams', + columns : { + x : { + title : 'Values for x-axis', + is_label: true, + is_auto : true + }, + y : { + title : 'Values for y-axis' + } + }, settings : { x_axis_type : { init : 'hide' diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/charts/nvd3_bar_horizontal_stacked/config.js --- a/config/plugins/visualizations/charts/static/charts/nvd3_bar_horizontal_stacked/config.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3_bar_horizontal_stacked/config.js @@ -7,6 +7,16 @@ x_axis_type : { init : 'hide' } + }, + columns : { + x : { + title : 'Values for x-axis', + is_label: true, + is_auto : true + }, + y : { + title : 'Values for y-axis' + } } }); diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/charts/nvd3_bar_stacked/config.js --- a/config/plugins/visualizations/charts/static/charts/nvd3_bar_stacked/config.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3_bar_stacked/config.js @@ -2,7 +2,17 @@ return $.extend(true, {}, nvd3_config, { title : 'Stacked', - category : 'Bar diagrams' + category : 'Bar diagrams', + columns : { + x : { + title : 'Values for x-axis', + is_label: true, + is_auto : true + }, + y : { + title : 'Values for y-axis' + } + } }); }); \ No newline at end of file diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/charts/nvd3_histogram_discrete/config.js --- a/config/plugins/visualizations/charts/static/charts/nvd3_histogram_discrete/config.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3_histogram_discrete/config.js @@ -5,7 +5,7 @@ category : 'Data processing (requires \'charts\' tool from Toolshed)', execute : 'histogramdiscrete', columns : { - y : { + x : { title : 'Observations', is_label : true } diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/charts/nvd3_histogram_discrete/wrapper.js --- a/config/plugins/visualizations/charts/static/charts/nvd3_histogram_discrete/wrapper.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3_histogram_discrete/wrapper.js @@ -15,24 +15,33 @@ { // configure request var index = 1; - for (var i in request_dictionary.groups) { - var group = request_dictionary.groups[i]; - group.columns = { - x: { - index: 0 - }, - y: { - index: index++ - }, - } + var tmp_dict = { + id : request_dictionary.id, + groups : [] + }; + + // configure groups + for (var group_index in request_dictionary.groups) { + var group = request_dictionary.groups[group_index]; + tmp_dict.groups.push({ + key : group.key, + columns : { + x: { + index : 0, + is_label : true + }, + y: { + index : index++ + } + } + }); } - // link this - var self = this; - - // load nvd3 + // draw 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, tmp_dict, function(nvd3_model) { + nvd3_model.options({showControls: true}); + }); } }); diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/charts/nvd3_line/config.js --- a/config/plugins/visualizations/charts/static/charts/nvd3_line/config.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3_line/config.js @@ -2,7 +2,16 @@ return $.extend(true, {}, nvd3_config, { title : 'Line chart', - category : 'Others' + category : 'Others', + columns : { + x : { + title : 'Values for x-axis', + is_auto : true + }, + y : { + title : 'Values for y-axis' + } + } }); }); \ No newline at end of file diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/charts/nvd3_line_focus/config.js --- a/config/plugins/visualizations/charts/static/charts/nvd3_line_focus/config.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3_line_focus/config.js @@ -2,7 +2,12 @@ return $.extend(true, {}, nvd3_config, { title : 'Line with focus', - category : 'Others' + category : 'Others', + columns : { + y : { + title : 'Values for y-axis' + } + } }); }); \ No newline at end of file diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/charts/nvd3_pie/config.js --- a/config/plugins/visualizations/charts/static/charts/nvd3_pie/config.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3_pie/config.js @@ -9,7 +9,8 @@ columns : { label : { title : 'Labels', - is_label : true + is_label : true, + is_auto : true }, y : { title : 'Values' diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/charts/nvd3_scatter/config.js --- a/config/plugins/visualizations/charts/static/charts/nvd3_scatter/config.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3_scatter/config.js @@ -6,6 +6,9 @@ columns : { x : { title : 'Values for x-axis' + }, + y : { + title : 'Values for y-axis' } } }); diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/charts/nvd3_stackedarea/config.js --- a/config/plugins/visualizations/charts/static/charts/nvd3_stackedarea/config.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3_stackedarea/config.js @@ -2,7 +2,12 @@ return $.extend(true, {}, nvd3_config, { title : 'Regular', - category : 'Area charts' + category : 'Area charts', + columns : { + y : { + title : 'Values for y-axis' + } + } }); }); \ No newline at end of file diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/charts/nvd3_stackedarea_full/config.js --- a/config/plugins/visualizations/charts/static/charts/nvd3_stackedarea_full/config.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3_stackedarea_full/config.js @@ -2,7 +2,12 @@ return $.extend(true, {}, nvd3_config, { title : 'Expanded', - category : 'Area charts' + category : 'Area charts', + columns : { + y : { + title : 'Values for y-axis' + } + } }); }); \ No newline at end of file diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/charts/nvd3_stackedarea_stream/config.js --- a/config/plugins/visualizations/charts/static/charts/nvd3_stackedarea_stream/config.js +++ b/config/plugins/visualizations/charts/static/charts/nvd3_stackedarea_stream/config.js @@ -2,7 +2,12 @@ return $.extend(true, {}, nvd3_config, { title : 'Stream', - category : 'Area charts' + category : 'Area charts', + columns : { + y : { + title : 'Values for y-axis' + } + } }); }); \ No newline at end of file diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe 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 @@ -48,7 +48,7 @@ 'nvd3_scatter' : nvd3_scatter, 'nvd3_pie' : nvd3_pie, 'nvd3_histogram' : nvd3_histogram, - //'nvd3_histogram_discrete' : nvd3_histogram_discrete, + 'nvd3_histogram_discrete' : nvd3_histogram_discrete, 'highcharts_boxplot' : highcharts_boxplot, 'heatmap' : heatmap } diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/library/datasets.js --- a/config/plugins/visualizations/charts/static/library/datasets.js +++ b/config/plugins/visualizations/charts/static/library/datasets.js @@ -27,29 +27,37 @@ // check if column data is requested if (request_dictionary.groups) { - this._get(request_dictionary, success); + this._get_dataset(request_dictionary.id, function() { + self._get(request_dictionary, success); + }); } else { - // check if dataset is available from cache - var dataset = this.list[request_dictionary.id]; - if (dataset) { - success(dataset); - return; + this._get_dataset(request_dictionary.id, success, error) + } + }, + + // get dataset + _get_dataset: function(id, success, error) { + // check if dataset is available from cache + var dataset = this.list[id]; + if (dataset) { + success(dataset); + return; + } + + // request dataset + var self = this; + Utils.request('GET', config.root + 'api/datasets/' + id, {}, function(dataset) { + switch (dataset.state) { + case 'error': + if (error) { + error(dataset); + } + break; + default: + self.list[id] = dataset; + success(dataset); } - - // request dataset - Utils.request('GET', config.root + 'api/datasets/' + request_dictionary.id, {}, function(dataset) { - switch (dataset.state) { - case 'error': - if (error) { - error(dataset); - } - break; - default: - self.list[request_dictionary.id] = dataset; - success(dataset); - } - }); - } + }); }, // get block id @@ -78,7 +86,7 @@ // check if column is in cache var block_id = this._block_id(request_dictionary, column); - if (this.cache[block_id]) { + if (this.cache[block_id] || column === 'auto') { continue; } @@ -134,45 +142,74 @@ // log console.debug('Datasets::_fill_from_cache() - Filling request from cache.'); + // get dataset + var dataset = this.list[request_dictionary.id]; + if (!dataset) { + console.debug('FAILED - Datasets::_fill_from_cache() - Dataset not found.'); + } + + // identify start/end of request + var start = request_dictionary.start; + var end = Math.min(request_dictionary.end, dataset.metadata_data_lines); + if (end - start <= 0) { + console.debug('FAILED - Datasets::_fill_from_cache() - Invalid range.'); + } + + // initialize group values + for (var i in request_dictionary.groups) { + // get group + var group = request_dictionary.groups[i]; + + // reset group + group.values = []; + + // add values + for (var j = 0; j < end - start; j++) { + // add default x values + group.values[j] = { + x : parseInt(j) + start + }; + } + } + // collect all data into the defined groups for (var i in request_dictionary.groups) { // get group var group = request_dictionary.groups[i]; - // create array for values - group.values = []; - // fill value for (var key in group.columns) { // get column var column = group.columns[key]; - // get block - var block_id = this._block_id(request_dictionary, column.index); - var column_data = this.cache[block_id]; - - // go through column - for (k in column_data) { - // initialize value - var value = group.values[k]; - if (value === undefined) { - // create new value field - value = { - x : parseInt(k) + request_dictionary.start + // check if auto block is requested + if (column.index == 'auto') { + for (var j = start; j < end; j++) { + // get value dictionary + var value = group.values[j]; + + // add auto value + value[key] = parseInt(j) + start; + } + } else { + // get block + var block_id = this._block_id(request_dictionary, column.index); + var column_data = this.cache[block_id]; + + // go through column + for (var j = start; j < end; j++) { + // get value dictionary + var value = group.values[j]; + + // get/fix value + var v = column_data[j]; + if (isNaN(v) && !column.is_label) { + v = 0; } - // add to group - group.values[k] = value; - }; - - // get/fix value - var v = column_data[k]; - if (isNaN(v) && !column.is_label) { - v = 0; + // add to dict + value[key] = v; } - - // add to dict - value[key] = v; } } } diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/library/ui-select.js --- a/config/plugins/visualizations/charts/static/library/ui-select.js +++ b/config/plugins/visualizations/charts/static/library/ui-select.js @@ -33,11 +33,9 @@ // add change event var self = this; - if (this.options.onchange) { - this.$select.on('change', function() { - self.value(self.$select.val()); - }); - } + this.$select.on('change', function() { + self.value(self.$select.val()); + }); // refresh this._refresh(); @@ -158,6 +156,34 @@ this._refresh(); }, + // force selection to existing value + force: function() { + if (!this._exists(this.selected)) { + // get select options + var options = this.$select.find('option'); + if (options.length > 0) { + // get value from options field + var value = options.val(); + + // log + console.debug('Ui-Select()::force() - Forcing value from "' + this.selected + '" to "' + value + '".'); + + // set value + this.value(value); + } + } + }, + + // set on change event + onchange: function(callback) { + this.options.onchange = callback; + }, + + // check if selected value exists + _exists: function(value) { + return this.$select.find('option[value=' + value + ']').length > 0; + }, + // refresh _refresh: function() { // remove placeholder @@ -166,9 +192,11 @@ // count remaining entries var remaining = this.$select.find('option').length; if (remaining == 0) { + // disable select field + this.disable(); + // append placeholder this.$select.append(this._templateOption({value : 'null', label : this.options.empty})); - this.disable(); } else { // enable select field this.enable(); @@ -180,12 +208,6 @@ } }, - // exists - _exists: function(value) { - // check if selected value exists - return 0 != this.$select.find('option[value=' + value + ']').length; - }, - // option _templateOption: function(options) { return '<option value="' + options.value + '">' + options.label + '</option>'; diff -r 6c3cc96d1fa7888b7af015dd73c7451df7338ad5 -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe config/plugins/visualizations/charts/static/views/group.js --- a/config/plugins/visualizations/charts/static/views/group.js +++ b/config/plugins/visualizations/charts/static/views/group.js @@ -82,25 +82,21 @@ // load list var list = {}; for (var id in chart_settings.columns) { - // initialize - var value = this.group.get(id); - if (!value) { - this.group.set(id, 0); + // get definition + var data_def = chart_settings.columns[id]; + if (!data_def) { + console.debug('Group::_refreshTable() - Skipping column definition.'); + continue; } + + // create select field + var select = new Ui.Select.View({ + id : 'select_' + id, + gid : id, + value : this.group.get(id), + wait : true + }); - // create select field - var data_def = chart_settings.columns[id]; - var select = new Ui.Select.View({ - id : 'select_' + id, - gid : id, - onchange : function(value) { - self.group.set(this.gid, value); - self.chart.set('modified', true); - }, - value : value, - wait : true - }); - // add row to table this.table.add(data_def.title, '25%'); this.table.add(select.$el); @@ -121,11 +117,25 @@ // update select fields for (var id in list) { + // select + var select = list[id]; + // is a numeric number required - var is_label = chart_settings.columns[id].is_label; - + var is_label = chart_settings.columns[id].is_label; + var is_auto = chart_settings.columns[id].is_auto; + // configure columns var columns = []; + + // add auto selection column + if (is_auto) { + columns.push({ + 'label' : 'Column: Row Number', + 'value' : 'auto' + }); + } + + // meta data var meta = dataset.metadata_column_types; for (var key in meta) { // check type @@ -138,9 +148,16 @@ } } + // add onchange event + select.onchange(function(value) { + self.group.set(this.gid, value); + self.chart.set('modified', true); + }); + // list - list[id].update(columns); - list[id].show(); + select.update(columns); + select.force(); + select.show(); } // loading 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.