Bugfix #282. Use valueRange (if specified) instead of extremes during unzooming....
[dygraphs.git] / dygraph-options-reference.js
index 5bc7f63..a94a54f 100644 (file)
@@ -1,3 +1,12 @@
+/**
+ * @license
+ * Copyright 2011 Dan Vanderkam (danvdk@gmail.com)
+ * MIT-licensed (http://opensource.org/licenses/MIT)
+ */
+
+/*jshint globalstrict: true */
+/*global Dygraph:false */
+
 // 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
@@ -103,16 +112,22 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
     "description": "Put <code>&lt;br/&gt;</code> between lines in the label string. Often used in conjunction with <strong>labelsDiv</strong>."
   },
   "xValueFormatter": {
-    "default": "(Round to 2 decimal places)",
-    "labels": ["Axis display"],
-    "type": "function(x)",
-    "description": "Function to provide a custom display format for the X value for mouseover."
+    "default": "",
+    "labels": ["Deprecated"],
+    "type": "",
+    "description": "Prefer axes: { x: { valueFormatter } }"
+  },
+  "valueFormatter": {
+    "default": "Depends on the type of your data.",
+    "labels": ["Legend", "Value display/formatting"],
+    "type": "function(num or millis, opts, dygraph)",
+    "description": "Function to provide a custom display format for the values displayed on mouseover. This does not affect the values that appear on tick marks next to the axes. To format those, see axisLabelFormatter. This is usually set on a <a href='per-axis.html'>per-axis</a> basis. For date axes, you can call new Date(millis) to get a Date object. opts is a function you can call to access various options (e.g. opts('labelsKMB'))."
   },
   "pixelsPerYLabel": {
-    "default": "30",
-    "labels": ["Axis display", "Grid"],
+    "default": "",
+    "labels": ["Deprecated"],
     "type": "integer",
-    "description": "Number of pixels to require between each x- and y-label. Larger values will yield a sparser axis with fewer ticks."
+    "description": "Prefer axes: { y: { pixelsPerLabel } }"
   },
   "annotationMouseOverHandler": {
     "default": "null",
@@ -180,11 +195,11 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
     "type": "Object",
     "description": "TODO(konigsberg): document this"
   },
