diff --git a/browser/js/generic_axis.js b/browser/js/generic_axis.js index 664d76b1bd684b984d22abdb5b7c079d5f8a80be..a5266678e9c64dacd5988729be79571f2c9ada62 100644 --- a/browser/js/generic_axis.js +++ b/browser/js/generic_axis.js @@ -115,24 +115,18 @@ GenericAxis.prototype = { }, populateValueMapping: function() { - var values = this.values; - var value_mapping = this.value_mapping; - var label_mapping = this.label_mapping; - var label_array = Object.keys(label_mapping); - for (var i = 0; i < values.length; i++) { - var value = values[i]; + for (var idx in this.values) { + var value = this.values[idx]; var convert = this.applyConverter(value); - if (typeof label_mapping[convert] !== 'undefined') { - var index = label_array.indexOf(convert); - if (typeof value_mapping[index] === 'undefined') { - value_mapping[index] = []; - } - value_mapping[index].push(value); + + if (typeof convert !== 'undefined') { + this.value_mapping[convert] = this.value_mapping[convert] || [] + this.value_mapping[convert].push(value); } else if (this.can_undefined){ - if (typeof value_mapping["?"] === 'undefined') - value_mapping["?"] = []; - value_mapping["?"].push(value); + if (typeof this.value_mapping["?"] === 'undefined') + this.value_mapping["?"] = []; + this.value_mapping["?"].push(value); } } }, @@ -181,10 +175,19 @@ GenericAxis.prototype = { }, pos: function(element) { - var value = this.label_mapping[this.applyConverter(element)]; - if (typeof value === 'undefined') - value = this.label_mapping["?"]; - return value; + value = this.applyConverter(element); + + return this.pos_from_value(value) + }, + + pos_from_value: function(value) { + + var pos = this.label_mapping[value] + + if (typeof pos === 'undefined') + pos = this.label_mapping["?"]; + + return pos ; }, computeLabels: function(values, sort) { diff --git a/browser/js/numerical_axis.js b/browser/js/numerical_axis.js index a648b7c50efb4109be1bf246f98d938152cb1772..c6e1690fa4591d7ee34461b391a42a47b304d455 100644 --- a/browser/js/numerical_axis.js +++ b/browser/js/numerical_axis.js @@ -147,13 +147,6 @@ NumericalAxis.prototype = Object.create(GenericAxis.prototype); this.computeLabels(min, max, use_log, display_label, this.can_undefined) } - NumericalAxis.prototype.pos = function(clone) { - var value, pos; - value = this.applyConverter(clone); - - return this.pos_from_value(value) - } - NumericalAxis.prototype.pos_from_value = function(value) { if (typeof value != "undefined" && value != 'undefined'){