From: Neal Nelson Date: Fri, 1 Apr 2011 10:23:02 +0000 (+0200) Subject: - Merge branch 'master' of http://github.com/danvk/dygraphs X-Git-Tag: v1.0.0~536^2~1^2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=e5152598cf72fb46c396f79edebc68e9fb4fec73;p=dygraphs.git - Merge branch 'master' of github.com/danvk/dygraphs - Change noZoomFlagChange option to isZoomedIgnoreProgrammaticZoom. - Move the isZoomed demo to tests/is-zoomed.html. Conflicts: docs/index.html dygraph.js --- e5152598cf72fb46c396f79edebc68e9fb4fec73 diff --cc dygraph.js index 4bd775a,1b8d8c7..623acf7 --- a/dygraph.js +++ b/dygraph.js @@@ -198,10 -258,20 +258,24 @@@ Dygraph.prototype.__init__ = function(d this.is_initial_draw_ = true; this.annotations_ = []; + // Zoomed indicators - These indicate when the graph has been zoomed and on what axis. + this.zoomed_x_ = false; + this.zoomed_y_ = false; + + // Number of digits to use when labeling the x (if numeric) and y axis + // ticks. + this.numXDigits_ = 2; + this.numYDigits_ = 2; + + // When labeling x (if numeric) or y values in the legend, there are + // numDigits + numExtraDigits of precision used. For axes labels with N + // digits of precision, the data should be displayed with at least N+1 digits + // of precision. The reason for this is to divide each interval between + // successive ticks into tenths (for 1) or hundredths (for 2), etc. For + // example, if the labels are [0, 1, 2], we want data to be displayed as + // 0.1, 1.3, etc. + this.numExtraDigits_ = 1; + // Clear the div. This ensure that, if multiple dygraphs are passed the same // div, then only one will be drawn. div.innerHTML = ""; @@@ -264,22 -334,6 +338,22 @@@ this.start_(); }; +/** + * Returns the zoomed status of the chart for one or both axes. + * + * Axis is an optional parameter. Can be set to 'x' or 'y'. + * + * The zoomed status for an axis is set whenever a user zooms using the mouse - * or when the dateWindow or valueRange are updated (unless the noZoomFlagChange ++ * or when the dateWindow or valueRange are updated (unless the isZoomedIgnoreProgrammaticZoom + * option is also specified). + */ +Dygraph.prototype.isZoomed = function(axis) { + if (axis == null) return this.zoomed_x_ || this.zoomed_y_; + if (axis == 'x') return this.zoomed_x_; + if (axis == 'y') return this.zoomed_y_; + throw "axis parameter to Dygraph.isZoomed must be missing, 'x' or 'y'."; +}; + Dygraph.prototype.toString = function() { var maindiv = this.maindiv_; var id = (maindiv && maindiv.id) ? maindiv.id : maindiv @@@ -2361,22 -2576,15 +2601,20 @@@ Dygraph.prototype.drawGraph_ = function this.layout_.addDataset(this.attr_("labels")[i], datasets[i]); } - this.computeYAxisRanges_(extremes); - this.layout_.updateOptions( { yAxes: this.axes_, - seriesToAxisMap: this.seriesToAxisMap_ - } ); - + if (datasets.length > 0) { + // TODO(danvk): this method doesn't need to return anything. - var out = this.computeYAxisRanges_(extremes); - var axes = out[0]; - var seriesToAxisMap = out[1]; - this.layout_.updateOptions( { yAxes: axes, - seriesToAxisMap: seriesToAxisMap ++ this.computeYAxisRanges_(extremes); ++ this.layout_.updateOptions( { yAxes: this.axes_, ++ seriesToAxisMap: this.seriesToAxisMap_ + } ); + } this.addXTicks_(); + // Save the X axis zoomed status as the updateOptions call will tend to set it errorneously + var tmp_zoomed_x = this.zoomed_x_; // Tell PlotKit to use this new data and render itself this.layout_.updateOptions({dateWindow: this.dateWindow_}); + this.zoomed_x_ = tmp_zoomed_x; this.layout_.evaluateWithError(); this.plotter_.clear(); this.plotter_.render(); @@@ -3202,12 -3462,6 +3525,12 @@@ Dygraph.prototype.start_ = function() *
  • file: changes the source data for the graph
  • *
  • errorBars: changes whether the data contains stddev
  • * + * + * If the dateWindow or valueRange options are specified, the relevant zoomed_x_ - * or zoomed_y_ flags are set, unless the noZoomFlagChange option is also ++ * or zoomed_y_ flags are set, unless the isZoomedIgnoreProgrammaticZoom option is also + * secified. This allows for the chart to be programmatically zoomed without + * altering the zoomed flags. + * * @param {Object} attrs The new properties and values */ Dygraph.prototype.updateOptions = function(attrs) { @@@ -3217,12 -3471,6 +3540,12 @@@ } if ('dateWindow' in attrs) { this.dateWindow_ = attrs.dateWindow; - if (!('noZoomFlagChange' in attrs)) { ++ if (!('isZoomedIgnoreProgrammaticZoom' in attrs)) { + this.zoomed_x_ = attrs.dateWindow != null; + } + } - if ('valueRange' in attrs && !('noZoomFlagChange' in attrs)) { ++ if ('valueRange' in attrs && !('isZoomedIgnoreProgrammaticZoom' in attrs)) { + this.zoomed_y_ = attrs.valueRange != null; } // TODO(danvk): validate per-series options. @@@ -3468,3 -3716,467 +3791,473 @@@ Dygraph.GVizChart.prototype.getSelectio // Older pages may still use this name. DateGraph = Dygraph; + + // + Dygraph.OPTIONS_REFERENCE = // + { + "xValueParser": { + "default": "parseFloat() or Date.parse()*", + "labels": ["CSV parsing"], + "type": "function(str) -> number", + "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." + }, + "stackedGraph": { + "default": "false", + "labels": ["Data Line display"], + "type": "boolean", + "description": "If set, stack series on top of one another rather than drawing them independently." + }, + "pointSize": { + "default": "1", + "labels": ["Data Line display"], + "type": "integer", + "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." + }, + "labelsDivStyles": { + "default": "null", + "labels": ["Legend"], + "type": "{}", + "description": "Additional styles to apply to the currently-highlighted points div. For example, { 'font-weight': 'bold' } will make the labels bold." + }, + "drawPoints": { + "default": "false", + "labels": ["Data Line display"], + "type": "boolean", + "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." + }, + "height": { + "default": "320", + "labels": ["Overall display"], + "type": "integer", + "description": "Height, in pixels, of the chart. If the container div has been explicitly sized, this will be ignored." + }, + "zoomCallback": { + "default": "null", + "labels": ["Callbacks"], + "type": "function(minDate, maxDate, yRanges)", + "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": "", + "labels": ["Callbacks", "Interactive Elements"], + "type": "", + "description": "" + }, + "colors": { + "default": "(see description)", + "labels": ["Data Series Colors"], + "type": "array", + "example": "['red', '#00FF00']", + "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." + }, + "connectSeparatedPoints": { + "default": "false", + "labels": ["Data Line display"], + "type": "boolean", + "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." + }, + "highlightCallback": { + "default": "null", + "labels": ["Callbacks"], + "type": "function(event, x, points,row)", + "description": "When set, this callback gets called every time a new point is highlighted. The parameters are the JavaScript mousemove event, the x-coordinate of the highlighted points and an array of highlighted points: [ {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", + "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." + }, + "dateWindow": { + "default": "Full range of the input is shown", + "labels": ["Axis display"], + "type": "Array of two Dates or numbers", + "example": "[
      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." + } + } + ; //
    + // 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. + + // Do a quick sanity check on the options reference. + (function() { + var warn = function(msg) { if (console) console.warn(msg); }; + var flds = ['type', 'default', 'description']; + var valid_cats = [ + 'Annotations', + 'Axis display', + 'CSV parsing', + 'Callbacks', + 'Data Line display', + 'Data Series Colors', + 'Error Bars', + 'Grid', + 'Interactive Elements', + 'Legend', + 'Overall display', + 'Rolling Averages', + 'Value display/formatting' + ]; + var cats = {}; + for (var 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++) { + 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'); + for (var i = 0; i < labels.length; i++) { + if (!cats.hasOwnProperty(labels[i])) { + warn('Option "' + k + '" has label "' + labels[i] + + '", which is invalid.'); + } + } + } + } + })(); + //
    diff --cc tests/is-zoomed-ignore-programmatic-zoom.html index 0000000,0000000..7b2629e new file mode 100644 --- /dev/null +++ b/tests/is-zoomed-ignore-programmatic-zoom.html @@@ -1,0 -1,0 +1,167 @@@ ++ ++ ++ isZoomedIgnoreProgrammaticZoom Flag ++ ++ ++ ++ ++ ++ ++ ++ ++ ++

    isZoomedIgnoreProgrammaticZoom Option

    ++

    ++ By default, when the 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. ++

    ++

    ++ Sometimes it may be desirable to change the display of the chart by ++ manipulating the 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. ++

    ++

    ++ In this case isZoomedIgnoreProgrammaticZoom may be specified along with ++ either the dateWindow or valueRange values to ++ updateOptions and the zoomed flags will remain unaffected. ++

    ++

    ++ The chart below may be manipulated to change the updateOptions ++ using the Max and Min Y axis buttons and the dateWindow ++ by using the Max and Min X axis buttons. ++

    ++

    ++ 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 (isZoomedIgnoreProgrammaticZoom)

    ++ ++
    ++
    ++

    ++ Max Y Axis: ++ ++ ++

    ++

    ++ Min Y Axis: ++ ++ ++

    ++

    ++ Min X Axis: ++ ++ ++

    ++

    ++ Max X Axis: ++ ++ ++

    ++
    ++
    ++
    ++ ++
    ++
    ++
    ++

    Zoomed Flags

    ++

    Zoomed: False

    ++

    Zoomed X: False

    ++

    Zoomed Y: False

    ++

    Window coordinates (in dates and values):

    ++
    ++
    ++
    ++ ++ ++ ++ diff --cc tests/is-zoomed.html index 0000000,0000000..50c23f1 new file mode 100644 --- /dev/null +++ b/tests/is-zoomed.html @@@ -1,0 -1,0 +1,103 @@@ ++ ++ ++ isZoomedIgnoresProgrammaticZoom Flag ++ ++ ++ ++ ++ ++ ++ ++ ++

    Determining Zoom

    ++

    ++ It is possible to detect whether a chart has been zoomed in either axis by the use of the 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. ++

    ++ ++

    Here's a simple example using drawCallback to display the various zoom states whenever the chart is zoomed:

    ++ ++
    OUTPUT
    ++
    ++
    ++

    Zoomed: False

    ++

    Zoomed X: False

    ++

    Zoomed Y: False

    ++

    ++
    ++
    ++ ++
    ++
    ++ ++

    ++

    HTML
    ++ ++
    ++  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.

    ++ ++

    Programmatic Zoom

    ++

    ++ 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. ++

    ++ ++