- i++;
- }
-};
-
-
-PlotKit.Layout.prototype._evaluateLineTicksForXAxis = function() {
- var isNil = MochiKit.Base.isUndefinedOrNull;
-
- if (this.options.xTicks) {
- // we use use specified ticks with optional labels
-
- this.xticks = new Array();
- var makeTicks = function(tick) {
- var label = tick.label;
- if (isNil(label))
- label = tick.v.toString();
- var pos = this.xscale * (tick.v - this.minxval);
- if ((pos >= 0.0) && (pos <= 1.0)) {
- this.xticks.push([pos, label]);
- }
- };
- MochiKit.Iter.forEach(this.options.xTicks, bind(makeTicks, this));
- }
- else if (this.options.xNumberOfTicks) {
- // we use defined number of ticks as hint to auto generate
- var xvalues = this._uniqueXValues();
- var roughSeparation = this.xrange / this.options.xNumberOfTicks;
- var tickCount = 0;
-
- this.xticks = new Array();
- for (var i = 0; i <= xvalues.length; i++) {
- if ((xvalues[i] - this.minxval) >= (tickCount * roughSeparation)) {
- var pos = this.xscale * (xvalues[i] - this.minxval);
- if ((pos > 1.0) || (pos < 0.0))
- continue;
- this.xticks.push([pos, xvalues[i]]);
- tickCount++;
- }
- if (tickCount > this.options.xNumberOfTicks)
- break;
- }
- }
-};
-
-PlotKit.Layout.prototype._evaluateLineTicksForYAxis = function() {
- var isNil = MochiKit.Base.isUndefinedOrNull;
-
-
- if (this.options.yTicks) {
- this.yticks = new Array();
- var makeTicks = function(tick) {
- var label = tick.label;
- if (isNil(label))
- label = tick.v.toString();
- var pos = 1.0 - (this.yscale * (tick.v - this.minyval));
- if ((pos >= 0.0) && (pos <= 1.0)) {
- this.yticks.push([pos, label]);
- }
- };
- MochiKit.Iter.forEach(this.options.yTicks, bind(makeTicks, this));
- }
- else if (this.options.yNumberOfTicks) {
- // We use the optionally defined number of ticks as a guide
- this.yticks = new Array();
-
- // if we get this separation right, we'll have good looking graphs
- var roundInt = PlotKit.Base.roundInterval;
- var prec = this.options.yTickPrecision;
- var roughSeparation = roundInt(this.yrange,
- this.options.yNumberOfTicks, prec);
-
- // round off each value of the y-axis to the precision
- // eg. 1.3333 at precision 1 -> 1.3
- for (var i = 0; i <= this.options.yNumberOfTicks; i++) {
- var yval = this.minyval + (i * roughSeparation);
- var pos = 1.0 - ((yval - this.minyval) * this.yscale);
- if ((pos > 1.0) || (pos < 0.0))
- continue;
- this.yticks.push([pos, MochiKit.Format.roundToFixed(yval, prec)]);
- }