1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/b38587cb8937/ Changeset: b38587cb8937 User: guerler Date: 2014-05-22 10:45:43 Summary: Charts: Improve options mapping between different chart types Affected #: 7 files diff -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe -r b38587cb8937d678f2edcd17659fc3ce1724794d 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 @@ -9,11 +9,6 @@ } }, columns : { - x : { - title : 'Values for x-axis', - is_label: true, - is_auto : true - }, y : { title : 'Values for y-axis' } diff -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe -r b38587cb8937d678f2edcd17659fc3ce1724794d 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 @@ -4,11 +4,6 @@ title : 'Stacked', category : 'Bar diagrams', columns : { - x : { - title : 'Values for x-axis', - is_label: true, - is_auto : true - }, y : { title : 'Values for y-axis' } diff -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe -r b38587cb8937d678f2edcd17659fc3ce1724794d 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 @@ -40,7 +40,7 @@ // draw var nvd3 = new NVD3(this.app, this.options); nvd3.draw(process_id, nv.models.multiBarChart(), chart, tmp_dict, function(nvd3_model) { - nvd3_model.options({showControls: true}); + nvd3_model.options({showControls: false}); }); } }); diff -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe -r b38587cb8937d678f2edcd17659fc3ce1724794d 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 @@ -5,7 +5,7 @@ var View = Backbone.View.extend( { // options - optionsDefault: { + optionsDefault : { id : '', cls : '', empty : 'No data available', @@ -21,6 +21,9 @@ // configure options this.options = Utils.merge(options, this.optionsDefault); + // initial value + this.selected = this.options.value; + // create new element this.setElement(this._template(this.options)); @@ -28,10 +31,7 @@ this.$select = this.$el.find('#select'); this.$icon = this.$el.find('#icon'); - // initial value - this.selected = this.options.value; - - // add change event + // add change event. fires only on user activity var self = this; this.$select.on('change', function() { self.value(self.$select.val()); @@ -67,9 +67,9 @@ // get current id/value var after = this.selected; - if(after) { + if (after) { // fire onchange - if ((after != before && this.options.onchange)) { + if (after != before && this.options.onchange) { this.options.onchange(after); } } @@ -78,6 +78,16 @@ return after; }, + // first + first: function() { + var options = this.$select.find('option'); + if (options.length > 0) { + return options.val(); + } else { + return undefined; + } + }, + // label text : function () { return this.$select.find('option:selected').text(); @@ -147,40 +157,17 @@ this.$select.append(this._templateOption(options[key])); } - // select first option if nothing else is selected - if (!this.selected && options.length > 0) { - this.value(options[0].value); - } - // refresh 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) { + setOnChange: function(callback) { this.options.onchange = callback; }, // check if selected value exists - _exists: function(value) { + exists: function(value) { return this.$select.find('option[value=' + value + ']').length > 0; }, @@ -200,11 +187,11 @@ } else { // enable select field this.enable(); - - // update selected value - if (this.selected) { - this.$select.val(this.selected); - } + } + + // update value + if (this.selected) { + this.$select.val(this.selected); } }, diff -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe -r b38587cb8937d678f2edcd17659fc3ce1724794d config/plugins/visualizations/charts/static/library/ui-table-form.js --- a/config/plugins/visualizations/charts/static/library/ui-table-form.js +++ b/config/plugins/visualizations/charts/static/library/ui-table-form.js @@ -40,14 +40,6 @@ for (var id in settings) { this._add(id, settings[id], model); } - - // trigger change - for (var id in this.list) { - var onchange = this.list[id].options.onchange; - if (onchange) { - onchange(); - } - } }, // add table row @@ -66,8 +58,9 @@ field = new Ui.Input({ id : id, placeholder : settings_def.placeholder, - onchange : function() { - model.set(id, field.value()); + value : model.get(id), + onchange : function(value) { + model.set(id, value); } }); break; @@ -76,13 +69,13 @@ field = new Ui.Select.View({ id : id, data : settings_def.data, - onchange : function() { + value : model.get(id), + onchange : function(value) { // set new value - var selected = field.value(); - model.set(id, selected); + model.set(id, value); // find selected dictionary - var dict = _.findWhere(settings_def.data, {value: selected}); + var dict = _.findWhere(settings_def.data, {value: value}); if (dict) { if (dict.show) { self.$el.find('#' + dict.show).fadeIn('fast'); diff -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe -r b38587cb8937d678f2edcd17659fc3ce1724794d config/plugins/visualizations/charts/static/library/ui.js --- a/config/plugins/visualizations/charts/static/library/ui.js +++ b/config/plugins/visualizations/charts/static/library/ui.js @@ -550,13 +550,13 @@ this.$el.hide(); } - // onchange event handler + // onchange event handler. fires on user activity. var self = this; - if (this.options.onchange) { - this.$el.on('input', function() { - self.options.onchange(); - }); - } + this.$el.on('input', function() { + if (self.options.onchange) { + self.options.onchange(self.$el.val()); + } + }); }, // value diff -r d18b0f6cac6cb7bea6bd66900cc2d119bb733fbe -r b38587cb8937d678f2edcd17659fc3ce1724794d 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 @@ -22,8 +22,8 @@ // ui elements this.group_key = new Ui.Input({ placeholder: 'Data label', - onchange: function() { - self.group.set('key', self.group_key.value()); + onchange: function(value) { + self.group.set('key', value); } }); this.table = new Table.View({content: 'No data column.'}); @@ -92,8 +92,6 @@ // create select field var select = new Ui.Select.View({ id : 'select_' + id, - gid : id, - value : this.group.get(id), wait : true }); @@ -116,48 +114,7 @@ this.app.datasets.request({id : dataset_id}, function(dataset) { // 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_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 - if ((!is_label && (meta[key] == 'int' || meta[key] == 'float')) || is_label) { - // add to selection - columns.push({ - 'label' : 'Column: ' + (parseInt(key) + 1) + ' [' + meta[key] + ']', - 'value' : key - }); - } - } - - // add onchange event - select.onchange(function(value) { - self.group.set(this.gid, value); - self.chart.set('modified', true); - }); - - // list - select.update(columns); - select.force(); - select.show(); + self._addRow(id, dataset, list[id], chart_settings.columns[id]) } // loading @@ -168,6 +125,62 @@ }); }, + // add row + _addRow: function(id, dataset, select, chart_setting) { + // is a numeric number required + var is_label = chart_setting.is_label; + var is_auto = chart_setting.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 + if ((!is_label && (meta[key] == 'int' || meta[key] == 'float')) || is_label) { + // add to selection + columns.push({ + 'label' : 'Column: ' + (parseInt(key) + 1) + ' [' + meta[key] + ']', + 'value' : key + }); + } + } + + // update selection list + select.update(columns); + select.show(); + + // update current value + if (!select.exists(this.group.get(id))) { + // get first value + var first = select.first(); + + // log + console.debug('Group()::_addRow() - Switching model value from "' + this.group.get(id) + '" to "' + first + '".'); + + // update model value + this.group.set(id, first); + } + select.value(this.group.get(id)); + + // add onchange event + var self = this; + select.setOnChange(function(value) { + // update model value + self.group.set(id, value); + self.chart.set('modified', true); + }); + }, + // update _refreshGroup: function() { this.group.set('date', Utils.time()); 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.