SigPlot is fairly simple to instantiate and use. First, create a placeholder for the plot:
<div id="plot"></div>
Then ensure that it has a non-zero size by using CSS:
#plot { height: 400px; width: 600px; }
Instantiate the plot:
plot = new sigplot.Plot(document.getElementById('plot'), {});
Then add layers:
plot.overlay_array(data);
SigPlot also directly supports the specialized BLUEFILE format:
plot.overlay_href('../dat/sin.tmp');
By default, raster plots do not smooth so that each individual data element can be clearly seen. This is typically done when you want to clearly see individual FFTbins. If you prefer smoothing you can change the rasterSmoothing setting.
plot.change_settings({rasterSmoothing: true});
The overlay_href method is asyncronous, because the underlying HTTP request is handle asyncronously. If you want to take an action when the layer has been downloaded, use the onload callback.
plot.overlay_href('../dat/sin.tmp', function(hdr, layer_n) {
console.log("Finished overlay")
});
If you make two overlay_href calls, the order of the layers will be arbitrary.
plot.overlay_href('../dat/sin.tmp');
plot.overlay_href('../dat/square.tmp'); // If square.tmp downloads first, if will be the first layer
You can avoid this with the following pattern:
// Use Immediately invoked function to create a closure
// so we can load files remotely, but keep the order
(function(p, files) {
var do_next_overlay = function() {
var f = files.shift();
if (f) {
p.overlay_href(f, do_next_overlay);
} else {
// We are done loading layers
p.rescale();
}
}
do_next_overlay(); // Kick things off
})(plot, ["../dat/pulse.tmp", "../dat/sin.tmp"]);
SigPlot defaults to an wheel scroll orientation, where scrolling the wheel forward will pan down while rolling backwards will pan up. You can change this setting if desired.
plot.change_settings({wheelscroll_mode_natural: false});
SigPlot provides scrollbars along each axis to allow panning of the plot. Zoom in to a region of the above plot and try out the following features:
Arrows are provided at the end of each scrollbar for stepping through a plot in either direction. Single-clicking one of these arrows will pan the plot by one step.
To pan a plot one page at a time, click anywhere in the trough between a panbar and one of the arrows at either end of a scrollbar.
SigPlot allows you to continuously pan a plot. To do this, keep your left mouse button held down while stepping or paging.
Dragging a panbar along an axis will allow you to quickly move from viewing one part of a plot to another.
SigPlot allows you to re-center your plot to a specific value along an axis. To do this, click on one of the numerical labels along an axis.
SigPlot allows you to expand or shrink the range of values visible within the plot area along an axis. To use this feature, middle-click with your mouse on a scrollbar and choose one of the options from the menu that pops up.
SigPlot also allows you to pan a plot by scrolling your mousewheel up or down while hovering your mouse over a scrollbar.
By default the scroll orientation is inverted/natural, meaning that when you scroll the wheel forward the plot will pan down (away from you) and when you scroll the wheel backwards the plot will pan up (towards you). You can change to a "normal" orientation using SigPlot's menu.