couldnt find a javascript implementation for extended encoding for google chart api, so here it is. if the function looks a little strange to you, check out this article about memoizing
http://osteele.com/archives/2006/04/javascript-memoization
also, thanks to
http://www.felipebarone.com/node/52
for putting this out there for php!
BaseMap.prototype.extendedEncoding = function(valueArray){
var MAX = 4095, MIN = 0, delta = MAX - MIN;
var extendedString = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.';
var stringLength = extendedString.length;
var encoded = function(valueArray){
var chartdata = 'e:';
for(var i=0;i= MIN && i <= MAX){
var calc1 = Math.round((valueArray[i] - MIN) / stringLength * MAX / delta);
var calc2 = ((valueArray[i] - MIN) % stringLength) * MAX / delta;
var first = extendedString.substring(calc1,calc1+1);
var second = extendedString.substring(calc2,calc2+1);
chartdata += first + second;
}else {
chardata += '__'; // Value out of max range;
}
}
return chartdata;
}
this.extendedEncoding = function(valueArray){return encoded(valueArray);}
return encoded;
}