/**
* @fileoverview Based on PlotKit, but modified to meet the needs of dygraphs.
* In particular, support for:
- * - grid overlays
+ * - grid overlays
* - error bars
* - dygraphs attribute system
*/
this.area.w -= (this.options.yAxisLabelWidth + 2 * this.options.axisTickSize);
} else if (this.dygraph_.numAxes() > 2) {
this.dygraph_.error("Only two y-axes are supported at this time. (Trying " +
- "to use " + this.layout.yAxes.length + ")");
+ "to use " + this.dygraph_.numAxes() + ")");
}
this.container.style.position = "relative";
ctx.strokeStyle = this.options.gridLineColor;
ctx.lineWidth = this.options.axisLineWidth;
for (var i = 0; i < ticks.length; i++) {
- if (ticks[i][0] != 0) continue; // TODO(danvk): per-axis property
+ // TODO(danvk): allow secondary axes to draw a grid, too.
+ if (ticks[i][0] != 0) continue;
var x = this.area.x;
var y = this.area.y + ticks[i][1] * this.area.h;
ctx.beginPath();
ctx.strokeStyle = this.options.gridLineColor;
ctx.lineWidth = this.options.axisLineWidth;
for (var i=0; i<ticks.length; i++) {
- var x = this.area.x + ticks[i][1] * this.area.w;
+ var x = this.area.x + ticks[i][0] * this.area.w;
var y = this.area.y + this.area.h;
ctx.beginPath();
ctx.moveTo(x, y);
var tick = this.layout.yticks[i];
if (typeof(tick) == "function") return;
var x = this.area.x;
- if (tick[0] == 1) {
- x = this.area.x + this.area.w - labelStyle.width;
+ var sgn = 1;
+ if (tick[0] == 1) { // right-side y-axis
+ x = this.area.x + this.area.w;
+ sgn = -1;
}
var y = this.area.y + tick[1] * this.area.h;
context.beginPath();
context.moveTo(x, y);
- context.lineTo(x - this.options.axisTickSize, y);
+ context.lineTo(x - sgn * this.options.axisTickSize, y);
context.closePath();
context.stroke();
context.lineTo(this.area.x, this.area.y + this.area.h);
context.closePath();
context.stroke();
+
+ if (this.dygraph_.numAxes() == 2) {
+ context.beginPath();
+ context.moveTo(this.area.x + this.area.w, this.area.y);
+ context.lineTo(this.area.x + this.area.w, this.area.y + this.area.h);
+ context.closePath();
+ context.stroke();
+ }
}
if (this.options.drawXAxis) {