Skip to content

Instantly share code, notes, and snippets.

@fmsf
Created December 20, 2012 11:48
Show Gist options
  • Save fmsf/4344860 to your computer and use it in GitHub Desktop.
Save fmsf/4344860 to your computer and use it in GitHub Desktop.
Must remember to push this to flot
// draw ticks
for (i = 0; i < axis.ticks.length; ++i) {
ctx.beginPath();
var v = axis.ticks[i].v;
xoff = yoff = 0;
if (v < axis.min || v > axis.max
// skip those lying on the axes if we got a border
|| (t == "full" && bw > 0
&& (v == axis.min || v == axis.max)))
continue;
if (axis.direction == "x") {
x = axis.p2c(v);
yoff = t == "full" ? -plotHeight : t;
if (axis.position == "top")
yoff = -yoff;
}
else {
y = axis.p2c(v);
xoff = t == "full" ? -plotWidth : t;
if (axis.position == "left")
xoff = -xoff;
}
if (ctx.lineWidth == 1) {
if (axis.direction == "x")
x = Math.floor(x) + 0.5;
else
y = Math.floor(y) + 0.5;
}
if ($.isFunction(axis.options.tickColor)){
ctx.strokeStyle = axis.options.tickColor(v);
}
ctx.moveTo(x, y);
ctx.lineTo(x + xoff, y + yoff);
ctx.stroke();
}
@fmsf
Copy link
Author

fmsf commented Dec 30, 2012

added to pull request: flot/flot#917

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment