Commit 61a13d10 authored by David Schnur's avatar David Schnur

Additional code & comments cleanup.

parent 492e97ea
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
// Find the URL in the link right next to us, then fetch the data // Find the URL in the link right next to us, then fetch the data
var dataurl = button.siblings('a').attr('href'); var dataurl = button.siblings("a").attr("href");
function onDataReceived(series) { function onDataReceived(series) {
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
{ data: generate(2, 10, function (x) { return Math.tan(x);}), xaxis: 2, yaxis: 4 } { data: generate(2, 10, function (x) { return Math.tan(x);}), xaxis: 2, yaxis: 4 }
]; ];
var plot = $.plot($("#placeholder"), data, { var plot = $.plot("#placeholder", data, {
xaxes: [ xaxes: [
{ position: 'bottom' }, { position: 'bottom' },
{ position: 'top'} { position: 'top'}
...@@ -40,16 +40,17 @@ ...@@ -40,16 +40,17 @@
] ]
}); });
// now for each axis, create a div // Create a div for each axis
$.each(plot.getAxes(), function (i, axis) { $.each(plot.getAxes(), function (i, axis) {
if (!axis.show) if (!axis.show)
return; return;
var box = axis.box; var box = axis.box;
$('<div class="axisTarget" style="position:absolute;left:' + box.left + 'px;top:' + box.top + 'px;width:' + box.width + 'px;height:' + box.height + 'px"></div>') $("<div class='axisTarget' style='position:absolute; left:" + box.left + "px; top:" + box.top + "px; width:" + box.width + "px; height:" + box.height + "px'></div>")
.data('axis.direction', axis.direction) .data("axis.direction", axis.direction)
.data('axis.n', axis.n) .data("axis.n", axis.n)
.css({ backgroundColor: "#f00", opacity: 0, cursor: "pointer" }) .css({ backgroundColor: "#f00", opacity: 0, cursor: "pointer" })
.appendTo(plot.getPlaceholder()) .appendTo(plot.getPlaceholder())
.hover( .hover(
......
This diff is collapsed.
This diff is collapsed.
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
d3.push([i, Math.tan(i)]); d3.push([i, Math.tan(i)]);
} }
$.plot( $("#placeholder"), [ $.plot("#placeholder", [
{ label: "sin(x)", data: d1 }, { label: "sin(x)", data: d1 },
{ label: "cos(x)", data: d2 }, { label: "cos(x)", data: d2 },
{ label: "tan(x)", data: d3 } { label: "tan(x)", data: d3 }
......
...@@ -10,13 +10,16 @@ ...@@ -10,13 +10,16 @@
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
var d1 = []; var d1 = [];
for (var i = 0; i < 14; i += 0.5) for (var i = 0; i < 14; i += 0.5) {
d1.push([i, Math.sin(i)]); d1.push([i, Math.sin(i)]);
}
var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]]; var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];
// a null signifies separate line segments // A null signifies separate line segments
var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]]; var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];
$.plot("#placeholder", [ d1, d2, d3 ]); $.plot("#placeholder", [ d1, d2, d3 ]);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
var data = [ ["January", 10], ["February", 8], ["March", 4], ["April", 13], ["May", 17], ["June", 9] ]; var data = [ ["January", 10], ["February", 8], ["March", 4], ["April", 13], ["May", 17], ["June", 9] ];
$.plot($("#placeholder"), [ data ], { $.plot("#placeholder", [ data ], {
series: { series: {
bars: { bars: {
show: true, show: true,
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
}; };
$.plot.image.loadDataImages(data, options, function () { $.plot.image.loadDataImages(data, options, function () {
$.plot($("#placeholder"), data, options); $.plot("#placeholder", data, options);
}); });
}); });
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
cos.push([i, Math.cos(i)]); cos.push([i, Math.cos(i)]);
} }
var plot = $.plot($("#placeholder"), [ var plot = $.plot("#placeholder", [
{ data: sin, label: "sin(x)"}, { data: sin, label: "sin(x)"},
{ data: cos, label: "cos(x)"} { data: cos, label: "cos(x)"}
], { ], {
......
This diff is collapsed.
...@@ -64,9 +64,9 @@ ...@@ -64,9 +64,9 @@
} }
}); });
var plot = $.plot($("#placeholder"), [ getRandomData() ], { var plot = $.plot("#placeholder", [ getRandomData() ], {
series: { series: {
shadowSize: 0 // drawing is faster without shadows shadowSize: 0 // Drawing is faster without shadows
}, },
yaxis: { yaxis: {
min: 0, min: 0,
...@@ -78,8 +78,11 @@ ...@@ -78,8 +78,11 @@
}); });
function update() { function update() {
plot.setData([ getRandomData() ]);
plot.setData([getRandomData()]);
// Since the axes don't change, we don't need to call plot.setupGrid() // Since the axes don't change, we don't need to call plot.setupGrid()
plot.draw(); plot.draw();
setTimeout(update, updateInterval); setTimeout(update, updateInterval);
} }
......
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
}); });
if (data.length > 0) { if (data.length > 0) {
$.plot($("#placeholder"), data, { $.plot("#placeholder", data, {
yaxis: { yaxis: {
min: 0 min: 0
}, },
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
d6.push([i, Math.sqrt(2*i + Math.sin(i) + 5)]); d6.push([i, Math.sqrt(2*i + Math.sin(i) + 5)]);
} }
$.plot($("#placeholder"), [{ $.plot("#placeholder", [{
data: d1, data: d1,
lines: { show: true, fill: true } lines: { show: true, fill: true }
}, { }, {
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
steps = false; steps = false;
function plotWithOptions() { function plotWithOptions() {
$.plot($("#placeholder"), [ d1, d2, d3 ], { $.plot("#placeholder", [ d1, d2, d3 ], {
series: { series: {
stack: stack, stack: stack,
lines: { lines: {
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
{ data: generate(7, 1.1), points: { symbol: "cross" } } { data: generate(7, 1.1), points: { symbol: "cross" } }
]; ];
$.plot($("#placeholder"), data, { $.plot("#placeholder", data, {
series: { series: {
points: { points: {
show: true, show: true,
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
} }
function plotWithOptions(t) { function plotWithOptions(t) {
$.plot($("#placeholder"), [{ $.plot("#placeholder", [{
data: d1, data: d1,
color: "rgb(30, 180, 20)", color: "rgb(30, 180, 20)",
threshold: { threshold: {
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
cos.push([i, Math.cos(i)]); cos.push([i, Math.cos(i)]);
} }
plot = $.plot($("#placeholder"), [ plot = $.plot("#placeholder", [
{ data: sin, label: "sin(x) = -0.00"}, { data: sin, label: "sin(x) = -0.00"},
{ data: cos, label: "cos(x) = -0.00" } { data: cos, label: "cos(x) = -0.00" }
], { ], {
...@@ -67,14 +67,16 @@ ...@@ -67,14 +67,16 @@
var series = dataset[i]; var series = dataset[i];
// find the nearest points, x-wise // Find the nearest points, x-wise
for (j = 0; j < series.data.length; ++j) { for (j = 0; j < series.data.length; ++j) {
if (series.data[j][0] > pos.x) { if (series.data[j][0] > pos.x) {
break; break;
} }
} }
// now interpolate // Now Interpolate
var y, var y,
p1 = series.data[j - 1], p1 = series.data[j - 1],
p2 = series.data[j]; p2 = series.data[j];
......
...@@ -63,9 +63,9 @@ ...@@ -63,9 +63,9 @@
} }
}; };
var plot = $.plot($("#placeholder"), [d], options); var plot = $.plot("#placeholder", [d], options);
var overview = $.plot($("#overview"), [d], { var overview = $.plot("#overview", [d], {
series: { series: {
lines: { lines: {
show: true, show: true,
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
// do the zooming // do the zooming
plot = $.plot($("#placeholder"), [d], $.extend(true, {}, options, { plot = $.plot("#placeholder", [d], $.extend(true, {}, options, {
xaxis: { xaxis: {
min: ranges.xaxis.from, min: ranges.xaxis.from,
max: ranges.xaxis.to max: ranges.xaxis.to
......
...@@ -49,11 +49,11 @@ ...@@ -49,11 +49,11 @@
var startData = getData(0, 3 * Math.PI); var startData = getData(0, 3 * Math.PI);
var plot = $.plot($("#placeholder"), startData, options); var plot = $.plot("#placeholder", startData, options);
// setup overview // Create the overview plot
var overview = $.plot($("#overview"), startData, { var overview = $.plot("#overview", startData, {
legend: { legend: {
show: false show: false
}, },
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
// do the zooming // do the zooming
plot = $.plot($("#placeholder"), getData(ranges.xaxis.from, ranges.xaxis.to), plot = $.plot("#placeholder", getData(ranges.xaxis.from, ranges.xaxis.to),
$.extend(true, {}, options, { $.extend(true, {}, options, {
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to }, xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to },
yaxis: { min: ranges.yaxis.from, max: ranges.yaxis.to } yaxis: { min: ranges.yaxis.from, max: ranges.yaxis.to }
......
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