// Ticks Code von http://nieldomingo.blogspot.com/2007/03/improved-tick-marks-for-plotkit.html

function PTCoord(listvals)
{
this.listvals = listvals;

var minval = listMin(this.listvals);
var maxval = listMax(this.listvals);

var interval;
if (minval == maxval)
interval = 10;
else
{
interval = Math.pow(10, Math.floor(Math.log(maxval-minval)/Math.log(10)));
}
minval = Math.min(minval, this.roundDown(minval, interval));
maxval = Math.max(maxval, this.roundUp(maxval, interval) + interval/2.0)

this.minval = minval;
this.maxval = maxval;
this.interval = interval;

v = [];
var x = this.minval;
while (x <= this.maxval)
{
v.push({v: x, label: x.toFixed(0)});
x += this.interval;
}
this.ticks = v;
}

PTCoord.prototype.roundDown = function (val, bound) {
return Math.floor(val / bound) * bound;
};

PTCoord.prototype.roundUp = function (val, bound) {
return (Math.floor((val-1)/bound+1)) * bound;
};

PTCoord.prototype.getRange = function () {
return [this.minval, this.maxval];
};

PTCoord.prototype.getTicks = function () {
return this.ticks;
};