Merge pull request #761 from justinsg/master
[dygraphs.git] / src / dygraph-options-reference.js
index 933bdab..4b1a23b 100644 (file)
@@ -4,11 +4,18 @@
  * MIT-licensed (http://opensource.org/licenses/MIT)
  */
 
+"use strict";
+
+var OPTIONS_REFERENCE = null;
+
+// For "production" code, this gets removed by uglifyjs.
+if (process.env.NODE_ENV != 'production') {
+
 // NOTE: in addition to parsing as JS, this snippet is expected to be valid
 // JSON. This assumption cannot be checked in JS, but it will be checked when
 // documentation is generated by the generate-documentation.py script. For the
 // most part, this just means that you should always use double quotes.
-Dygraph.OPTIONS_REFERENCE =  // <JSON>
+OPTIONS_REFERENCE =  // <JSON>
 {
   "xValueParser": {
     "default": "parseFloat() or Date.parse()*",
@@ -157,6 +164,12 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
     "type": "float",
     "description": "Fade the background while highlighting series. 1=fully visible background (disable fading), 0=hiddden background (show highlighted series only)."
   },
+  "highlightSeriesBackgroundColor": {
+    "default": "rgb(255, 255, 255)",
+    "labels": ["Interactive Elements"],
+    "type": "string",
+    "description": "Sets the background color used to fade out the series in conjunction with 'highlightSeriesBackgroundAlpha'."
+  },
   "includeZero": {
     "default": "false",
     "labels": ["Axis display"],
@@ -450,6 +463,15 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
     "type": "string",
     "description": "When to display the legend. By default, it only appears when a user mouses over the chart. Set it to \"always\" to always display a legend of some sort. When set to \"follow\", legend follows highlighted points."
   },
+  "legendFormatter": {
+    "default": "null",
+    "labels": ["Legend"],
+    "type": "function(data): string",
+    "params": [
+      [ "data", "An object containing information about the selection (or lack of a selection). This includes formatted values and series information. See <a href=\"https://github.com/danvk/dygraphs/pull/683\">here</a> for sample values." ]
+    ],
+    "description": "Set this to supply a custom formatter for the legend. See <a href=\"https://github.com/danvk/dygraphs/pull/683\">this comment</a> and the <a href=\"tests/legend-formatter.html\">legendFormatter demo</a> for usage."
+  },
   "labelsShowZeroValues": {
     "default": "true",
     "labels": ["Legend"],
@@ -831,57 +853,58 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
 // most part, this just means that you should always use double quotes.
 
 // Do a quick sanity check on the options reference.
-(function() {
-  "use strict";
-  var warn = function(msg) { if (window.console) window.console.warn(msg); };
-  var flds = ['type', 'default', 'description'];
-  var valid_cats = [
-   'Annotations',
-   'Axis display',
-   'Chart labels',
-   'CSV parsing',
-   'Callbacks',
-   'Data',
-   'Data Line display',
-   'Data Series Colors',
-   'Error Bars',
-   'Grid',
-   'Interactive Elements',
-   'Range Selector',
-   'Legend',
-   'Overall display',
-   'Rolling Averages',
-   'Series',
-   'Value display/formatting',
-   'Zooming',
-   'Debugging',
-   'Configuration',
-   'Deprecated'
-  ];
-  var i;
-  var cats = {};
-  for (i = 0; i < valid_cats.length; i++) cats[valid_cats[i]] = true;
+var warn = function(msg) { if (window.console) window.console.warn(msg); };
+var flds = ['type', 'default', 'description'];
+var valid_cats = [
+ 'Annotations',
+ 'Axis display',
+ 'Chart labels',
+ 'CSV parsing',
+ 'Callbacks',
+ 'Data',
+ 'Data Line display',
+ 'Data Series Colors',
+ 'Error Bars',
+ 'Grid',
+ 'Interactive Elements',
+ 'Range Selector',
+ 'Legend',
+ 'Overall display',
+ 'Rolling Averages',
+ 'Series',
+ 'Value display/formatting',
+ 'Zooming',
+ 'Debugging',
+ 'Configuration',
+ 'Deprecated'
+];
+var i;
+var cats = {};
+for (i = 0; i < valid_cats.length; i++) cats[valid_cats[i]] = true;
 
-  for (var k in Dygraph.OPTIONS_REFERENCE) {
-    if (!Dygraph.OPTIONS_REFERENCE.hasOwnProperty(k)) continue;
-    var op = Dygraph.OPTIONS_REFERENCE[k];
-    for (i = 0; i < flds.length; i++) {
-      if (!op.hasOwnProperty(flds[i])) {
-        warn('Option ' + k + ' missing "' + flds[i] + '" property');
-      } else if (typeof(op[flds[i]]) != 'string') {
-        warn(k + '.' + flds[i] + ' must be of type string');
-      }
+for (var k in OPTIONS_REFERENCE) {
+  if (!OPTIONS_REFERENCE.hasOwnProperty(k)) continue;
+  var op = OPTIONS_REFERENCE[k];
+  for (i = 0; i < flds.length; i++) {
+    if (!op.hasOwnProperty(flds[i])) {
+      warn('Option ' + k + ' missing "' + flds[i] + '" property');
+    } else if (typeof(op[flds[i]]) != 'string') {
+      warn(k + '.' + flds[i] + ' must be of type string');
     }
-    var labels = op.labels;
-    if (typeof(labels) !== 'object') {
-      warn('Option "' + k + '" is missing a "labels": [...] option');
-    } else {
-      for (i = 0; i < labels.length; i++) {
-        if (!cats.hasOwnProperty(labels[i])) {
-          warn('Option "' + k + '" has label "' + labels[i] +
-               '", which is invalid.');
-        }
+  }
+  var labels = op.labels;
+  if (typeof(labels) !== 'object') {
+    warn('Option "' + k + '" is missing a "labels": [...] option');
+  } else {
+    for (i = 0; i < labels.length; i++) {
+      if (!cats.hasOwnProperty(labels[i])) {
+        warn('Option "' + k + '" has label "' + labels[i] +
+             '", which is invalid.');
       }
     }
   }
-})();
+}
+
+}
+
+export default OPTIONS_REFERENCE;