Commit 9c9ac524 authored by Thonier Florian's avatar Thonier Florian

numericalAxis: add a function nice_number_digit to FloatAxis

parent b14c6b56
Pipeline #10985 passed with stages
in 4 minutes and 55 seconds
......@@ -279,7 +279,7 @@ function FloatAxis (model, reverse, can_undefined) {
FloatAxis.prototype = Object.create(NumericalAxis.prototype);
FloatAxis.prototype.getLabelText = function(value) {
return parseFloat(value).toFixed(2)
return parseFloat(value).toFixed( this.nice_number_digits(this.min, this.max) )
}
FloatAxis.prototype.insert_values = function() {
......@@ -303,4 +303,12 @@ FloatAxis.prototype = Object.create(NumericalAxis.prototype);
temp[key] = this.value_mapping[key]
}
this.value_mapping = temp
}
FloatAxis.prototype.nice_number_digits = function(min, max) { //max - min, 2){
var exposant = 0
while (max - min < Math.pow(10, exposant) ) {
exposant--;
}
return exposant
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment