projects
/
dygraphs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implement tick.label_v.
[dygraphs.git]
/
src
/
plugins
/
grid.js
diff --git
a/src/plugins/grid.js
b/src/plugins/grid.js
index
db1b42d
..
25126db
100644
(file)
--- a/
src/plugins/grid.js
+++ b/
src/plugins/grid.js
@@
-5,8
+5,6
@@
*/
/*global Dygraph:false */
*/
/*global Dygraph:false */
-Dygraph.Plugins.Grid = (function() {
-
/*
Current bits of jankiness:
/*
Current bits of jankiness:
@@
-64,26
+62,25
@@
grid.prototype.willDrawChart = function(e) {
ticks = layout.yticks;
ctx.save();
// draw grids for the different y axes
ticks = layout.yticks;
ctx.save();
// draw grids for the different y axes
- for (i = 0; i < ticks.length; i++) {
- var axis = ticks[i][0];
- if(drawGrid[axis]) {
+ for (var tick of ticks) {
+ if (!tick.has_tick) continue;
+ var axis = tick.axis;
+ if (drawGrid[axis]) {
+ ctx.save();
if (stroking[axis]) {
if (stroking[axis]) {
-
ctx.installPattern
(strokePattern[axis]);
+
if (ctx.setLineDash) ctx.setLineDash
(strokePattern[axis]);
}
ctx.strokeStyle = strokeStyles[axis];
ctx.lineWidth = lineWidths[axis];
x = halfUp(area.x);
}
ctx.strokeStyle = strokeStyles[axis];
ctx.lineWidth = lineWidths[axis];
x = halfUp(area.x);
- y = halfDown(area.y + tick
s[i][1]
* area.h);
+ y = halfDown(area.y + tick
.pos
* area.h);
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(x + area.w, y);
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(x + area.w, y);
- ctx.closePath();
ctx.stroke();
ctx.stroke();
- if (stroking[axis]) {
- ctx.uninstallPattern();
- }
+ ctx.restore();
}
}
ctx.restore();
}
}
ctx.restore();
@@
-96,12
+93,13
@@
grid.prototype.willDrawChart = function(e) {
var strokePattern = g.getOptionForAxis('gridLinePattern', 'x');
var stroking = strokePattern && (strokePattern.length >= 2);
if (stroking) {
var strokePattern = g.getOptionForAxis('gridLinePattern', 'x');
var stroking = strokePattern && (strokePattern.length >= 2);
if (stroking) {
-
ctx.installPattern
(strokePattern);
+
if (ctx.setLineDash) ctx.setLineDash
(strokePattern);
}
ctx.strokeStyle = g.getOptionForAxis('gridLineColor', 'x');
ctx.lineWidth = g.getOptionForAxis('gridLineWidth', 'x');
}
ctx.strokeStyle = g.getOptionForAxis('gridLineColor', 'x');
ctx.lineWidth = g.getOptionForAxis('gridLineWidth', 'x');
- for (i = 0; i < ticks.length; i++) {
- x = halfUp(area.x + ticks[i][0] * area.w);
+ for (var tick of ticks) {
+ if (!tick.has_tick) continue;
+ x = halfUp(area.x + tick.pos * area.w);
y = halfDown(area.y + area.h);
ctx.beginPath();
ctx.moveTo(x, y);
y = halfDown(area.y + area.h);
ctx.beginPath();
ctx.moveTo(x, y);
@@
-110,7
+108,7
@@
grid.prototype.willDrawChart = function(e) {
ctx.stroke();
}
if (stroking) {
ctx.stroke();
}
if (stroking) {
-
ctx.uninstallPattern(
);
+
if (ctx.setLineDash) ctx.setLineDash([]
);
}
ctx.restore();
}
}
ctx.restore();
}
@@
-119,6
+117,4
@@
grid.prototype.willDrawChart = function(e) {
grid.prototype.destroy = function() {
};
grid.prototype.destroy = function() {
};
-return grid;
-
-})();
+export default grid;