A scale is a special function (not a class) that has some additional methods attached to it that allow one to create and/or alter the way the scaling function performs.
Scaling functions behave by taking an input, scaling that input to a given output. The scaling function can be altered by changing the input and output ranges and scales do not have to be continuous. The built in scales types are thinkmap.scale.linear and thinkmap.scale.time
The scaling function. Takes an input and scales it to produce an output.
the input to scale
returns the scaled output
var scale = thinkmap.scale.linear().inputs(0,1000).outputs(0,5);
scale(200); // returns 1
scale(100); // returns .5
scale(1000); // returns 5
scale(500); // returns 2.5
var scale = thinkmap.scale.linear();
scale.inputs(0,1000,5000);
scale.outputs(0,10,10000);
scale(400); //returns 4
scale(1000); // returns 10;
scale(1400); // returns 1009;
scale(5000); // returns 10000;
Returns a new scale of the same type with the same inputs but the outputs are reversed. So if the outputs are 0,2000 the scale will produce new outputs ranged from 2000,0.
var scale = thinkmap.scale.linear().inputs(0,1000).outputs(0,5);
scale(200); //returns 1
scale(1000); //returns 5
var flippedScale = scale.flip();
flippedScale(200); //returns 4
flippedScale(0); //returns 5
flippedScale(1000); //returns 0
Sets (or gets) the input values which signify the range of inputs the scale can expect. For all scales, it is important to set the input and output ranges. Not doing either will result in a scale that is simply 1 to 1 and won't scale values.
the range of inputs this scale is to operate on. If no arguments are passed, then the current inputs are returned. The default linear scale uses an input range of 0-1
this scale of inputs of no arguments are passed else the outputs are set and this scale is returned
Takes a scaled output value and returns the corresponding input. This is the inverse of scaling an input.
takes the scaled value and returns the corresponding input value (the inverse)
the inverted value
var scale = thinkmap.scale.linear().inputs(0,10).outputs(25,50)
var result = scale(3); // result is 32.5
var invert = scale.invert(result); //result is 3
Sets (or gets) the output values which signify the range of outputs the scale should use to scale the input between. All scales should have defined inputs and outputs. Not doing either will result in a scale that is simply 1 to 1 and won't scale values.
the range of outputs this scale is to produce. If no arguments are passed, then the current outputs are returned. The default linear scale uses an output range of 0-1
this scale of outputs if no arguments are passed else the outputs are set and this scale is returned