Add a:visited style to link-interaction (#819)
[dygraphs.git] / gallery / highlighted-series.js
index 27a6458..5e97bca 100644 (file)
@@ -1,3 +1,4 @@
+/*global Gallery,Dygraph,data */
 Gallery.register(
   'highlighted-series',
   {
@@ -27,19 +28,6 @@ var getData = function(numSeries, numRows, isStacked) {
   return data;
 };
 
-var makeClickCallback = function(graph) {
-  var isLocked = false;
-  return function(ev) {
-    if (isLocked) {
-      graph.clearSelection();
-      isLocked = false;
-    } else {
-      graph.setSelection(graph.getSelection(), graph.getHighlightSeries(), true);
-      isLocked = true;
-    }
-  };
-};
-
 var makeGraph = function(className, numSeries, numRows, isStacked) {
   var demo = document.getElementById('demo');
   var div = document.createElement('div');
@@ -70,10 +58,17 @@ var makeGraph = function(className, numSeries, numRows, isStacked) {
         highlightSeriesOpts: {
           strokeWidth: 3,
           strokeBorderWidth: 1,
-          highlightCircleSize: 5,
-        },
+          highlightCircleSize: 5
+        }
       });
-  g.updateOptions({clickCallback: makeClickCallback(g)}, true);
+  var onclick = function(ev) {
+    if (g.isSeriesLocked()) {
+      g.clearSelection();
+    } else {
+      g.setSelection(g.getSelection(), g.getHighlightSeries(), true);
+    }
+  };
+  g.updateOptions({clickCallback: onclick}, true);
   g.setSelection(false, 's005');
   //console.log(g);
 };