Commit 1308e069 authored by olau@iola.dk's avatar olau@iola.dk

Added missing semicolons, renamed translate functions

git-svn-id: https://flot.googlecode.com/svn/trunk@25 1e0a6537-2640-0410-bfb7-f154510ff394
parent 881a1bf5
...@@ -388,11 +388,11 @@ ...@@ -388,11 +388,11 @@
} }
} }
function translateHoz(x) { function tHoz(x) {
return (x - xaxis.min) * hozScale; return (x - xaxis.min) * hozScale;
} }
function translateVert(y) { function tVert(y) {
return plotHeight - (y - yaxis.min) * vertScale; return plotHeight - (y - yaxis.min) * vertScale;
} }
...@@ -416,8 +416,8 @@ ...@@ -416,8 +416,8 @@
if (v == xaxis.min || v == xaxis.max) if (v == xaxis.min || v == xaxis.max)
continue; // skip those lying on the axes continue; // skip those lying on the axes
ctx.moveTo(Math.floor(translateHoz(v)) + ctx.lineWidth/2, 0); ctx.moveTo(Math.floor(tHoz(v)) + ctx.lineWidth/2, 0);
ctx.lineTo(Math.floor(translateHoz(v)) + ctx.lineWidth/2, plotHeight); ctx.lineTo(Math.floor(tHoz(v)) + ctx.lineWidth/2, plotHeight);
} }
for (i = 0; i < yaxis.ticks.length; ++i) { for (i = 0; i < yaxis.ticks.length; ++i) {
...@@ -425,8 +425,8 @@ ...@@ -425,8 +425,8 @@
if (v == yaxis.min || v == yaxis.max) if (v == yaxis.min || v == yaxis.max)
continue; continue;
ctx.moveTo(0, Math.floor(translateVert(v)) + ctx.lineWidth/2); ctx.moveTo(0, Math.floor(tVert(v)) + ctx.lineWidth/2);
ctx.lineTo(plotWidth, Math.floor(translateVert(v)) + ctx.lineWidth/2); ctx.lineTo(plotWidth, Math.floor(tVert(v)) + ctx.lineWidth/2);
} }
ctx.stroke(); ctx.stroke();
...@@ -459,7 +459,7 @@ ...@@ -459,7 +459,7 @@
tick = xaxis.ticks[i]; tick = xaxis.ticks[i];
if (!tick.label) if (!tick.label)
continue; continue;
html += '<div style="position:absolute;top:' + (plotOffset.top + plotHeight + options.grid.labelMargin) + 'px;left:' + (plotOffset.left + translateHoz(tick.v) - xBoxWidth/2) + 'px;width:' + xBoxWidth + 'px;text-align:center" class="gridLabel">' + tick.label + "</div>"; html += '<div style="position:absolute;top:' + (plotOffset.top + plotHeight + options.grid.labelMargin) + 'px;left:' + (plotOffset.left + tHoz(tick.v) - xBoxWidth/2) + 'px;width:' + xBoxWidth + 'px;text-align:center" class="gridLabel">' + tick.label + "</div>";
} }
// do the y-axis // do the y-axis
...@@ -467,7 +467,7 @@ ...@@ -467,7 +467,7 @@
tick = yaxis.ticks[i]; tick = yaxis.ticks[i];
if (!tick.label || tick.label.length == 0) if (!tick.label || tick.label.length == 0)
continue; continue;
html += '<div style="position:absolute;top:' + (plotOffset.top + translateVert(tick.v) - labelMaxHeight/2) + 'px;left:0;width:' + labelMaxWidth + 'px;text-align:right" class="gridLabel">' + tick.label + "</div>"; html += '<div style="position:absolute;top:' + (plotOffset.top + tVert(tick.v) - labelMaxHeight/2) + 'px;left:0;width:' + labelMaxWidth + 'px;text-align:right" class="gridLabel">' + tick.label + "</div>";
} }
html += '</div>'; html += '</div>';
...@@ -562,8 +562,8 @@ ...@@ -562,8 +562,8 @@
if (data.length < 2) if (data.length < 2)
return; return;
var prevx = translateHoz(data[0][0]), var prevx = tHoz(data[0][0]),
prevy = translateVert(data[0][1]) + offset; prevy = tVert(data[0][1]) + offset;
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(prevx, prevy); ctx.moveTo(prevx, prevy);
...@@ -628,11 +628,11 @@ ...@@ -628,11 +628,11 @@
x2 = xaxis.max; x2 = xaxis.max;
} }
if (prevx != translateHoz(x1) || prevy != translateVert(y1) + offset) if (prevx != tHoz(x1) || prevy != tVert(y1) + offset)
ctx.moveTo(translateHoz(x1), translateVert(y1) + offset); ctx.moveTo(tHoz(x1), tVert(y1) + offset);
prevx = translateHoz(x2); prevx = tHoz(x2);
prevy = translateVert(y2) + offset; prevy = tVert(y2) + offset;
ctx.lineTo(prevx, prevy); ctx.lineTo(prevx, prevy);
} }
ctx.stroke(); ctx.stroke();
...@@ -683,19 +683,19 @@ ...@@ -683,19 +683,19 @@
} }
if (first) { if (first) {
ctx.moveTo(translateHoz(x1), translateVert(bottom)); ctx.moveTo(tHoz(x1), tVert(bottom));
first = false; first = false;
} }
// now first check the case where both is outside // now first check the case where both is outside
if (y1 >= yaxis.max && y2 >= yaxis.max) { if (y1 >= yaxis.max && y2 >= yaxis.max) {
ctx.lineTo(translateHoz(x1), translateVert(yaxis.max)); ctx.lineTo(tHoz(x1), tVert(yaxis.max));
ctx.lineTo(translateHoz(x2), translateVert(yaxis.max)); ctx.lineTo(tHoz(x2), tVert(yaxis.max));
continue; continue;
} }
else if (y1 <= yaxis.min && y2 <= yaxis.min) { else if (y1 <= yaxis.min && y2 <= yaxis.min) {
ctx.lineTo(translateHoz(x1), translateVert(yaxis.min)); ctx.lineTo(tHoz(x1), tVert(yaxis.min));
ctx.lineTo(translateHoz(x2), translateVert(yaxis.min)); ctx.lineTo(tHoz(x2), tVert(yaxis.min));
continue; continue;
} }
...@@ -735,13 +735,13 @@ ...@@ -735,13 +735,13 @@
else else
top = yaxis.max; top = yaxis.max;
ctx.lineTo(translateHoz(x1old), translateVert(top)); ctx.lineTo(tHoz(x1old), tVert(top));
ctx.lineTo(translateHoz(x1), translateVert(top)); ctx.lineTo(tHoz(x1), tVert(top));
} }
// fill the triangles // fill the triangles
ctx.lineTo(translateHoz(x1), translateVert(y1)); ctx.lineTo(tHoz(x1), tVert(y1));
ctx.lineTo(translateHoz(x2), translateVert(y2)); ctx.lineTo(tHoz(x2), tVert(y2));
// fill the other rectangle if it's there // fill the other rectangle if it's there
if (x2 != x2old) { if (x2 != x2old) {
...@@ -750,20 +750,20 @@ ...@@ -750,20 +750,20 @@
else else
top = yaxis.max; top = yaxis.max;
ctx.lineTo(translateHoz(x2old), translateVert(top)); ctx.lineTo(tHoz(x2old), tVert(top));
ctx.lineTo(translateHoz(x2), translateVert(top)); ctx.lineTo(tHoz(x2), tVert(top));
} }
lastX = Math.max(x2, x2old); lastX = Math.max(x2, x2old);
} }
/* /*
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(translateHoz(data[0][0]), translateVert(0)); ctx.moveTo(tHoz(data[0][0]), tVert(0));
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
ctx.lineTo(translateHoz(data[i][0]), translateVert(data[i][1])); ctx.lineTo(tHoz(data[i][0]), tVert(data[i][1]));
} }
ctx.lineTo(translateHoz(data[data.length - 1][0]), translateVert(0));*/ ctx.lineTo(tHoz(data[data.length - 1][0]), tVert(0));*/
ctx.lineTo(translateHoz(lastX), translateVert(bottom)); ctx.lineTo(tHoz(lastX), tVert(bottom));
ctx.fill(); ctx.fill();
} }
...@@ -804,7 +804,7 @@ ...@@ -804,7 +804,7 @@
continue; continue;
ctx.beginPath(); ctx.beginPath();
ctx.arc(translateHoz(x), translateVert(y), radius, 0, 2 * Math.PI, true); ctx.arc(tHoz(x), tVert(y), radius, 0, 2 * Math.PI, true);
if (fill) if (fill)
ctx.fill(); ctx.fill();
ctx.stroke(); ctx.stroke();
...@@ -817,7 +817,7 @@ ...@@ -817,7 +817,7 @@
if (x < xaxis.min || x > xaxis.max || y < yaxis.min || y > yaxis.max) if (x < xaxis.min || x > xaxis.max || y < yaxis.min || y > yaxis.max)
continue; continue;
ctx.beginPath(); ctx.beginPath();
ctx.arc(translateHoz(x), translateVert(y) + offset, radius, 0, Math.PI, false); ctx.arc(tHoz(x), tVert(y) + offset, radius, 0, Math.PI, false);
ctx.stroke(); ctx.stroke();
} }
} }
...@@ -880,30 +880,30 @@ ...@@ -880,30 +880,30 @@
// fill the bar // fill the bar
if (fill) { if (fill) {
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(translateHoz(left), translateVert(bottom) + offset); ctx.moveTo(tHoz(left), tVert(bottom) + offset);
ctx.lineTo(translateHoz(left), translateVert(top) + offset); ctx.lineTo(tHoz(left), tVert(top) + offset);
ctx.lineTo(translateHoz(right), translateVert(top) + offset); ctx.lineTo(tHoz(right), tVert(top) + offset);
ctx.lineTo(translateHoz(right), translateVert(bottom) + offset); ctx.lineTo(tHoz(right), tVert(bottom) + offset);
ctx.fill(); ctx.fill();
} }
// draw outline // draw outline
if (drawLeft || drawRight || drawTop) { if (drawLeft || drawRight || drawTop) {
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(translateHoz(left), translateVert(bottom) + offset); ctx.moveTo(tHoz(left), tVert(bottom) + offset);
if (drawLeft) if (drawLeft)
ctx.lineTo(translateHoz(left), translateVert(top) + offset); ctx.lineTo(tHoz(left), tVert(top) + offset);
else else
ctx.moveTo(translateHoz(left), translateVert(top) + offset); ctx.moveTo(tHoz(left), tVert(top) + offset);
if (drawTop) if (drawTop)
ctx.lineTo(translateHoz(right), translateVert(top) + offset); ctx.lineTo(tHoz(right), tVert(top) + offset);
else else
ctx.moveTo(translateHoz(right), translateVert(top) + offset); ctx.moveTo(tHoz(right), tVert(top) + offset);
if (drawRight) if (drawRight)
ctx.lineTo(translateHoz(right), translateVert(bottom) + offset); ctx.lineTo(tHoz(right), tVert(bottom) + offset);
else else
ctx.moveTo(translateHoz(right), translateVert(bottom) + offset); ctx.moveTo(tHoz(right), tVert(bottom) + offset);
ctx.stroke(); ctx.stroke();
} }
} }
...@@ -1225,7 +1225,7 @@ ...@@ -1225,7 +1225,7 @@
} else { } else {
return "rgba("+[this.r,this.g,this.b,this.a].join(",")+")"; return "rgba("+[this.r,this.g,this.b,this.a].join(",")+")";
} }
} };
this.scale = function(rf, gf, bf, af) { this.scale = function(rf, gf, bf, af) {
x = 4; //rgba.length x = 4; //rgba.length
...@@ -1234,7 +1234,7 @@ ...@@ -1234,7 +1234,7 @@
this[rgba[x]] *= arguments[x]; this[rgba[x]] *= arguments[x];
} }
return this.normalize(); return this.normalize();
} };
this.adjust = function(rd, gd, bd, ad) { this.adjust = function(rd, gd, bd, ad) {
x = 4; //rgba.length x = 4; //rgba.length
...@@ -1243,23 +1243,23 @@ ...@@ -1243,23 +1243,23 @@
this[rgba[x]] += arguments[x]; this[rgba[x]] += arguments[x];
} }
return this.normalize(); return this.normalize();
} };
this.clone = function() { this.clone = function() {
return new Color(this.r, this.b, this.g, this.a); return new Color(this.r, this.b, this.g, this.a);
} };
var limit = function(val,minVal,maxVal) { var limit = function(val,minVal,maxVal) {
return Math.max(Math.min(val, maxVal), minVal); return Math.max(Math.min(val, maxVal), minVal);
} };
this.normalize = function() { this.normalize = function() {
this.r = limit(parseInt(this.r), 0, 255); this.r = limit(parseInt(this.r), 0, 255);
this.g = limit(parseInt(this.g), 0, 255); this.g = limit(parseInt(this.g), 0, 255);
this.b = limit(parseInt(this.b), 0, 255); this.b = limit(parseInt(this.b), 0, 255);
this.a = limit(this.a, 0, 1) this.a = limit(this.a, 0, 1);
return this; return this;
} };
this.normalize(); this.normalize();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment