Index.draw = function(element, data, options) {
element.innerHTML = "";
element.removeAttribute("style");
+
+ // Replace the drawCallback function with one that also lets us track
+ // all labels (for the palette.)
+ // If the drawCallback option is not specified, use a null function.
+ var originalDraw = options["drawCallback"] || function() {};
+ options.drawCallback = function(g, isInitial) {
+ Index.palette.setSeries(g.getLabels());
+ // Call the original function, too.
+ originalDraw(g, isInitial);
+ };
+
var g = new Dygraph(
element,
data,
var sample = Samples.data[sampleIndex];
var data = sample.data;
var redraw = function() {
- Index.draw(document.getElementById("graph"), data, palette.read());
+ Index.draw(document.getElementById("graph"), data, Index.palette.read());
}
// Selector is the drop-down for selecting a set of data.
selector.selectedIndex = sampleIndex;
// Palette contains the widget that builds options.
- var palette = new MultiPalette();
- palette.create(document.getElementById("optionsPalette"));
- palette.write(sample.options);
- palette.onchange = redraw;
- palette.filterBar.focus();
+ Index.palette = new MultiPalette();
+ Index.palette.create(document.getElementById("optionsPalette"));
+ Index.palette.write(sample.options);
+ Index.palette.onchange = redraw;
+ Index.palette.filterBar.focus();
redraw();