Commit 9f3d5624 authored by Marc Duez's avatar Marc Duez
Browse files

axis.js : accept anonymous function as default min/max

-remove special case for 0
-improve range for reverse mode
-debug min
parent c15efbd6
...@@ -153,14 +153,16 @@ Axis.prototype = { ...@@ -153,14 +153,16 @@ Axis.prototype = {
use_log= typeof percent !== 'undefined' ? use_log : false; use_log= typeof percent !== 'undefined' ? use_log : false;
var self = this; var self = this;
this.fct = fct; this.fct = fct;
var min = default_min; var min = default_min;
var max = default_max; var max = default_max;
if (typeof min === 'function') min = min();
if (typeof min === 'function') max = max();
for (var i in this.m.clones){ for (var i in this.m.clones){
var tmp; var tmp;
try{ try{
tmp = fct(i); tmp = fct(i);
if (tmp == 0) tmp = undefined;
}catch(e){} }catch(e){}
if ( typeof tmp != "undefined"){ if ( typeof tmp != "undefined"){
...@@ -174,14 +176,16 @@ Axis.prototype = { ...@@ -174,14 +176,16 @@ Axis.prototype = {
max = 1; max = 1;
} }
var range = [0,1]
if (self.reverse) range = [1,0]
if (use_log){ if (use_log){
this.sizeScale = d3.scale.log() this.sizeScale = d3.scale.log()
.domain([min, max]) .domain([min, max])
.range([0, 1]); .range(range);
}else{ }else{
this.sizeScale = d3.scale.linear() this.sizeScale = d3.scale.linear()
.domain([min, max]) .domain([min, max])
.range([0, 1]); .range(range);
} }
this.min = min; this.min = min;
...@@ -196,10 +200,9 @@ Axis.prototype = { ...@@ -196,10 +200,9 @@ Axis.prototype = {
if (typeof value != "undefined"){ if (typeof value != "undefined"){
pos = self.sizeScale(value); pos = self.sizeScale(value);
}else{ }else{
pos = self.min; pos = self.sizeScale(self.min);
} }
if (self.reverse) pos = 1 - pos;
return pos; return pos;
} }
......
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