From: Neal Nelson
++ By default, when the
++ Sometimes it may be desirable to change the display of the chart by
++ manipulating the
++ In this case
++ The chart below may be manipulated to change the
++ Toggle the check box below to determine the difference in operation of the zoom flags
++ when the date and value windows of the chart are changed using the arrows underneath.
++ Do not change zoom flags (
++ Max Y Axis:
++
++
++
++ Min Y Axis:
++
++
++
++ Min X Axis:
++
++
++
++ Max X Axis:
++
++
++ Zoomed: False Zoomed X: False Zoomed Y: False
++ It is possible to detect whether a chart has been zoomed in either axis by the use of the Here's a simple example using Zoomed: False Zoomed X: False Zoomed Y: False
++ [ {name: 'series', yval: y-value}, … ]
"
+ },
+ "includeZero": {
+ "default": "false",
+ "labels": ["Axis display"],
+ "type": "boolean",
+ "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"
+ },
+ "rollPeriod": {
+ "default": "1",
+ "labels": ["Error Bars", "Rolling Averages"],
+ "type": "integer >= 1",
+ "description": "Number of days over which to average data. Discussed extensively above."
+ },
+ "unhighlightCallback": {
+ "default": "null",
+ "labels": ["Callbacks"],
+ "type": "function(event)",
+ "description": "When set, this callback gets called every time the user stops highlighting any point by mousing out of the graph. The parameter is the mouseout event."
+ },
+ "axisTickSize": {
+ "default": "3.0",
+ "labels": ["Axis display"],
+ "type": "number",
+ "description": "The size of the line to display next to each tick mark on x- or y-axes."
+ },
+ "labelsSeparateLines": {
+ "default": "false",
+ "labels": ["Legend"],
+ "type": "boolean",
+ "description": "Put <br/>
between lines in the label string. Often used in conjunction with labelsDiv."
+ },
+ "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."
+ },
+ "pixelsPerYLabel": {
+ "default": "30",
+ "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."
+ },
+ "annotationMouseOverHandler": {
+ "default": "null",
+ "labels": ["Annotations"],
+ "type": "function(annotation, point, dygraph, event)",
+ "description": "If provided, this function is called whenever the user mouses over an annotation."
+ },
+ "annotationMouseOutHandler": {
+ "default": "null",
+ "labels": ["Annotations"],
+ "type": "function(annotation, point, dygraph, event)",
+ "description": "If provided, this function is called whenever the user mouses out of an annotation."
+ },
+ "annotationClickHandler": {
+ "default": "null",
+ "labels": ["Annotations"],
+ "type": "function(annotation, point, dygraph, event)",
+ "description": "If provided, this function is called whenever the user clicks on an annotation."
+ },
+ "annotationDblClickHandler": {
+ "default": "null",
+ "labels": ["Annotations"],
+ "type": "function(annotation, point, dygraph, event)",
+ "description": "If provided, this function is called whenever the user double-clicks on an annotation."
+ },
+ "drawCallback": {
+ "default": "null",
+ "labels": ["Callbacks"],
+ "type": "function(dygraph, is_initial)",
+ "description": "When set, this callback gets called every time the dygraph is drawn. This includes the initial draw, after zooming and repeatedly while panning. The first parameter is the dygraph being drawn. The second is a boolean value indicating whether this is the initial draw."
+ },
+ "labelsKMG2": {
+ "default": "false",
+ "labels": ["Value display/formatting"],
+ "type": "boolean",
+ "description": "Show k/M/G for kilo/Mega/Giga on y-axis. This is different than labelsKMB
in that it uses base 2, not 10."
+ },
+ "delimiter": {
+ "default": ",",
+ "labels": ["CSV parsing"],
+ "type": "string",
+ "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."
+ },
+ "axisLabelFontSize": {
+ "default": "14",
+ "labels": ["Axis display"],
+ "type": "integer",
+ "description": "Size of the font (in pixels) to use in the axis labels, both x- and y-axis."
+ },
+ "underlayCallback": {
+ "default": "null",
+ "labels": ["Callbacks"],
+ "type": "function(canvas, area, dygraph)",
+ "description": "When set, this callback gets called before the chart is drawn. It details on how to use this."
+ },
+ "width": {
+ "default": "480",
+ "labels": ["Overall display"],
+ "type": "integer",
+ "description": "Width, in pixels, of the chart. If the container div has been explicitly sized, this will be ignored."
+ },
+ "interactionModel": {
+ "default": "...",
+ "labels": ["Interactive Elements"],
+ "type": "Object",
+ "description": "TODO(konigsberg): document this"
+ },
+ "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."
+ },
+ "xAxisLabelWidth": {
+ "default": "50",
+ "labels": ["Axis display"],
+ "type": "integer",
+ "description": "Width, in pixels, of the x-axis labels."
+ },
+ "showLabelsOnHighlight": {
+ "default": "true",
+ "labels": ["Interactive Elements", "Legend"],
+ "type": "boolean",
+ "description": "Whether to show the legend upon mouseover."
+ },
+ "axis": {
+ "default": "(none)",
+ "labels": ["Axis display"],
+ "type": "string or object",
+ "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",
+ "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."
+ },
+ "labelsDiv": {
+ "default": "null",
+ "labels": ["Legend"],
+ "type": "DOM element or string",
+ "example": "document.getElementById('foo')
or'foo'",
+ "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."
+ },
+ "fractions": {
+ "default": "false",
+ "labels": ["CSV parsing", "Error Bars"],
+ "type": "boolean",
+ "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)."
+ },
+ "logscale": {
+ "default": "false",
+ "labels": ["Axis display"],
+ "type": "boolean",
+ "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."
+ },
+ "strokeWidth": {
+ "default": "1.0",
+ "labels": ["Data Line display"],
+ "type": "integer",
+ "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."
+ },
+ "wilsonInterval": {
+ "default": "true",
+ "labels": ["Error Bars"],
+ "type": "boolean",
+ "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."
+ },
+ "fillGraph": {
+ "default": "false",
+ "labels": ["Data Line display"],
+ "type": "boolean",
+ "description": "Should the area underneath the graph be filled? This option is not compatible with error bars."
+ },
+ "highlightCircleSize": {
+ "default": "3",
+ "labels": ["Interactive Elements"],
+ "type": "integer",
+ "description": "The size in pixels of the dot drawn over highlighted points."
+ },
+ "gridLineColor": {
+ "default": "rgb(128,128,128)",
+ "labels": ["Grid"],
+ "type": "red, blue",
+ "description": "The color of the gridlines."
+ },
+ "visibility": {
+ "default": "[true, true, ...]",
+ "labels": ["Data Line display"],
+ "type": "Array of booleans",
+ "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
visibility
and setVisibility
methods."
+ },
+ "valueRange": {
+ "default": "Full range of the input is shown",
+ "labels": ["Axis display"],
+ "type": "Array of two numbers",
+ "example": "[10, 110]",
+ "description": "Explicitly set the vertical range of the graph to [low, high]."
+ },
+ "labelsDivWidth": {
+ "default": "250",
+ "labels": ["Legend"],
+ "type": "integer",
+ "description": "Width (in pixels) of the div which shows information on the currently-highlighted points."
+ },
+ "colorSaturation": {
+ "default": "1.0",
+ "labels": ["Data Series Colors"],
+ "type": "0.0 - 1.0",
+ "description": "If colors is not specified, saturation of the automatically-generated data series colors."
+ },
+ "yAxisLabelWidth": {
+ "default": "50",
+ "labels": ["Axis display"],
+ "type": "integer",
+ "description": "Width, in pixels, of the y-axis labels."
+ },
+ "hideOverlayOnMouseOut": {
+ "default": "true",
+ "labels": ["Interactive Elements", "Legend"],
+ "type": "boolean",
+ "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."
+ },
+ "legend": {
+ "default": "onmouseover",
+ "labels": ["Legend"],
+ "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."
+ },
+ "labelsShowZeroValues": {
+ "default": "true",
+ "labels": ["Legend"],
+ "type": "boolean",
+ "description": "Show zero value labels in the labelsDiv."
+ },
+ "stepPlot": {
+ "default": "false",
+ "labels": ["Data Line display"],
+ "type": "boolean",
+ "description": "When set, display the graph as a step plot instead of a line plot."
+ },
+ "labelsKMB": {
+ "default": "false",
+ "labels": ["Value display/formatting"],
+ "type": "boolean",
+ "description": "Show K/M/B for thousands/millions/billions on y-axis."
+ },
+ "rightGap": {
+ "default": "5",
+ "labels": ["Overall display"],
+ "type": "integer",
+ "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."
+ },
+ "avoidMinZero": {
+ "default": "false",
+ "labels": ["Axis display"],
+ "type": "boolean",
+ "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."
+ },
+ "clickCallback": {
+ "snippet": "function(e, date){
alert(date);
}",
+ "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."
+ },
+ "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 yValueFormatter
unless specified."
+ },
+ "labels": {
+ "default": "[\"X\", \"Y1\", \"Y2\", ...]*",
+ "labels": ["Legend"],
+ "type": "array
Date.parse('2006-01-01'),
(new Date()).valueOf()
]",
+ "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."
+ },
+ "showRoller": {
+ "default": "false",
+ "labels": ["Interactive Elements", "Rolling Averages"],
+ "type": "boolean",
+ "description": "If the rolling average period text box should be shown."
+ },
+ "sigma": {
+ "default": "2.0",
+ "labels": ["Error Bars"],
+ "type": "integer",
+ "description": "When errorBars is set, shade this many standard deviations above/below each point."
+ },
+ "customBars": {
+ "default": "false",
+ "labels": ["CSV parsing", "Error Bars"],
+ "type": "boolean",
+ "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."
+ },
+ "colorValue": {
+ "default": "1.0",
+ "labels": ["Data Series Colors"],
+ "type": "float (0.0 - 1.0)",
+ "description": "If colors is not specified, value of the data series colors, as in hue/saturation/value. (0.0-1.0, default 0.5)"
+ },
+ "errorBars": {
+ "default": "false",
+ "labels": ["CSV parsing", "Error Bars"],
+ "type": "boolean",
+ "description": "Does the data contain standard deviations? Setting this to true alters the input format (see above)."
+ },
+ "displayAnnotations": {
+ "default": "false",
+ "labels": ["Annotations"],
+ "type": "boolean",
+ "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."
+ },
+ "panEdgeFraction": {
+ "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."
++ },
++ "isZoomedIgnoreProgrammaticZoom" : {
++ "default": "false",
++ "labels": ["Zooming"],
++ "type": "boolean",
++ "description" : "When this flag is passed along with either the dateWindow
or valueRange
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 isZoomed
method to determine this."
+ }
+ }
+ ; // isZoomedIgnoreProgrammaticZoom Option
++ dateWindow
or updateOptions
++ of a chart is changed programmatically by a call to updateOptions
++ the zoomed flags (isZoomed
) are changed. This is the same
++ as manually zooming in using the mouse.
++ dateWindow
and valueRange
++ options but without changing the zoomed flags, for example where manual
++ zooming is still required but where it is also desired that the zoomed
++ flags drive display elements, but only for manual zooming.
++ isZoomedIgnoreProgrammaticZoom
may be specified along with
++ either the dateWindow
or valueRange
values to
++ updateOptions
and the zoomed flags will remain unaffected.
++ updateOptions
++ using the Max and Min Y axis buttons and the dateWindow
++ by using the Max and Min X axis buttons.
++ isZoomedIgnoreProgrammaticZoom
) Zoomed Flags
++ Window coordinates (in dates and values):
++
++
++ Determining Zoom
++ isZoomed
function.
++ If called with no argument, it will report whether either axis has been zoomed.
++ Alternatively it can be called with an argument of either 'x'
or 'y'
and it will report the status of just that axis.
++ drawCallback
to display the various zoom states whenever the chart is zoomed:
++ new Dygraph(
++
++ // containing div
++ document.getElementById("zoomdiv"),
++
++ // CSV or path to a CSV file.
++ "Date,Temperature\n" +
++ "2011-01-07,75\n" +
++ "2011-01-08,70\n" +
++ "2011-01-09,90\n" +
++ "2011-01-10,30\n" +
++ "2011-01-11,40\n" +
++ "2011-01-12,60\n" +
++ "2011-01-13,70\n" +
++ "2011-01-14,40\n",
++ {
++ drawCallback: function(me, initial) {
++ document.getElementById("zoomed").innerHTML = "" + me.isZoomed();
++ document.getElementById("zoomedX").innerHTML = "" + me.isZoomed("x");
++ document.getElementById("zoomedY").innerHTML = "" + me.isZoomed("y");
++ }
++ }
++ );
++
++
The Tests for zoom operations show a full example of this in action.
++ ++
++ When a chart is programmatically zoomed by updating either the dateWindow
++ or valueRange
option, by default the zoomed flags are also updated correspondingly.
++ It is possible to prevent this by specifying the isZoomedIgnoreProgrammaticZoom
in the same
++ call to the updateOptions
method.
++
++ The is-zoomed-ignore-programmatic-zoom test shows this in operation. ++
++ ++