-  "xTicker": {
+  "ticker": {
     "default": "Dygraph.dateTicker or Dygraph.numericTicks",
     "labels": ["Axis display"],
-    "type": "function(min, max, dygraph) -> [{v: ..., label: ...}, ...]",
-    "description": "This lets you specify an arbitrary function to generate tick marks on an axis. The tick marks are an array of (value, label) pairs. The built-in functions go to great lengths to choose good tick marks so, if you set this option, you'll most likely want to call one of them and modify the result."
+    "type": "function(min, max, pixels, opts, dygraph, vals) -> [{v: ..., label: ...}, ...]",
+    "description": "This lets you specify an arbitrary function to generate tick marks on an axis. The tick marks are an array of (value, label) pairs. The built-in functions go to great lengths to choose good tick marks so, if you set this option, you'll most likely want to call one of them and modify the result. See dygraph-tickers.js for an extensive discussion. This is set on a <a href='per-axis.html'>per-axis</a> basis."
   },
   "xAxisLabelWidth": {
     "default": "50",
@@ -211,10 +226,16 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
     "description": "Set to either an object ({}) filled with options for this axis or to the name of an existing data series with its own axis to re-use that axis. See tests for usage."
   },
   "pixelsPerXLabel": {
-    "default": "60",
+    "default": "",
+    "labels": ["Deprecated"],
+    "type": "integer",
+    "description": "Prefer axes { x: { pixelsPerLabel } }"
+  },
+  "pixelsPerLabel": {
+    "default": "60 (x-axis) or 30 (y-axes)",
     "labels": ["Axis display", "Grid"],
     "type": "integer",
-    "description": "Number of pixels to require between each x- and y-label. Larger values will yield a sparser axis with fewer ticks."
+    "description": "Number of pixels to require between each x- and y-label. Larger values will yield a sparser axis with fewer ticks. This is set on a <a href='per-axis.html'>per-axis</a> basis."
   },
   "labelsDiv": {
     "default": "null",
@@ -242,6 +263,13 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
     "example": "0.5, 2.0",
     "description": "The width of the lines connecting data points. This can be used to increase the contrast or some graphs."
   },
+  "strokePattern": {
+    "default": "null",
+    "labels": ["Data Line display"],
+    "type": "array<integer>",
+    "example": "[10, 2, 5, 2]",
+    "description": "A custom pattern array where the even index is a draw and odd is a space in pixels. If null then it draws a solid line. The array should have a even length as any odd lengthed array could be expressed as a smaller even length array."
+  },
   "wilsonInterval": {
     "default": "true",
     "labels": ["Error Bars"],
@@ -277,7 +305,7 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
     "labels": ["Axis display"],
     "type": "Array of two numbers",
     "example": "[10, 110]",
-    "description": "Explicitly set the vertical range of the graph to [low, high]."
+    "description": "Explicitly set the vertical range of the graph to [low, high]. This may be set on a per-axis basis to define each y-axis separately."
   },
   "labelsDivWidth": {
     "default": "250",
@@ -304,10 +332,10 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
     "description": "Whether to hide the legend when the mouse leaves the chart area."
   },
   "yValueFormatter": {
-    "default": "(Round to 2 decimal places)",
-    "labels": ["Axis display"],
-    "type": "function(x)",
-    "description": "Function to provide a custom display format for the Y value for mouseover."
+    "default": "",
+    "labels": ["Deprecated"],
+    "type": "",
+    "description": "Prefer axes: { y: { valueFormatter } }"
   },
   "legend": {
     "default": "onmouseover",
@@ -346,10 +374,16 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
     "description": "When set, the heuristic that fixes the Y axis at zero for a data set with the minimum Y value of zero is disabled. \nThis is particularly useful for data sets that contain many zero values, especially for step plots which may otherwise have lines not visible running along the bottom axis."
   },
   "xAxisLabelFormatter": {
-    "default": "Dygraph.dateAxisFormatter",
-    "labels": ["Axis display", "Value display/formatting"],
-    "type": "function(date, granularity)",
-    "description": "Function to call to format values along the x axis."
+    "default": "",
+    "labels": ["Deprecated"],
+    "type": "",
+    "description": "Prefer axes { x: { axisLabelFormatter } }"
+  },
+  "axisLabelFormatter": {
+    "default": "Depends on the data type",
+    "labels": ["Axis display"],
+    "type": "function(number or Date, granularity, opts, dygraph)",
+    "description": "Function to call to format the tick values that appear along an axis. This is usually set on a <a href='per-axis.html'>per-axis</a> basis. The first parameter is either a number (for a numeric axis) or a Date object (for a date axis). The second argument specifies how fine-grained the axis is. For date axes, this is a reference to the time granularity enumeration, defined in dygraph-tickers.js, e.g. Dygraph.WEEKLY. opts is a function which provides access to various options on the dygraph, e.g. opts('labelsKMB')."
   },
   "clickCallback": {
     "snippet": "function(e, date_millis){<br>&nbsp;&nbsp;alert(new Date(date_millis));<br>}",
@@ -359,10 +393,10 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
     "description": "A function to call when the canvas is clicked. The function should take three arguments, the event object for the click, the x-value that was clicked (for dates this is millis since epoch), and the closest points along that date. The points have these properties:\n * xval/yval: The data coordinates of the point (with dates/times as millis since epoch) \n * canvasx/canvasy: The canvas coordinates at which the point is drawn. \n name: The name of the data series to which the point belongs"
   },
   "yAxisLabelFormatter": {
-    "default": "yValueFormatter",
-    "labels": ["Axis display", "Value display/formatting"],
-    "type": "function(x)",
-    "description": "Function used to format values along the Y axis. By default it uses the same as the <code>yValueFormatter</code> unless specified."
+    "default": "",
+    "labels": ["Deprecated"],
+    "type": "",
+    "description": "Prefer axes: { y: { axisLabelFormatter } }"
   },
   "labels": {
     "default": "[\"X\", \"Y1\", \"Y2\", ...]*",
@@ -417,7 +451,6 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
     "default": "null",
     "labels": ["Axis display", "Interactive Elements"],
     "type": "float",
-    "default": "null",
     "description": "A value representing the farthest a graph may be panned, in percent of the display. For example, a value of 0.1 means that the graph can only be panned 10% pased the edges of the displayed values. null means no bounds."
   },
   "title": {
@@ -450,6 +483,12 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
     "default": "null",
     "description": "Text to display to the left of the chart's y-axis. You can supply any HTML for this value, not just text. If you wish to style it using CSS, use the 'dygraph-label' or 'dygraph-ylabel' classes. The text will be rotated 90 degrees by default, so CSS rules may behave in unintuitive ways. No additional space is set aside for a y-axis label. If you need more space, increase the width of the y-axis tick labels using the yAxisLabelWidth option. If you need a wider div for the y-axis label, either style it that way with CSS (but remember that it's rotated, so width is controlled by the 'height' property) or set the yLabelWidth option."
   },
+  "y2label": {
+    "labels": ["Chart labels"],
+    "type": "string",
+    "default": "null",
+    "description": "Text to display to the right of the chart's secondary y-axis. This label is only displayed if a secondary y-axis is present. See <a href='http://dygraphs.com/tests/two-axes.html'>this test</a> for an example of how to do this. The comments for the 'ylabel' option generally apply here as well. This label gets a 'dygraph-y2label' instead of a 'dygraph-ylabel' class."
+  },
   "yLabelWidth": {
     "labels": ["Chart labels"],
     "type": "integer",
@@ -545,6 +584,42 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
     "labels": ["Data"],
     "type": "string (URL of CSV or CSV), GViz DataTable or 2D Array",
     "description": "Sets the data being displayed in the chart. This can only be set when calling updateOptions; it cannot be set from the constructor. For a full description of valid data formats, see the <a href='http://dygraphs.com/data.html'>Data Formats</a> page."
+  },
+  "timingName": {
+    "default": "null",
+    "labels": [ "Debugging" ],
+    "type": "string",
+    "description": "Set this option to log timing information. The value of the option will be logged along with the timimg, so that you can distinguish multiple dygraphs on the same page."
+  },
+  "showRangeSelector": {
+    "default": "false",
+    "labels": ["Interactive Elements"],
+    "type": "boolean",
+    "description": "Show the range selector widget. This option can only be specified at Dygraph creation time."
+  },
+  "rangeSelectorHeight": {
+    "default": "40",
+    "labels": ["Interactive Elements"],
+    "type": "integer",
+    "description": "Height, in pixels, of the range selector widget. This option can only be specified at Dygraph creation time."
+  },
+  "rangeSelectorPlotStrokeColor": {
+    "default": "#808FAB",
+    "labels": ["Interactive Elements"],
+    "type": "string",
+    "description": "The range selector mini plot stroke color. This can be of the form \"#AABBCC\" or \"rgb(255,100,200)\" or \"yellow\". You can also specify null or \"\" to turn off stroke."
+  },
+  "rangeSelectorPlotFillColor": {
+    "default": "#A7B1C4",
+    "labels": ["Interactive Elements"],
+    "type": "string",
+    "description": "The range selector mini plot fill color. This can be of the form \"#AABBCC\" or \"rgb(255,100,200)\" or \"yellow\". You can also specify null or \"\" to turn off fill."
+  },
+  "animatedZooms": {
+    "default": "false",
+    "labels": ["Interactive Elements"],
+    "type": "boolean",
+    "description": "Set this option to animate the transition between zoom windows. Applies to programmatic and interactive zooms. Note that if you also set a drawCallback, it will be called several times on each zoom. If you set a zoomCallback, it will only be called after the animation is complete."
   }
 }
 ;  // </JSON>
@@ -555,9 +630,10 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
 
 // Do a quick sanity check on the options reference.
 (function() {
+  "use strict";
   var warn = function(msg) { if (console) console.warn(msg); };
   var flds = ['type', 'default', 'description'];
-  var valid_cats = [ 
+  var valid_cats = [
    'Annotations',
    'Axis display',
    'Chart labels',
@@ -573,26 +649,29 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
    'Overall display',
    'Rolling Averages',
    'Value display/formatting',
-   'Zooming'
+   'Zooming',
+   'Debugging',
+   'Deprecated'
   ];
+  var i;
   var cats = {};
-  for (var i = 0; i < valid_cats.length; i++) cats[valid_cats[i]] = true;
+  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 (var i = 0; i < flds.length; i++) {
+    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'];
+    var labels = op.labels;
     if (typeof(labels) !== 'object') {
       warn('Option "' + k + '" is missing a "labels": [...] option');
     } else {
-      for (var i = 0; i < labels.length; i++) {
+      for (i = 0; i < labels.length; i++) {
         if (!cats.hasOwnProperty(labels[i])) {
           warn('Option "' + k + '" has label "' + labels[i] +
                '", which is invalid.');