Add support for animated zooms.
[dygraphs.git] / dygraph-options-reference.js
index 6ba8f8e..b29bb47 100644 (file)
@@ -1,3 +1,9 @@
+/**
+ * @license
+ * Copyright 2011 Dan Vanderkam (danvdk@gmail.com)
+ * MIT-licensed (http://opensource.org/licenses/MIT)
+ */
+
 // 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
@@ -47,10 +53,11 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
     "description": "A function to call when the zoom window is changed (either by zooming in or out). minDate and maxDate are milliseconds since epoch. yRanges is an array of [bottom, top] pairs, one for each y-axis."
   },
   "pointClickCallback": {
-    "default": "",
+    "snippet": "function(e, point){<br>&nbsp;&nbsp;alert(point);<br>}",
+    "default": "null",
     "labels": ["Callbacks", "Interactive Elements"],
-    "type": "",
-    "description": ""
+    "type": "function(e, point)",
+    "description": "A function to call when a data point is clicked. The function should take two arguments, the event object for the click, and the point that was clicked. The 'point' argument has 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"
   },
   "colors": {
     "default": "(see description)",
@@ -102,16 +109,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",
@@ -182,8 +195,14 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
   "xTicker": {
     "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."
+  },
+  "xTicker": {
+    "default": "",
+    "labels": ["Deprecated"],
+    "type": "",
+    "description": "Prefer axes: { x: { ticker } }"
   },
   "xAxisLabelWidth": {
     "default": "50",
@@ -210,10 +229,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",
@@ -303,10 +328,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",
@@ -345,23 +370,29 @@ 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){<br>&nbsp;&nbsp;alert(date);<br>}",
+    "snippet": "function(e, date_millis){<br>&nbsp;&nbsp;alert(new Date(date_millis));<br>}",
     "default": "null",
     "labels": ["Callbacks"],
-    "type": "function(e, date)",
-    "description": "A function to call when a data point is clicked. The function should take two arguments, the event object for the click and the date that was clicked."
+    "type": "function(e, x, points)",
+    "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\", ...]*",
@@ -544,6 +575,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>
@@ -556,7 +623,7 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
 (function() {
   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',
@@ -572,7 +639,9 @@ Dygraph.OPTIONS_REFERENCE =  // <JSON>
    'Overall display',
    'Rolling Averages',
    'Value display/formatting',
-   'Zooming'
+   'Zooming',
+   'Debugging',
+   'Deprecated'
   ];
   var cats = {};
   for (var i = 0; i < valid_cats.length; i++) cats[valid_cats[i]] = true;