Add test suite for DygraphOptions object. Fix broken method in it.
[dygraphs.git] / dygraph-options-reference.js
CommitLineData
88e95c46
DV
1/**
2 * @license
3 * Copyright 2011 Dan Vanderkam (danvdk@gmail.com)
4 * MIT-licensed (http://opensource.org/licenses/MIT)
5 */
5108eb20 6
758a629f
DV
7/*jshint globalstrict: true */
8/*global Dygraph:false */
9
74a5af31
DV
10// NOTE: in addition to parsing as JS, this snippet is expected to be valid
11// JSON. This assumption cannot be checked in JS, but it will be checked when
12// documentation is generated by the generate-documentation.py script. For the
13// most part, this just means that you should always use double quotes.
14Dygraph.OPTIONS_REFERENCE = // <JSON>
15{
16 "xValueParser": {
17 "default": "parseFloat() or Date.parse()*",
18 "labels": ["CSV parsing"],
19 "type": "function(str) -> number",
20 "description": "A function which parses x-values (i.e. the dependent series). Must return a number, even when the values are dates. In this case, millis since epoch are used. This is used primarily for parsing CSV data. *=Dygraphs is slightly more accepting in the dates which it will parse. See code for details."
21 },
22 "stackedGraph": {
23 "default": "false",
24 "labels": ["Data Line display"],
25 "type": "boolean",
890e2a37 26 "description": "If set, stack series on top of one another rather than drawing them independently. The first series specified in the input data will wind up on top of the chart and the last will be on bottom."
74a5af31
DV
27 },
28 "pointSize": {
29 "default": "1",
30 "labels": ["Data Line display"],
31 "type": "integer",
32 "description": "The size of the dot to draw on each point in pixels (see drawPoints). A dot is always drawn when a point is \"isolated\", i.e. there is a missing point on either side of it. This also controls the size of those dots."
33 },
34 "labelsDivStyles": {
35 "default": "null",
36 "labels": ["Legend"],
37 "type": "{}",
e2c21500 38 "description": "Additional styles to apply to the currently-highlighted points div. For example, { 'fontWeight': 'bold' } will make the labels bold. In general, it is better to use CSS to style the .dygraph-legend class than to use this property."
74a5af31
DV
39 },
40 "drawPoints": {
41 "default": "false",
42 "labels": ["Data Line display"],
43 "type": "boolean",
47e07d08 44 "description": "Draw a small dot at each point, in addition to a line going through the point. This makes the individual data points easier to see, but can increase visual clutter in the chart. The small dot can be replaced with a custom rendering by supplying a <a href='#drawPointCallback'>drawPointCallback</a>."
78e58af4 45 },
a5a50727 46 "drawGapEdgePoints": {
19b84fe7
KW
47 "default": "false",
48 "labels": ["Data Line display"],
49 "type": "boolean",
50 "description": "Draw points at the edges of gaps in the data. This improves visibility of small data segments or other data irregularities."
51 },
78e58af4
RK
52 "drawPointCallback": {
53 "default": "null",
54 "labels": ["Data Line display"],
55 "type": "function(g, seriesName, canvasContext, cx, cy, color, pointSize)",
3fb9650f
RK
56 "parameters": [
57 [ "g" , "the reference graph" ],
58 [ "seriesName" , "the name of the series" ],
59 [ "canvasContext" , "the canvas to draw on" ],
60 [ "cx" , "center x coordinate" ],
61 [ "cy" , "center y coordinate" ],
62 [ "color" , "series color" ],
63 [ "pointSize" , "the radius of the image." ]
64 ],
47e07d08 65 "description": "Draw a custom item when drawPoints is enabled. Default is a small dot matching the series color. This method should constrain drawing to within pointSize pixels from (cx, cy). Also see <a href='#drawHighlightPointCallback'>drawHighlightPointCallback</a>"
74a5af31
DV
66 },
67 "height": {
68 "default": "320",
69 "labels": ["Overall display"],
70 "type": "integer",
47e07d08 71 "description": "Height, in pixels, of the chart. If the container div has been explicitly sized, this will be ignored."
74a5af31
DV
72 },
73 "zoomCallback": {
74 "default": "null",
75 "labels": ["Callbacks"],
76 "type": "function(minDate, maxDate, yRanges)",
b5bdd85b
RK
77 "parameters": [
78 [ "minDate" , "milliseconds since epoch" ],
79 [ "maxDate" , "milliseconds since epoch." ],
80 [ "yRanges" , "is an array of [bottom, top] pairs, one for each y-axis." ]
81 ],
47e07d08 82 "description": "A function to call when the zoom window is changed (either by zooming in or out)."
74a5af31
DV
83 },
84 "pointClickCallback": {
3f2f472e
RK
85 "snippet": "function(e, point){<br>&nbsp;&nbsp;alert(point);<br>}",
86 "default": "null",
74a5af31 87 "labels": ["Callbacks", "Interactive Elements"],
3f2f472e 88 "type": "function(e, point)",
b5bdd85b
RK
89 "parameters": [
90 [ "e" , "the event object for the click" ],
91 [ "point" , "the point that was clicked See <a href='#point_properties'>Point properties</a> for details" ]
92 ],
93 "description": "A function to call when a data point is clicked. and the point that was clicked."
74a5af31
DV
94 },
95 "colors": {
96 "default": "(see description)",
97 "labels": ["Data Series Colors"],
98 "type": "array<string>",
99 "example": "['red', '#00FF00']",
100 "description": "List of colors for the data series. These can be of the form \"#AABBCC\" or \"rgb(255,100,200)\" or \"yellow\", etc. If not specified, equally-spaced points around a color wheel are used."
101 },
102 "connectSeparatedPoints": {
103 "default": "false",
104 "labels": ["Data Line display"],
105 "type": "boolean",
106 "description": "Usually, when Dygraphs encounters a missing value in a data series, it interprets this as a gap and draws it as such. If, instead, the missing values represents an x-value for which only a different series has data, then you'll want to connect the dots by setting this to true. To explicitly include a gap with this option set, use a value of NaN."
107 },
108 "highlightCallback": {
109 "default": "null",
110 "labels": ["Callbacks"],
5469113b 111 "type": "function(event, x, points, row, seriesName)",
b5bdd85b
RK
112 "description": "When set, this callback gets called every time a new point is highlighted.",
113 "parameters": [
114 ["event", "the JavaScript mousemove event"],
115 ["x", "the x-coordinate of the highlighted points"],
116 ["points", "an array of highlighted points: <code>[ {name: 'series', yval: y-value}, &hellip; ]</code>"],
5469113b
KW
117 ["row", "integer index of the highlighted row in the data table, starting from 0"],
118 ["seriesName", "name of the highlighted series, only present if highlightSeriesOpts is set."]
b5bdd85b 119 ]
74a5af31 120 },
5879307d 121 "drawHighlightPointCallback": {
78e58af4
RK
122 "default": "null",
123 "labels": ["Data Line display"],
124 "type": "function(g, seriesName, canvasContext, cx, cy, color, pointSize)",
3fb9650f
RK
125 "parameters": [
126 [ "g" , "the reference graph" ],
127 [ "seriesName" , "the name of the series" ],
128 [ "canvasContext" , "the canvas to draw on" ],
129 [ "cx" , "center x coordinate" ],
130 [ "cy" , "center y coordinate" ],
131 [ "color" , "series color" ],
132 [ "pointSize" , "the radius of the image." ]
133 ],
47e07d08 134 "description": "Draw a custom item when a point is highlighted. Default is a small dot matching the series color. This method should constrain drawing to within pointSize pixels from (cx, cy) Also see <a href='#drawPointCallback'>drawPointCallback</a>"
857a6931
KW
135 },
136 "highlightSeriesOpts": {
137 "default": "null",
138 "labels": ["Interactive Elements"],
139 "type": "Object",
140 "description": "When set, the options from this object are applied to the timeseries closest to the mouse pointer for interactive highlighting. See also 'highlightCallback'. Example: highlightSeriesOpts: { strokeWidth: 3 }."
141 },
afdb20d8 142 "highlightSeriesBackgroundAlpha": {
2a02e5dd 143 "default": "0.5",
857a6931 144 "labels": ["Interactive Elements"],
2a02e5dd 145 "type": "float",
afdb20d8 146 "description": "Fade the background while highlighting series. 1=fully visible background (disable fading), 0=hiddden background (show highlighted series only)."
74a5af31
DV
147 },
148 "includeZero": {
149 "default": "false",
150 "labels": ["Axis display"],
151 "type": "boolean",
152 "description": "Usually, dygraphs will use the range of the data plus some padding to set the range of the y-axis. If this option is set, the y-axis will always include zero, typically as the lowest value. This can be used to avoid exaggerating the variance in the data"
153 },
154 "rollPeriod": {
155 "default": "1",
156 "labels": ["Error Bars", "Rolling Averages"],
157 "type": "integer &gt;= 1",
158 "description": "Number of days over which to average data. Discussed extensively above."
159 },
160 "unhighlightCallback": {
161 "default": "null",
162 "labels": ["Callbacks"],
163 "type": "function(event)",
b5bdd85b
RK
164 "parameters": [
165 [ "event" , "the mouse event" ]
166 ],
167 "description": "When set, this callback gets called every time the user stops highlighting any point by mousing out of the graph."
74a5af31
DV
168 },
169 "axisTickSize": {
170 "default": "3.0",
171 "labels": ["Axis display"],
172 "type": "number",
173 "description": "The size of the line to display next to each tick mark on x- or y-axes."
174 },
175 "labelsSeparateLines": {
176 "default": "false",
177 "labels": ["Legend"],
178 "type": "boolean",
179 "description": "Put <code>&lt;br/&gt;</code> between lines in the label string. Often used in conjunction with <strong>labelsDiv</strong>."
180 },
181 "xValueFormatter": {
48e614ac
DV
182 "default": "",
183 "labels": ["Deprecated"],
184 "type": "",
185 "description": "Prefer axes: { x: { valueFormatter } }"
186 },
187 "valueFormatter": {
188 "default": "Depends on the type of your data.",
189 "labels": ["Legend", "Value display/formatting"],
190 "type": "function(num or millis, opts, dygraph)",
191 "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'))."
74a5af31
DV
192 },
193 "pixelsPerYLabel": {
48e614ac
DV
194 "default": "",
195 "labels": ["Deprecated"],
74a5af31 196 "type": "integer",
48e614ac 197 "description": "Prefer axes: { y: { pixelsPerLabel } }"
74a5af31
DV
198 },
199 "annotationMouseOverHandler": {
200 "default": "null",
201 "labels": ["Annotations"],
202 "type": "function(annotation, point, dygraph, event)",
203 "description": "If provided, this function is called whenever the user mouses over an annotation."
204 },
205 "annotationMouseOutHandler": {
206 "default": "null",
207 "labels": ["Annotations"],
208 "type": "function(annotation, point, dygraph, event)",
b5bdd85b
RK
209 "parameters": [
210 [ "annotation" , "the annotation left" ],
211 [ "point" , "the point associated with the annotation" ],
212 [ "dygraph" , "the reference graph" ],
213 [ "event" , "the mouse event" ]
214 ],
74a5af31
DV
215 "description": "If provided, this function is called whenever the user mouses out of an annotation."
216 },
217 "annotationClickHandler": {
218 "default": "null",
219 "labels": ["Annotations"],
220 "type": "function(annotation, point, dygraph, event)",
b5bdd85b
RK
221 "parameters": [
222 [ "annotation" , "the annotation left" ],
223 [ "point" , "the point associated with the annotation" ],
224 [ "dygraph" , "the reference graph" ],
225 [ "event" , "the mouse event" ]
226 ],
74a5af31
DV
227 "description": "If provided, this function is called whenever the user clicks on an annotation."
228 },
229 "annotationDblClickHandler": {
230 "default": "null",
231 "labels": ["Annotations"],
232 "type": "function(annotation, point, dygraph, event)",
b5bdd85b
RK
233 "parameters": [
234 [ "annotation" , "the annotation left" ],
235 [ "point" , "the point associated with the annotation" ],
236 [ "dygraph" , "the reference graph" ],
237 [ "event" , "the mouse event" ]
238 ],
74a5af31
DV
239 "description": "If provided, this function is called whenever the user double-clicks on an annotation."
240 },
241 "drawCallback": {
242 "default": "null",
243 "labels": ["Callbacks"],
244 "type": "function(dygraph, is_initial)",
b5bdd85b
RK
245 "parameters": [
246 [ "dygraph" , "The graph being drawn" ],
247 [ "is_initial" , "True if this is the initial draw, false for subsequent draws." ]
248 ],
249 "description": "When set, this callback gets called every time the dygraph is drawn. This includes the initial draw, after zooming and repeatedly while panning."
74a5af31
DV
250 },
251 "labelsKMG2": {
252 "default": "false",
253 "labels": ["Value display/formatting"],
254 "type": "boolean",
255 "description": "Show k/M/G for kilo/Mega/Giga on y-axis. This is different than <code>labelsKMB</code> in that it uses base 2, not 10."
256 },
257 "delimiter": {
258 "default": ",",
259 "labels": ["CSV parsing"],
260 "type": "string",
261 "description": "The delimiter to look for when separating fields of a CSV file. Setting this to a tab is not usually necessary, since tab-delimited data is auto-detected."
262 },
263 "axisLabelFontSize": {
264 "default": "14",
265 "labels": ["Axis display"],
266 "type": "integer",
267 "description": "Size of the font (in pixels) to use in the axis labels, both x- and y-axis."
268 },
269 "underlayCallback": {
270 "default": "null",
271 "labels": ["Callbacks"],
1987a3df 272 "type": "function(context, area, dygraph)",
b5bdd85b 273 "parameters": [
1987a3df
DV
274 [ "context" , "the canvas drawing context on which to draw" ],
275 [ "area" , "An object with {x,y,w,h} properties describing the drawing area." ],
b5bdd85b
RK
276 [ "dygraph" , "the reference graph" ]
277 ],
74a5af31
DV
278 "description": "When set, this callback gets called before the chart is drawn. It details on how to use this."
279 },
280 "width": {
281 "default": "480",
282 "labels": ["Overall display"],
283 "type": "integer",
284 "description": "Width, in pixels, of the chart. If the container div has been explicitly sized, this will be ignored."
285 },
286 "interactionModel": {
287 "default": "...",
288 "labels": ["Interactive Elements"],
289 "type": "Object",
290 "description": "TODO(konigsberg): document this"
291 },
758a629f 292 "ticker": {
74a5af31
DV
293 "default": "Dygraph.dateTicker or Dygraph.numericTicks",
294 "labels": ["Axis display"],
48e614ac 295 "type": "function(min, max, pixels, opts, dygraph, vals) -> [{v: ..., label: ...}, ...]",
b5bdd85b
RK
296 "parameters": [
297 [ "min" , "" ],
298 [ "max" , "" ],
299 [ "pixels" , "" ],
300 [ "opts" , "" ],
301 [ "dygraph" , "the reference graph" ],
302 [ "vals" , "" ]
303 ],
758a629f 304 "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."
74a5af31
DV
305 },
306 "xAxisLabelWidth": {
307 "default": "50",
308 "labels": ["Axis display"],
309 "type": "integer",
310 "description": "Width, in pixels, of the x-axis labels."
311 },
312 "xAxisHeight": {
313 "default": "(null)",
314 "labels": ["Axis display"],
315 "type": "integer",
316 "description": "Height, in pixels, of the x-axis. If not set explicitly, this is computed based on axisLabelFontSize and axisTickSize."
317 },
318 "showLabelsOnHighlight": {
319 "default": "true",
320 "labels": ["Interactive Elements", "Legend"],
321 "type": "boolean",
322 "description": "Whether to show the legend upon mouseover."
323 },
324 "axis": {
325 "default": "(none)",
326 "labels": ["Axis display"],
327 "type": "string or object",
328 "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."
329 },
330 "pixelsPerXLabel": {
48e614ac
DV
331 "default": "",
332 "labels": ["Deprecated"],
333 "type": "integer",
334 "description": "Prefer axes { x: { pixelsPerLabel } }"
335 },
336 "pixelsPerLabel": {
337 "default": "60 (x-axis) or 30 (y-axes)",
74a5af31
DV
338 "labels": ["Axis display", "Grid"],
339 "type": "integer",
48e614ac 340 "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."
74a5af31
DV
341 },
342 "labelsDiv": {
343 "default": "null",
344 "labels": ["Legend"],
345 "type": "DOM element or string",
346 "example": "<code style='font-size: small'>document.getElementById('foo')</code>or<code>'foo'",
347 "description": "Show data labels in an external div, rather than on the graph. This value can either be a div element or a div id."
348 },
349 "fractions": {
350 "default": "false",
351 "labels": ["CSV parsing", "Error Bars"],
352 "type": "boolean",
353 "description": "When set, attempt to parse each cell in the CSV file as \"a/b\", where a and b are integers. The ratio will be plotted. This allows computation of Wilson confidence intervals (see below)."
354 },
355 "logscale": {
356 "default": "false",
357 "labels": ["Axis display"],
358 "type": "boolean",
359 "description": "When set for a y-axis, the graph shows that axis in log scale. Any values less than or equal to zero are not displayed.\n\nNot compatible with showZero, and ignores connectSeparatedPoints. Also, showing log scale with valueRanges that are less than zero will result in an unviewable graph."
360 },
361 "strokeWidth": {
362 "default": "1.0",
363 "labels": ["Data Line display"],
475f7420 364 "type": "float",
74a5af31
DV
365 "example": "0.5, 2.0",
366 "description": "The width of the lines connecting data points. This can be used to increase the contrast or some graphs."
367 },
79253bd0 368 "strokePattern": {
369 "default": "null",
370 "labels": ["Data Line display"],
371 "type": "array<integer>",
372 "example": "[10, 2, 5, 2]",
e2c21500 373 "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. This is used to create dashed lines."
79253bd0 374 },
857a6931
KW
375 "strokeBorderWidth": {
376 "default": "null",
377 "labels": ["Data Line display"],
475f7420
KW
378 "type": "float",
379 "example": "1.0",
857a6931
KW
380 "description": "Draw a border around graph lines to make crossing lines more easily distinguishable. Useful for graphs with many lines."
381 },
382 "strokeBorderColor": {
383 "default": "white",
384 "labels": ["Data Line display"],
385 "type": "string",
386 "example": "red, #ccffdd",
387 "description": "Color for the line border used if strokeBorderWidth is set."
388 },
74a5af31
DV
389 "wilsonInterval": {
390 "default": "true",
391 "labels": ["Error Bars"],
392 "type": "boolean",
393 "description": "Use in conjunction with the \"fractions\" option. Instead of plotting +/- N standard deviations, dygraphs will compute a Wilson confidence interval and plot that. This has more reasonable behavior for ratios close to 0 or 1."
394 },
395 "fillGraph": {
396 "default": "false",
397 "labels": ["Data Line display"],
398 "type": "boolean",
cf8c87d4 399 "description": "Should the area underneath the graph be filled? This option is not compatible with error bars. This may be set on a <a href='per-axis.html'>per-series</a> basis."
74a5af31
DV
400 },
401 "highlightCircleSize": {
402 "default": "3",
403 "labels": ["Interactive Elements"],
404 "type": "integer",
405 "description": "The size in pixels of the dot drawn over highlighted points."
406 },
407 "gridLineColor": {
408 "default": "rgb(128,128,128)",
409 "labels": ["Grid"],
410 "type": "red, blue",
411 "description": "The color of the gridlines."
412 },
413 "visibility": {
414 "default": "[true, true, ...]",
415 "labels": ["Data Line display"],
416 "type": "Array of booleans",
417 "description": "Which series should initially be visible? Once the Dygraph has been constructed, you can access and modify the visibility of each series using the <code>visibility</code> and <code>setVisibility</code> methods."
418 },
419 "valueRange": {
420 "default": "Full range of the input is shown",
421 "labels": ["Axis display"],
422 "type": "Array of two numbers",
423 "example": "[10, 110]",
1e1233b3 424 "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. If either limit is unspecified, it will be calculated automatically (e.g. [null, 30] to automatically calculate just the lower bound)"
74a5af31
DV
425 },
426 "labelsDivWidth": {
427 "default": "250",
428 "labels": ["Legend"],
429 "type": "integer",
430 "description": "Width (in pixels) of the div which shows information on the currently-highlighted points."
431 },
432 "colorSaturation": {
433 "default": "1.0",
434 "labels": ["Data Series Colors"],
435 "type": "float (0.0 - 1.0)",
436 "description": "If <strong>colors</strong> is not specified, saturation of the automatically-generated data series colors."
437 },
438 "yAxisLabelWidth": {
439 "default": "50",
440 "labels": ["Axis display"],
441 "type": "integer",
442 "description": "Width, in pixels, of the y-axis labels. This also affects the amount of space available for a y-axis chart label."
443 },
444 "hideOverlayOnMouseOut": {
445 "default": "true",
446 "labels": ["Interactive Elements", "Legend"],
447 "type": "boolean",
448 "description": "Whether to hide the legend when the mouse leaves the chart area."
449 },
450 "yValueFormatter": {
48e614ac
DV
451 "default": "",
452 "labels": ["Deprecated"],
453 "type": "",
454 "description": "Prefer axes: { y: { valueFormatter } }"
74a5af31
DV
455 },
456 "legend": {
457 "default": "onmouseover",
458 "labels": ["Legend"],
459 "type": "string",
460 "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."
461 },
462 "labelsShowZeroValues": {
463 "default": "true",
464 "labels": ["Legend"],
465 "type": "boolean",
466 "description": "Show zero value labels in the labelsDiv."
467 },
468 "stepPlot": {
469 "default": "false",
470 "labels": ["Data Line display"],
471 "type": "boolean",
104d87c5 472 "description": "When set, display the graph as a step plot instead of a line plot. This option may either be set for the whole graph or for single series."
74a5af31
DV
473 },
474 "labelsKMB": {
475 "default": "false",
476 "labels": ["Value display/formatting"],
477 "type": "boolean",
478 "description": "Show K/M/B for thousands/millions/billions on y-axis."
479 },
480 "rightGap": {
481 "default": "5",
482 "labels": ["Overall display"],
483 "type": "integer",
484 "description": "Number of pixels to leave blank at the right edge of the Dygraph. This makes it easier to highlight the right-most data point."
485 },
486 "avoidMinZero": {
487 "default": "false",
fa460473 488 "labels": ["Deprecated"],
74a5af31 489 "type": "boolean",
fa460473 490 "description": "Deprecated, please use yRangePad instead. 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."
74a5af31 491 },
f4b87da2
KW
492 "drawAxesAtZero": {
493 "default": "false",
494 "labels": ["Axis display"],
495 "type": "boolean",
496 "description": "When set, draw the X axis at the Y=0 position and the Y axis at the X=0 position if those positions are inside the graph's visible area. Otherwise, draw the axes at the bottom or left graph edge as usual."
497 },
fa460473
KW
498 "xRangePad": {
499 "default": "0",
500 "labels": ["Axis display"],
501 "type": "float",
502 "description": "Add the specified amount of extra space (in pixels) around the X-axis value range to ensure points at the edges remain visible."
503 },
504 "yRangePad": {
505 "default": "null",
506 "labels": ["Axis display"],
507 "type": "float",
508 "description": "If set, add the specified amount of extra space (in pixels) around the Y-axis value range to ensure points at the edges remain visible. If unset, use the traditional Y padding algorithm."
509 },
74a5af31 510 "xAxisLabelFormatter": {
48e614ac
DV
511 "default": "",
512 "labels": ["Deprecated"],
513 "type": "",
514 "description": "Prefer axes { x: { axisLabelFormatter } }"
515 },
516 "axisLabelFormatter": {
517 "default": "Depends on the data type",
518 "labels": ["Axis display"],
519 "type": "function(number or Date, granularity, opts, dygraph)",
b5bdd85b
RK
520 "parameters": [
521 [ "number or date" , "Either a number (for a numeric axis) or a Date object (for a date axis)" ],
522 [ "granularity" , "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." ],
523 [ "opts" , "a function which provides access to various options on the dygraph, e.g. opts('labelsKMB')." ],
524 [ "dygraph" , "the referenced graph" ]
525 ],
526 "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."
74a5af31
DV
527 },
528 "clickCallback": {
e6e12f18 529 "snippet": "function(e, date_millis){<br>&nbsp;&nbsp;alert(new Date(date_millis));<br>}",
74a5af31
DV
530 "default": "null",
531 "labels": ["Callbacks"],
e6e12f18 532 "type": "function(e, x, points)",
b5bdd85b
RK
533 "parameters": [
534 [ "e" , "The event object for the click" ],
535 [ "x" , "The x value that was clicked (for dates, this is milliseconds since epoch)" ],
536 [ "points" , "The closest points along that date. See <a href='#point_properties'>Point properties</a> for details." ]
537 ],
538 "description": "A function to call when the canvas is clicked."
74a5af31
DV
539 },
540 "yAxisLabelFormatter": {
48e614ac
DV
541 "default": "",
542 "labels": ["Deprecated"],
543 "type": "",
544 "description": "Prefer axes: { y: { axisLabelFormatter } }"
74a5af31
DV
545 },
546 "labels": {
547 "default": "[\"X\", \"Y1\", \"Y2\", ...]*",
548 "labels": ["Legend"],
549 "type": "array<string>",
550 "description": "A name for each data series, including the independent (X) series. For CSV files and DataTable objections, this is determined by context. For raw data, this must be specified. If it is not, default values are supplied and a warning is logged."
551 },
552 "dateWindow": {
553 "default": "Full range of the input is shown",
554 "labels": ["Axis display"],
555 "type": "Array of two Dates or numbers",
556 "example": "[<br>&nbsp;&nbsp;Date.parse('2006-01-01'),<br>&nbsp;&nbsp;(new Date()).valueOf()<br>]",
557 "description": "Initially zoom in on a section of the graph. Is of the form [earliest, latest], where earliest/latest are milliseconds since epoch. If the data for the x-axis is numeric, the values in dateWindow must also be numbers."
558 },
559 "showRoller": {
560 "default": "false",
561 "labels": ["Interactive Elements", "Rolling Averages"],
562 "type": "boolean",
563 "description": "If the rolling average period text box should be shown."
564 },
565 "sigma": {
566 "default": "2.0",
567 "labels": ["Error Bars"],
568 "type": "float",
569 "description": "When errorBars is set, shade this many standard deviations above/below each point."
570 },
571 "customBars": {
572 "default": "false",
573 "labels": ["CSV parsing", "Error Bars"],
574 "type": "boolean",
575 "description": "When set, parse each CSV cell as \"low;middle;high\". Error bars will be drawn for each point between low and high, with the series itself going through middle."
576 },
577 "colorValue": {
578 "default": "1.0",
579 "labels": ["Data Series Colors"],
580 "type": "float (0.0 - 1.0)",
581 "description": "If colors is not specified, value of the data series colors, as in hue/saturation/value. (0.0-1.0, default 0.5)"
582 },
583 "errorBars": {
584 "default": "false",
585 "labels": ["CSV parsing", "Error Bars"],
586 "type": "boolean",
587 "description": "Does the data contain standard deviations? Setting this to true alters the input format (see above)."
588 },
589 "displayAnnotations": {
590 "default": "false",
591 "labels": ["Annotations"],
592 "type": "boolean",
593 "description": "Only applies when Dygraphs is used as a GViz chart. Causes string columns following a data series to be interpreted as annotations on points in that series. This is the same format used by Google's AnnotatedTimeLine chart."
594 },
595 "panEdgeFraction": {
596 "default": "null",
597 "labels": ["Axis display", "Interactive Elements"],
598 "type": "float",
74a5af31
DV
599 "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."
600 },
601 "title": {
602 "labels": ["Chart labels"],
603 "type": "string",
604 "default": "null",
605 "description": "Text to display above the chart. 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-title' classes."
606 },
607 "titleHeight": {
608 "default": "18",
609 "labels": ["Chart labels"],
610 "type": "integer",
611 "description": "Height of the chart title, in pixels. This also controls the default font size of the title. If you style the title on your own, this controls how much space is set aside above the chart for the title's div."
612 },
613 "xlabel": {
614 "labels": ["Chart labels"],
615 "type": "string",
616 "default": "null",
617 "description": "Text to display below the chart's x-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-xlabel' classes."
618 },
619 "xLabelHeight": {
620 "labels": ["Chart labels"],
621 "type": "integer",
622 "default": "18",
623 "description": "Height of the x-axis label, in pixels. This also controls the default font size of the x-axis label. If you style the label on your own, this controls how much space is set aside below the chart for the x-axis label's div."
624 },
625 "ylabel": {
626 "labels": ["Chart labels"],
627 "type": "string",
628 "default": "null",
629 "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."
630 },
d0c39108
DV
631 "y2label": {
632 "labels": ["Chart labels"],
633 "type": "string",
634 "default": "null",
635 "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."
636 },
74a5af31
DV
637 "yLabelWidth": {
638 "labels": ["Chart labels"],
639 "type": "integer",
640 "default": "18",
641 "description": "Width of the div which contains the y-axis label. Since the y-axis label appears rotated 90 degrees, this actually affects the height of its div."
642 },
643 "isZoomedIgnoreProgrammaticZoom" : {
644 "default": "false",
645 "labels": ["Zooming"],
646 "type": "boolean",
647 "description" : "When this option is passed to updateOptions() along with either the <code>dateWindow</code> or <code>valueRange</code> options, the zoom flags are not changed to reflect a zoomed state. This is primarily useful for when the display area of a chart is changed programmatically and also where manual zooming is allowed and use is made of the <code>isZoomed</code> method to determine this."
648 },
649 "drawXGrid": {
650 "default": "true",
651 "labels": ["Grid"],
652 "type": "boolean",
653 "description" : "Whether to display vertical gridlines under the chart."
654 },
655 "drawYGrid": {
656 "default": "true",
657 "labels": ["Grid"],
658 "type": "boolean",
659 "description" : "Whether to display horizontal gridlines under the chart."
660 },
661 "drawXAxis": {
662 "default": "true",
663 "labels": ["Axis display"],
664 "type": "boolean",
665 "description" : "Whether to draw the x-axis. Setting this to false also prevents x-axis ticks from being drawn and reclaims the space for the chart grid/lines."
666 },
667 "drawYAxis": {
668 "default": "true",
669 "labels": ["Axis display"],
670 "type": "boolean",
671 "description" : "Whether to draw the y-axis. Setting this to false also prevents y-axis ticks from being drawn and reclaims the space for the chart grid/lines."
672 },
673 "gridLineWidth": {
674 "default": "0.3",
675 "labels": ["Grid"],
676 "type": "float",
677 "description" : "Thickness (in pixels) of the gridlines drawn under the chart. The vertical/horizontal gridlines can be turned off entirely by using the drawXGrid and drawYGrid options."
678 },
679 "axisLineWidth": {
680 "default": "0.3",
681 "labels": ["Axis display"],
682 "type": "float",
683 "description" : "Thickness (in pixels) of the x- and y-axis lines."
684 },
685 "axisLineColor": {
686 "default": "black",
687 "labels": ["Axis display"],
688 "type": "string",
689 "description" : "Color of the x- and y-axis lines. Accepts any value which the HTML canvas strokeStyle attribute understands, e.g. 'black' or 'rgb(0, 100, 255)'."
690 },
691 "fillAlpha": {
692 "default": "0.15",
693 "labels": ["Error Bars", "Data Series Colors"],
694 "type": "float (0.0 - 1.0)",
695 "description" : "Error bars (or custom bars) for each series are drawn in the same color as the series, but with partial transparency. This sets the transparency. A value of 0.0 means that the error bars will not be drawn, whereas a value of 1.0 means that the error bars will be as dark as the line for the series itself. This can be used to produce chart lines whose thickness varies at each point."
696 },
697 "axisLabelColor": {
698 "default": "black",
699 "labels": ["Axis display"],
700 "type": "string",
701 "description" : "Color for x- and y-axis labels. This is a CSS color string."
702 },
703 "axisLabelWidth": {
704 "default": "50",
705 "labels": ["Axis display", "Chart labels"],
706 "type": "integer",
707 "description" : "Width (in pixels) of the containing divs for x- and y-axis labels. For the y-axis, this also controls "
708 },
709 "sigFigs" : {
710 "default": "null",
711 "labels": ["Value display/formatting"],
712 "type": "integer",
713 "description": "By default, dygraphs displays numbers with a fixed number of digits after the decimal point. If you'd prefer to have a fixed number of significant figures, set this option to that number of sig figs. A value of 2, for instance, would cause 1 to be display as 1.0 and 1234 to be displayed as 1.23e+3."
714 },
715 "digitsAfterDecimal" : {
716 "default": "2",
717 "labels": ["Value display/formatting"],
718 "type": "integer",
719 "description": "Unless it's run in scientific mode (see the <code>sigFigs</code> option), dygraphs displays numbers with <code>digitsAfterDecimal</code> digits after the decimal point. Trailing zeros are not displayed, so with a value of 2 you'll get '0', '0.1', '0.12', '123.45' but not '123.456' (it will be rounded to '123.46'). Numbers with absolute value less than 0.1^digitsAfterDecimal (i.e. those which would show up as '0.00') will be displayed in scientific notation."
720 },
721 "maxNumberWidth" : {
722 "default": "6",
723 "labels": ["Value display/formatting"],
724 "type": "integer",
725 "description": "When displaying numbers in normal (not scientific) mode, large numbers will be displayed with many trailing zeros (e.g. 100000000 instead of 1e9). This can lead to unwieldy y-axis labels. If there are more than <code>maxNumberWidth</code> digits to the left of the decimal in a number, dygraphs will switch to scientific notation, even when not operating in scientific mode. If you'd like to see all those digits, set this to something large, like 20 or 30."
726 },
727 "file": {
728 "default": "(set when constructed)",
729 "labels": ["Data"],
730 "type": "string (URL of CSV or CSV), GViz DataTable or 2D Array",
731 "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."
7153e001
DV
732 },
733 "timingName": {
734 "default": "null",
735 "labels": [ "Debugging" ],
736 "type": "string",
737 "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."
ccd9d7c2
PF
738 },
739 "showRangeSelector": {
740 "default": "false",
741 "labels": ["Interactive Elements"],
742 "type": "boolean",
0d216a60 743 "description": "Show or hide the range selector widget."
ccd9d7c2
PF
744 },
745 "rangeSelectorHeight": {
746 "default": "40",
747 "labels": ["Interactive Elements"],
748 "type": "integer",
749 "description": "Height, in pixels, of the range selector widget. This option can only be specified at Dygraph creation time."
750 },
751 "rangeSelectorPlotStrokeColor": {
752 "default": "#808FAB",
753 "labels": ["Interactive Elements"],
754 "type": "string",
755 "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."
756 },
757 "rangeSelectorPlotFillColor": {
758 "default": "#A7B1C4",
759 "labels": ["Interactive Elements"],
760 "type": "string",
761 "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."
b1a3b195
DV
762 },
763 "animatedZooms": {
764 "default": "false",
765 "labels": ["Interactive Elements"],
766 "type": "boolean",
767 "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."
38e3d209
DV
768 },
769 "plotter": {
770 "default": "[DygraphCanvasRenderer.Plotters.fillPlotter, DygraphCanvasRenderer.Plotters.errorPlotter, DygraphCanvasRenderer.Plotters.linePlotter]",
771 "labels": ["Data Line display"],
772 "type": "array or function",
773 "description": "A function (or array of functions) which plot each data series on the chart. TODO(danvk): more details! May be set per-series."
56bccd4d 774 },
73e953cd
RK
775 "series": {
776 "default": "null",
777 "labels": ["Series"],
38f280e5 778 "type": "Object",
73e953cd 779 "description": "Defines per-series options. Its keys match the y-axis label names, and the values are dictionaries themselves that contain options specific to that series. When this option is missing, it falls back on the old-style of per-series options comingled with global options."
d9fbba56
RK
780 },
781 "plugins": {
782 "default": "[]",
783 "labels": ["Configuration"],
eced46cf 784 "type": "Array<plugin>",
d9fbba56 785 "description": "Defines per-graph plug-ins. Useful for per-graph customization"
73e953cd 786 }
74a5af31
DV
787}
788; // </JSON>
789// NOTE: in addition to parsing as JS, this snippet is expected to be valid
790// JSON. This assumption cannot be checked in JS, but it will be checked when
791// documentation is generated by the generate-documentation.py script. For the
792// most part, this just means that you should always use double quotes.
793
794// Do a quick sanity check on the options reference.
795(function() {
758a629f 796 "use strict";
0bb99c82 797 var warn = function(msg) { if (window.console) window.console.warn(msg); };
74a5af31 798 var flds = ['type', 'default', 'description'];
ccd9d7c2 799 var valid_cats = [
74a5af31
DV
800 'Annotations',
801 'Axis display',
802 'Chart labels',
803 'CSV parsing',
804 'Callbacks',
805 'Data',
806 'Data Line display',
807 'Data Series Colors',
808 'Error Bars',
809 'Grid',
810 'Interactive Elements',
811 'Legend',
812 'Overall display',
813 'Rolling Averages',
6ca57c65 814 'Series',
74a5af31 815 'Value display/formatting',
7153e001 816 'Zooming',
48e614ac 817 'Debugging',
d9fbba56 818 'Configuration',
48e614ac 819 'Deprecated'
74a5af31 820 ];
758a629f 821 var i;
74a5af31 822 var cats = {};
758a629f 823 for (i = 0; i < valid_cats.length; i++) cats[valid_cats[i]] = true;
74a5af31
DV
824
825 for (var k in Dygraph.OPTIONS_REFERENCE) {
826 if (!Dygraph.OPTIONS_REFERENCE.hasOwnProperty(k)) continue;
827 var op = Dygraph.OPTIONS_REFERENCE[k];
758a629f 828 for (i = 0; i < flds.length; i++) {
74a5af31
DV
829 if (!op.hasOwnProperty(flds[i])) {
830 warn('Option ' + k + ' missing "' + flds[i] + '" property');
831 } else if (typeof(op[flds[i]]) != 'string') {
832 warn(k + '.' + flds[i] + ' must be of type string');
833 }
834 }
758a629f 835 var labels = op.labels;
74a5af31
DV
836 if (typeof(labels) !== 'object') {
837 warn('Option "' + k + '" is missing a "labels": [...] option');
838 } else {
758a629f 839 for (i = 0; i < labels.length; i++) {
74a5af31
DV
840 if (!cats.hasOwnProperty(labels[i])) {
841 warn('Option "' + k + '" has label "' + labels[i] +
842 '", which is invalid.');
843 }
844 }
845 }
846 }
847})();