Fullstack Portal Created by the HCMR for the Marine Strategy Framework Directive Program in order to cover demands and aspects considering extendability and maintainability
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
672 KiB

2 years ago
{
"version": 3,
"sources": [
"node_modules/browser-pack/_prelude.js",
"node_modules/process/browser.js",
"src/datahandler/bars-custom.js",
"src/datahandler/bars-error.js",
"src/datahandler/bars-fractions.js",
"src/datahandler/bars.js",
"src/datahandler/datahandler.js",
"src/datahandler/default-fractions.js",
"src/datahandler/default.js",
"src/dygraph-canvas.js",
"src/dygraph-default-attrs.js",
"src/dygraph-gviz.js",
"src/dygraph-interaction-model.js",
"src/dygraph-layout.js",
"src/dygraph-options-reference.js",
"src/dygraph-options.js",
"src/dygraph-tickers.js",
"src/dygraph-utils.js",
"src/dygraph.js",
"src/iframe-tarp.js",
"src/plugins/annotations.js",
"src/plugins/axes.js",
"src/plugins/chart-labels.js",
"src/plugins/grid.js",
"src/plugins/legend.js",
"src/plugins/range-selector.js"
],
"names": [],
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;ACxHA,YAAY,CAAC;;;;;;;;oBAEW,QAAQ;;;;;;;;AAMhC,IAAI,iBAAiB,GAAG,SAApB,iBAAiB,GAAc,EAClC,CAAC;;AAEF,iBAAiB,CAAC,SAAS,GAAG,uBAAiB,CAAC;;;AAGhD,iBAAiB,CAAC,SAAS,CAAC,aAAa,GAAG,UAAS,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE;;AAExE,MAAI,MAAM,GAAG,EAAE,CAAC;AAChB,MAAI,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC;AAChB,MAAI,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AACvC,OAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACxC,KAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClB,SAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtB,QAAI,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE;;;AAG9B,UAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE;AACnD,aAAK,GAAG,IAAI,CAAC;OACd;KACF;;AAED,QAAI,KAAK,KAAK,IAAI,EAAE;AAClB,OAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AACb,UAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;AAC3B,cAAM,CAAC,IAAI,CAAC,CAAE,CAAC,EAAE,CAAC,EAAE,CAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAE,CAAE,CAAC,CAAC;OAC/C,MAAM;AACL,cAAM,CAAC,IAAI,CAAC,CAAE,CAAC,EAAE,CAAC,EAAE,CAAE,CAAC,EAAE,CAAC,CAAE,CAAE,CAAC,CAAC;OACjC;KACF,MAAM;AACL,YAAM,CAAC,IAAI,CAAC,CAAE,CAAC,EAAE,IAAI,EAAE,CAAE,IAAI,EAAE,IAAI,CAAE,CAAE,CAAC,CAAC;KAC1C;GACF;AACD,SAAO,MAAM,CAAC;CACf,CAAC;;;AAGF,iBAAiB,CAAC,SAAS,CAAC,cAAc,GACtC,UAAS,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE;AAC9C,YAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;AACvD,MAAI,WAAW,GAAG,EAAE,CAAC;AACrB,MAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,CAAC;;AAEzC,KAAG,GAAG,CAAC,CAAC;AACR,KAAG,GAAG,CAAC,CAAC;AACR,MAAI,GAAG,CAAC,CAAC;AACT,OAAK,GAAG,CAAC,CAAC;AACV,OAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACxC,KAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvB,YAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9B,eAAW,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;;AAEjC,QAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;AAC3B,SAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC;AACnB,SAAG,IAAI,CAAC,CAAC;AACT,UAAI,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC;AACpB,WAAK,IAAI,CAAC,CAAC;KACZ;AACD,QAAI,CAAC,GAAG,UAAU,IAAI,CAAC,EAAE;AACvB,UAAI,IAAI,GAAG,YAAY,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC;AACxC,UAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;AACvC,WAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClB,WAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;AACf,YAAI,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnB,aAAK,IAAI,CAAC,CAAC;OACZ;KACF;AACD,QAAI,KAAK,EAAE;AACT,iBAAW,CAAC,CAAC,CAAC,GAAG,CACb,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAClB,GAAG,GAAG,GAAG,GAAG,KAAK,EACjB,CAAE,GAAG,GAAG,GAAG,GAAG,KAAK,EACjB,GAAG,GAAG,IAAI,GAAG,KAAK,CAAE,CAAE,CAAC;KAC9B,MAAM;AACL,iBAAW,CAAC,CAAC,CAAC,GAAG,CAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAE,IAAI,EAAE,IAAI,CAAE,CAAE,CAAC;KAC/D;GACF;;AAED,SAAO,WAAW,CAAC;CACpB,CAAC;;qBAEa,iBAAiB;;;;;;;;;;;;;;;;ACzFhC,YAAY,CAAC;;;;;;;;oBAEW,QAAQ;;;;;;;;AAMhC,IAAI,gBAAgB,GAAG,SAAnB,gBAAgB,GAAc,EACjC,CAAC;;AAEF,gBAAgB,CAAC,SAAS,GAAG,uBAAiB,CAAC;;;AAG/C,gBAAgB,CAAC,SAAS,CAAC,aAAa,GAAG,UAAS,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE;;AAEvE,MAAI,MAAM,GAAG,EAAE,CAAC;AAChB,MAAI,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC;AAC1B,MAAI,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACjC,MAAI,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AACvC,OAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACxC,KAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClB,SAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAA
"file": "generated.js",
"sourceRoot": "",
"sourcesContent": [
"(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})",
"// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\n(function () {\n try {\n cachedSetTimeout = setTimeout;\n } catch (e) {\n cachedSetTimeout = function () {\n throw new Error('setTimeout is not defined');\n }\n }\n try {\n cachedClearTimeout = clearTimeout;\n } catch (e) {\n cachedClearTimeout = function () {\n throw new Error('clearTimeout is not defined');\n }\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n return setTimeout(fun, 0);\n } else {\n return cachedSetTimeout.call(null, fun, 0);\n }\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n clearTimeout(marker);\n } else {\n cachedClearTimeout.call(null, marker);\n }\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n",
"/**\n * @license\n * Copyright 2013 David Eberlein (david.eberlein@ch.sauter-bc.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/**\n * @fileoverview DataHandler implementation for the custom bars option.\n * @author David Eberlein (david.eberlein@ch.sauter-bc.com)\n */\n\n/*global Dygraph:false */\n\"use strict\";\n\nimport BarsHandler from './bars';\n\n/**\n * @constructor\n * @extends Dygraph.DataHandlers.BarsHandler\n */\nvar CustomBarsHandler = function() {\n};\n\nCustomBarsHandler.prototype = new BarsHandler();\n\n/** @inheritDoc */\nCustomBarsHandler.prototype.extractSeries = function(rawData, i, options) {\n // TODO(danvk): pre-allocate series here.\n var series = [];\n var x, y, point;\n var logScale = options.get('logscale');\n for ( var j = 0; j < rawData.length; j++) {\n x = rawData[j][0];\n point = rawData[j][i];\n if (logScale && point !== null) {\n // On the log scale, points less than zero do not exist.\n // This will create a gap in the chart.\n if (point[0] <= 0 || point[1] <= 0 || point[2] <= 0) {\n point = null;\n }\n }\n // Extract to the unified data format.\n if (point !== null) {\n y = point[1];\n if (y !== null && !isNaN(y)) {\n series.push([ x, y, [ point[0], point[2] ] ]);\n } else {\n series.push([ x, y, [ y, y ] ]);\n }\n } else {\n series.push([ x, null, [ null, null ] ]);\n }\n }\n return series;\n};\n\n/** @inheritDoc */\nCustomBarsHandler.prototype.rollingAverage =\n function(originalData, rollPeriod, options) {\n rollPeriod = Math.min(rollPeriod, originalData.length);\n var rollingData = [];\n var y, low, high, mid,count, i, extremes;\n\n low = 0;\n mid = 0;\n high = 0;\n count = 0;\n for (i = 0; i < originalData.length; i++) {\n y = originalData[i][1];\n extremes = originalData[i][2];\n rollingData[i] = originalData[i];\n\n if (y !== null && !isNaN(y)) {\n low += extremes[0];\n mid += y;\n high += extremes[1];\n count += 1;\n }\n if (i - rollPeriod >= 0) {\n var prev = originalData[i - rollPeriod];\n if (prev[1] !== null && !isNaN(prev[1])) {\n low -= prev[2][0];\n mid -= prev[1];\n high -= prev[2][1];\n count -= 1;\n }\n }\n if (count) {\n rollingData[i] = [\n originalData[i][0],\n 1.0 * mid / count, \n [ 1.0 * low / count,\n 1.0 * high / count ] ];\n } else {\n rollingData[i] = [ originalData[i][0], null, [ null, null ] ];\n }\n }\n\n return rollingData;\n};\n\nexport default CustomBarsHandler;\n",
"/**\n * @license\n * Copyright 2013 David Eberlein (david.eberlein@ch.sauter-bc.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/**\n * @fileoverview DataHandler implementation for the error bars option.\n * @author David Eberlein (david.eberlein@ch.sauter-bc.com)\n */\n\n/*global Dygraph:false */\n\"use strict\";\n\nimport BarsHandler from './bars';\n\n/**\n * @constructor\n * @extends BarsHandler\n */\nvar ErrorBarsHandler = function() {\n};\n\nErrorBarsHandler.prototype = new BarsHandler();\n\n/** @inheritDoc */\nErrorBarsHandler.prototype.extractSeries = function(rawData, i, options) {\n // TODO(danvk): pre-allocate series here.\n var series = [];\n var x, y, variance, point;\n var sigma = options.get(\"sigma\");\n var logScale = options.get('logscale');\n for ( var j = 0; j < rawData.length; j++) {\n x = rawData[j][0];\n point = rawData[j][i];\n if (logScale && point !== null) {\n // On the log scale, points less than zero do not exist.\n // This will create a gap in the chart.\n if (point[0] <= 0 || point[0] - sigma * point[1] <= 0) {\n point = null;\n }\n }\n // Extract to the unified data format.\n if (point !== null) {\n y = point[0];\n if (y !== null && !isNaN(y)) {\n variance = sigma * point[1];\n // preserve original error value in extras for further\n // filtering\n series.push([ x, y, [ y - variance, y + variance, point[1] ] ]);\n } else {\n series.push([ x, y, [ y, y, y ] ]);\n }\n } else {\n series.push([ x, null, [ null, null, null ] ]);\n }\n }\n return series;\n};\n\n/** @inheritDoc */\nErrorBarsHandler.prototype.rollingAverage =\n function(originalData, rollPeriod, options) {\n rollPeriod = Math.min(rollPeriod, originalData.length);\n var rollingData = [];\n var sigma = options.get(\"sigma\");\n\n var i, j, y, v, sum, num_ok, stddev, variance, value;\n\n // Calculate the rolling average for the first rollPeriod - 1 points\n // where there is not enough data to roll over the full number of points\n for (i = 0; i < originalData.length; i++) {\n sum = 0;\n variance = 0;\n num_ok = 0;\n for (j = Math.max(0, i - rollPeriod + 1); j < i + 1; j++) {\n y = originalData[j][1];\n if (y === null || isNaN(y))\n continue;\n num_ok++;\n sum += y;\n variance += Math.pow(originalData[j][2][2], 2);\n }\n if (num_ok) {\n stddev = Math.sqrt(variance) / num_ok;\n value = sum / num_ok;\n rollingData[i] = [ originalData[i][0], value,\n [value - sigma * stddev, value + sigma * stddev] ];\n } else {\n // This explicitly preserves NaNs to aid with \"independent\n // series\".\n // See testRollingAveragePreservesNaNs.\n v = (rollPeriod == 1) ? originalData[i][1] : null;\n rollingData[i] = [ originalData[i][0], v, [ v, v ] ];\n }\n }\n\n return rollingData;\n};\n\nexport default ErrorBarsHandler;\n",
"/**\n * @license\n * Copyright 2013 David Eberlein (david.eberlein@ch.sauter-bc.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/**\n * @fileoverview DataHandler implementation for the combination \n * of error bars and fractions options.\n * @author David Eberlein (david.eberlein@ch.sauter-bc.com)\n */\n\n/*global Dygraph:false */\n\"use strict\";\n\nimport BarsHandler from './bars';\n\n/**\n * @constructor\n * @extends Dygraph.DataHandlers.BarsHandler\n */\nvar FractionsBarsHandler = function() {\n};\n\nFractionsBarsHandler.prototype = new BarsHandler();\n\n/** @inheritDoc */\nFractionsBarsHandler.prototype.extractSeries = function(rawData, i, options) {\n // TODO(danvk): pre-allocate series here.\n var series = [];\n var x, y, point, num, den, value, stddev, variance;\n var mult = 100.0;\n var sigma = options.get(\"sigma\");\n var logScale = options.get('logscale');\n for ( var j = 0; j < rawData.length; j++) {\n x = rawData[j][0];\n point = rawData[j][i];\n if (logScale && point !== null) {\n // On the log scale, points less than zero do not exist.\n // This will create a gap in the chart.\n if (point[0] <= 0 || point[1] <= 0) {\n point = null;\n }\n }\n // Extract to the unified data format.\n if (point !== null) {\n num = point[0];\n den = point[1];\n if (num !== null && !isNaN(num)) {\n value = den ? num / den : 0.0;\n stddev = den ? sigma * Math.sqrt(value * (1 - value) / den) : 1.0;\n variance = mult * stddev;\n y = mult * value;\n // preserve original values in extras for further filtering\n series.push([ x, y, [ y - variance, y + variance, num, den ] ]);\n } else {\n series.push([ x, num, [ num, num, num, den ] ]);\n }\n } else {\n series.push([ x, null, [ null, null, null, null ] ]);\n }\n }\n return series;\n};\n\n/** @inheritDoc */\nFractionsBarsHandler.prototype.rollingAverage =\n function(originalData, rollPeriod, options) {\n rollPeriod = Math.min(rollPeriod, originalData.length);\n var rollingData = [];\n var sigma = options.get(\"sigma\");\n var wilsonInterval = options.get(\"wilsonInterval\");\n\n var low, high, i, stddev;\n var num = 0;\n var den = 0; // numerator/denominator\n var mult = 100.0;\n for (i = 0; i < originalData.length; i++) {\n num += originalData[i][2][2];\n den += originalData[i][2][3];\n if (i - rollPeriod >= 0) {\n num -= originalData[i - rollPeriod][2][2];\n den -= originalData[i - rollPeriod][2][3];\n }\n\n var date = originalData[i][0];\n var value = den ? num / den : 0.0;\n if (wilsonInterval) {\n // For more details on this confidence interval, see:\n // http://en.wikipedia.org/wiki/Binomial_confidence_interval\n if (den) {\n var p = value < 0 ? 0 : value, n = den;\n var pm = sigma * Math.sqrt(p * (1 - p) / n + sigma * sigma / (4 * n * n));\n var denom = 1 + sigma * sigma / den;\n low = (p + sigma * sigma / (2 * den) - pm) / denom;\n high = (p + sigma * sigma / (2 * den) + pm) / denom;\n rollingData[i] = [ date, p * mult,\n [ low * mult, high * mult ] ];\n } else {\n rollingData[i] = [ date, 0, [ 0, 0 ] ];\n }\n } else {\n stddev = den ? sigma * Math.sqrt(value * (1 - value) / den) : 1.0;\n rollingData[i] = [ date, mult * value, \n [ mult * (value - stddev), mult * (value + stddev) ] ];\n }\n }\n\n return rollingData;\n};\n\nexport default FractionsBarsHandler;\n",
"/**\n * @license\n * Copyright 2013 David Eberlein (david.eberlein@ch.sauter-bc.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/**\n * @fileoverview DataHandler base implementation for the \"bar\" \n * data formats. This implementation must be extended and the\n * extractSeries and rollingAverage must be implemented.\n * @author David Eberlein (david.eberlein@ch.sauter-bc.com)\n */\n\n/*global Dygraph:false */\n/*global DygraphLayout:false */\n\"use strict\";\n\nimport DygraphDataHandler from './datahandler';\nimport DygraphLayout from '../dygraph-layout';\n\n/**\n * @constructor\n * @extends {Dygraph.DataHandler}\n */\nvar BarsHandler = function() {\n DygraphDataHandler.call(this);\n};\nBarsHandler.prototype = new DygraphDataHandler();\n\n// TODO(danvk): figure out why the jsdoc has to be copy/pasted from superclass.\n// (I get closure compiler errors if this isn't here.)\n/**\n * @override\n * @param {!Array.<Array>} rawData The raw data passed into dygraphs where \n * rawData[i] = [x,ySeries1,...,ySeriesN].\n * @param {!number} seriesIndex Index of the series to extract. All other\n * series should be ignored.\n * @param {!DygraphOptions} options Dygraph options.\n * @return {Array.<[!number,?number,?]>} The series in the unified data format\n * where series[i] = [x,y,{extras}]. \n */\nBarsHandler.prototype.extractSeries = function(rawData, seriesIndex, options) {\n // Not implemented here must be extended\n};\n\n/**\n * @override\n * @param {!Array.<[!number,?number,?]>} series The series in the unified \n * data format where series[i] = [x,y,{extras}].\n * @param {!number} rollPeriod The number of points over which to average the data\n * @param {!DygraphOptions} options The dygraph options.\n * TODO(danvk): be more specific than \"Array\" here.\n * @return {!Array.<[!number,?number,?]>} the rolled series.\n */\nBarsHandler.prototype.rollingAverage =\n function(series, rollPeriod, options) {\n // Not implemented here, must be extended.\n};\n\n/** @inheritDoc */\nBarsHandler.prototype.onPointsCreated_ = function(series, points) {\n for (var i = 0; i < series.length; ++i) {\n var item = series[i];\n var point = points[i];\n point.y_top = NaN;\n point.y_bottom = NaN;\n point.yval_minus = DygraphDataHandler.parseFloat(item[2][0]);\n point.yval_plus = DygraphDataHandler.parseFloat(item[2][1]);\n }\n};\n\n/** @inheritDoc */\nBarsHandler.prototype.getExtremeYValues = function(series, dateWindow, options) {\n var minY = null, maxY = null, y;\n\n var firstIdx = 0;\n var lastIdx = series.length - 1;\n\n for ( var j = firstIdx; j <= lastIdx; j++) {\n y = series[j][1];\n if (y === null || isNaN(y)) continue;\n\n var low = series[j][2][0];\n var high = series[j][2][1];\n\n if (low > y) low = y; // this can happen with custom bars,\n if (high < y) high = y; // e.g. in tests/custom-bars.html\n\n if (maxY === null || high > maxY) maxY = high;\n if (minY === null || low < minY) minY = low;\n }\n\n return [ minY, maxY ];\n};\n\n/** @inheritDoc */\nBarsHandler.prototype.onLineEvaluated = function(points, axis, logscale) {\n var point;\n for (var j = 0; j < points.length; j++) {\n // Copy over the error terms\n point = points[j];\n point.y_top = DygraphLayout.calcYNormal_(axis, point.yval_minus, logscale);\n point.y_bottom = DygraphLayout.calcYNormal_(axis, point.yval_plus, logscale);\n }\n};\n\nexport default BarsHandler;\n",
"/**\n * @license\n * Copyright 2013 David Eberlein (david.eberlein@ch.sauter-bc.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/**\n * @fileoverview This file contains the managment of data handlers\n * @author David Eberlein (david.eberlein@ch.sauter-bc.com)\n *\n * The idea is to define a common, generic data format that works for all data\n * structures supported by dygraphs. To make this possible, the DataHandler\n * interface is introduced. This makes it possible, that dygraph itself can work\n * with the same logic for every data type independent of the actual format and\n * the DataHandler takes care of the data format specific jobs.\n * DataHandlers are implemented for all data types supported by Dygraphs and\n * return Dygraphs compliant formats.\n * By default the correct DataHandler is chosen based on the options set.\n * Optionally the user may use his own DataHandler (similar to the plugin\n * system).\n *\n *\n * The unified data format returend by each handler is defined as so:\n * series[n][point] = [x,y,(extras)]\n *\n * This format contains the common basis that is needed to draw a simple line\n * series extended by optional extras for more complex graphing types. It\n * contains a primitive x value as first array entry, a primitive y value as\n * second array entry and an optional extras object for additional data needed.\n *\n * x must always be a number.\n * y must always be a number, NaN of type number or null.\n * extras is optional and must be interpreted by the DataHandler. It may be of\n * any type.\n *\n * In practice this might look something like this:\n * default: [x, yVal]\n * errorBar / customBar: [x, yVal, [yTopVariance, yBottomVariance] ]\n *\n */\n/*global Dygraph:false */\n/*global DygraphLayout:false */\n\n\"use strict\";\n\n/**\n *\n * The data handler is responsible for all data specific operations. All of the\n * series data it receives and returns is always in the unified data format.\n * Initially the unified data is created by the extractSeries method\n * @constructor\n */\nvar DygraphDataHandler = function () {\n};\n\nvar handler = DygraphDataHandler;\n\n/**\n * X-value array index constant for unified data samples.\n * @const\n * @type {number}\n */\nhandler.X = 0;\n\n/**\n * Y-value array index constant for unified data samples.\n * @const\n * @type {number}\n */\nhandler.Y = 1;\n\n/**\n * Extras-value array index constant for unified data samples.\n * @const\n * @type {number}\n */\nhandler.EXTRAS = 2;\n\n/**\n * Extracts one series from the raw data (a 2D array) into an array of the\n * unified data format.\n * This is where undesirable points (i.e. negative values on log scales and\n * missing values through which we wish to connect lines) are dropped.\n * TODO(danvk): the \"missing values\" bit above doesn't seem right.\n *\n * @param {!Array.<Array>} rawData The raw data passed into dygraphs where\n * rawData[i] = [x,ySeries1,...,ySeriesN].\n * @param {!number} seriesIndex Index of the series to extract. All other\n * series should be ignored.\n * @param {!DygraphOptions} options Dygraph options.\n * @return {Array.<[!number,?number,?]>} The series in the unified data format\n * where series[i] = [x,y,{extras}].\n */\nhandler.prototype.extractSeries = function(rawData, seriesIndex, options) {\n};\n\n/**\n * Converts a series to a Point array. The resulting point array must be\n * returned in increasing order of idx property.\n *\n * @param {!Array.<[!number,?number,?]>} series The series in the unified\n * data format where series[i] = [x,y,{extras}].\n * @param {!string} setName Name of the series.\n * @param {!number} boundaryIdStart Index offset of the first point, equal to the\n * number of skipped points left of the date window minimum (if any).\n * @return {!Array.<Dygraph.PointType>} List of points for this series.\n */\nhandler.prototype.seriesToPoints = function(series, setName, boundaryIdStart) {\n // TODO(bhs): these loops are a hot-spot for high-point-count charts. In\n // fact,\n // on chrome+linux,
"/**\n * @license\n * Copyright 2013 David Eberlein (david.eberlein@ch.sauter-bc.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/**\n * @fileoverview DataHandler implementation for the fractions option.\n * @author David Eberlein (david.eberlein@ch.sauter-bc.com)\n */\n\n/*global Dygraph:false */\n\"use strict\";\n\nimport DygraphDataHandler from './datahandler';\nimport DefaultHandler from './default';\n\n/**\n * @extends DefaultHandler\n * @constructor\n */\nvar DefaultFractionHandler = function() {\n};\n \nDefaultFractionHandler.prototype = new DefaultHandler();\n\nDefaultFractionHandler.prototype.extractSeries = function(rawData, i, options) {\n // TODO(danvk): pre-allocate series here.\n var series = [];\n var x, y, point, num, den, value;\n var mult = 100.0;\n var logScale = options.get('logscale');\n for ( var j = 0; j < rawData.length; j++) {\n x = rawData[j][0];\n point = rawData[j][i];\n if (logScale && point !== null) {\n // On the log scale, points less than zero do not exist.\n // This will create a gap in the chart.\n if (point[0] <= 0 || point[1] <= 0) {\n point = null;\n }\n }\n // Extract to the unified data format.\n if (point !== null) {\n num = point[0];\n den = point[1];\n if (num !== null && !isNaN(num)) {\n value = den ? num / den : 0.0;\n y = mult * value;\n // preserve original values in extras for further filtering\n series.push([ x, y, [ num, den ] ]);\n } else {\n series.push([ x, num, [ num, den ] ]);\n }\n } else {\n series.push([ x, null, [ null, null ] ]);\n }\n }\n return series;\n};\n\nDefaultFractionHandler.prototype.rollingAverage = function(originalData, rollPeriod,\n options) {\n rollPeriod = Math.min(rollPeriod, originalData.length);\n var rollingData = [];\n\n var i;\n var num = 0;\n var den = 0; // numerator/denominator\n var mult = 100.0;\n for (i = 0; i < originalData.length; i++) {\n num += originalData[i][2][0];\n den += originalData[i][2][1];\n if (i - rollPeriod >= 0) {\n num -= originalData[i - rollPeriod][2][0];\n den -= originalData[i - rollPeriod][2][1];\n }\n\n var date = originalData[i][0];\n var value = den ? num / den : 0.0;\n rollingData[i] = [ date, mult * value ];\n }\n\n return rollingData;\n};\n\nexport default DefaultFractionHandler;\n",
"/**\n * @license\n * Copyright 2013 David Eberlein (david.eberlein@ch.sauter-bc.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/**\n * @fileoverview DataHandler default implementation used for simple line charts.\n * @author David Eberlein (david.eberlein@ch.sauter-bc.com)\n */\n\n/*global Dygraph:false */\n\"use strict\";\n\nimport DygraphDataHandler from './datahandler';\n\n/**\n * @constructor\n * @extends Dygraph.DataHandler\n */\nvar DefaultHandler = function() {\n};\n\nDefaultHandler.prototype = new DygraphDataHandler();\n\n/** @inheritDoc */\nDefaultHandler.prototype.extractSeries = function(rawData, i, options) {\n // TODO(danvk): pre-allocate series here.\n var series = [];\n var logScale = options.get('logscale');\n for ( var j = 0; j < rawData.length; j++) {\n var x = rawData[j][0];\n var point = rawData[j][i];\n if (logScale) {\n // On the log scale, points less than zero do not exist.\n // This will create a gap in the chart.\n if (point <= 0) {\n point = null;\n }\n }\n series.push([ x, point ]);\n }\n return series;\n};\n\n/** @inheritDoc */\nDefaultHandler.prototype.rollingAverage = function(originalData, rollPeriod,\n options) {\n rollPeriod = Math.min(rollPeriod, originalData.length);\n var rollingData = [];\n\n var i, j, y, sum, num_ok;\n // Calculate the rolling average for the first rollPeriod - 1 points\n // where\n // there is not enough data to roll over the full number of points\n if (rollPeriod == 1) {\n return originalData;\n }\n for (i = 0; i < originalData.length; i++) {\n sum = 0;\n num_ok = 0;\n for (j = Math.max(0, i - rollPeriod + 1); j < i + 1; j++) {\n y = originalData[j][1];\n if (y === null || isNaN(y))\n continue;\n num_ok++;\n sum += originalData[j][1];\n }\n if (num_ok) {\n rollingData[i] = [ originalData[i][0], sum / num_ok ];\n } else {\n rollingData[i] = [ originalData[i][0], null ];\n }\n }\n\n return rollingData;\n};\n\n/** @inheritDoc */\nDefaultHandler.prototype.getExtremeYValues = function(series, dateWindow,\n options) {\n var minY = null, maxY = null, y;\n var firstIdx = 0, lastIdx = series.length - 1;\n\n for ( var j = firstIdx; j <= lastIdx; j++) {\n y = series[j][1];\n if (y === null || isNaN(y))\n continue;\n if (maxY === null || y > maxY) {\n maxY = y;\n }\n if (minY === null || y < minY) {\n minY = y;\n }\n }\n return [ minY, maxY ];\n};\n\nexport default DefaultHandler;\n",
"/**\n * @license\n * Copyright 2006 Dan Vanderkam (danvdk@gmail.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/**\n * @fileoverview Based on PlotKit.CanvasRenderer, but modified to meet the\n * needs of dygraphs.\n *\n * In particular, support for:\n * - grid overlays\n * - error bars\n * - dygraphs attribute system\n */\n\n/**\n * The DygraphCanvasRenderer class does the actual rendering of the chart onto\n * a canvas. It's based on PlotKit.CanvasRenderer.\n * @param {Object} element The canvas to attach to\n * @param {Object} elementContext The 2d context of the canvas (injected so it\n * can be mocked for testing.)\n * @param {Layout} layout The DygraphLayout object for this graph.\n * @constructor\n */\n\n/*global Dygraph:false */\n\"use strict\";\n\nimport * as utils from './dygraph-utils';\nimport Dygraph from './dygraph';\n\n\n/**\n * @constructor\n *\n * This gets called when there are \"new points\" to chart. This is generally the\n * case when the underlying data being charted has changed. It is _not_ called\n * in the common case that the user has zoomed or is panning the view.\n *\n * The chart canvas has already been created by the Dygraph object. The\n * renderer simply gets a drawing context.\n *\n * @param {Dygraph} dygraph The chart to which this renderer belongs.\n * @param {HTMLCanvasElement} element The &lt;canvas&gt; DOM element on which to draw.\n * @param {CanvasRenderingContext2D} elementContext The drawing context.\n * @param {DygraphLayout} layout The chart's DygraphLayout object.\n *\n * TODO(danvk): remove the elementContext property.\n */\nvar DygraphCanvasRenderer = function(dygraph, element, elementContext, layout) {\n this.dygraph_ = dygraph;\n\n this.layout = layout;\n this.element = element;\n this.elementContext = elementContext;\n\n this.height = dygraph.height_;\n this.width = dygraph.width_;\n\n // --- check whether everything is ok before we return\n if (!utils.isCanvasSupported(this.element)) {\n throw \"Canvas is not supported.\";\n }\n\n // internal state\n this.area = layout.getPlotArea();\n\n // Set up a clipping area for the canvas (and the interaction canvas).\n // This ensures that we don't overdraw.\n var ctx = this.dygraph_.canvas_ctx_;\n ctx.beginPath();\n ctx.rect(this.area.x, this.area.y, this.area.w, this.area.h);\n ctx.clip();\n\n ctx = this.dygraph_.hidden_ctx_;\n ctx.beginPath();\n ctx.rect(this.area.x, this.area.y, this.area.w, this.area.h);\n ctx.clip();\n};\n\n/**\n * Clears out all chart content and DOM elements.\n * This is called immediately before render() on every frame, including\n * during zooms and pans.\n * @private\n */\nDygraphCanvasRenderer.prototype.clear = function() {\n this.elementContext.clearRect(0, 0, this.width, this.height);\n};\n\n/**\n * This method is responsible for drawing everything on the chart, including\n * lines, error bars, fills and axes.\n * It is called immediately after clear() on every frame, including during pans\n * and zooms.\n * @private\n */\nDygraphCanvasRenderer.prototype.render = function() {\n // attaches point.canvas{x,y}\n this._updatePoints();\n\n // actually draws the chart.\n this._renderLineChart();\n};\n\n/**\n * Returns a predicate to be used with an iterator, which will\n * iterate over points appropriately, depending on whether\n * connectSeparatedPoints is true. When it's false, the predicate will\n * skip over points with missing yVals.\n */\nDygraphCanvasRenderer._getIteratorPredicate = function(connectSeparatedPoints) {\n return connectSeparatedPoints ?\n DygraphCanvasRenderer._predicateThatSkipsEmptyPoints :\n null;\n};\n\nDygraphCanvasRenderer._predicateThatSkipsEmptyPoints =\n function(array, idx) {\n return array[idx].yval !== null;\n};\n\n/**\n * Draws a line with the styles passed in and calls all the drawPointCallbacks.\n * @param {Object} e The dictionary passed to the plotter function.\n * @private\n */\nDygraphCanvasRenderer._drawStyledLine = function(e,\n color, strokeWidth, strokePattern, drawPoints,\n drawPointCallb
"'use strict'\n\nimport * as DygraphTickers from './dygraph-tickers';\nimport DygraphInteraction from './dygraph-interaction-model';\nimport DygraphCanvasRenderer from './dygraph-canvas';\nimport * as utils from './dygraph-utils';\n\n// Default attribute values.\nvar DEFAULT_ATTRS = {\n highlightCircleSize: 3,\n highlightSeriesOpts: null,\n highlightSeriesBackgroundAlpha: 0.5,\n highlightSeriesBackgroundColor: 'rgb(255, 255, 255)',\n\n labelsSeparateLines: false,\n labelsShowZeroValues: true,\n labelsKMB: false,\n labelsKMG2: false,\n showLabelsOnHighlight: true,\n\n digitsAfterDecimal: 2,\n maxNumberWidth: 6,\n sigFigs: null,\n\n strokeWidth: 1.0,\n strokeBorderWidth: 0,\n strokeBorderColor: \"white\",\n\n axisTickSize: 3,\n axisLabelFontSize: 14,\n rightGap: 5,\n\n showRoller: false,\n xValueParser: undefined,\n\n delimiter: ',',\n\n sigma: 2.0,\n errorBars: false,\n fractions: false,\n wilsonInterval: true, // only relevant if fractions is true\n customBars: false,\n fillGraph: false,\n fillAlpha: 0.15,\n connectSeparatedPoints: false,\n\n stackedGraph: false,\n stackedGraphNaNFill: 'all',\n hideOverlayOnMouseOut: true,\n\n legend: 'onmouseover',\n stepPlot: false,\n xRangePad: 0,\n yRangePad: null,\n drawAxesAtZero: false,\n\n // Sizes of the various chart labels.\n titleHeight: 28,\n xLabelHeight: 18,\n yLabelWidth: 18,\n\n axisLineColor: \"black\",\n axisLineWidth: 0.3,\n gridLineWidth: 0.3,\n axisLabelWidth: 50,\n gridLineColor: \"rgb(128,128,128)\",\n\n interactionModel: DygraphInteraction.defaultModel,\n animatedZooms: false, // (for now)\n\n // Range selector options\n showRangeSelector: false,\n rangeSelectorHeight: 40,\n rangeSelectorPlotStrokeColor: \"#808FAB\",\n rangeSelectorPlotFillGradientColor: \"white\",\n rangeSelectorPlotFillColor: \"#A7B1C4\",\n rangeSelectorBackgroundStrokeColor: \"gray\",\n rangeSelectorBackgroundLineWidth: 1,\n rangeSelectorPlotLineWidth:1.5,\n rangeSelectorForegroundStrokeColor: \"black\",\n rangeSelectorForegroundLineWidth: 1,\n rangeSelectorAlpha: 0.6,\n showInRangeSelector: null,\n\n // The ordering here ensures that central lines always appear above any\n // fill bars/error bars.\n plotter: [\n DygraphCanvasRenderer._fillPlotter,\n DygraphCanvasRenderer._errorPlotter,\n DygraphCanvasRenderer._linePlotter\n ],\n\n plugins: [ ],\n\n // per-axis options\n axes: {\n x: {\n pixelsPerLabel: 70,\n axisLabelWidth: 60,\n axisLabelFormatter: utils.dateAxisLabelFormatter,\n valueFormatter: utils.dateValueFormatter,\n drawGrid: true,\n drawAxis: true,\n independentTicks: true,\n ticker: DygraphTickers.dateTicker\n },\n y: {\n axisLabelWidth: 50,\n pixelsPerLabel: 30,\n valueFormatter: utils.numberValueFormatter,\n axisLabelFormatter: utils.numberAxisLabelFormatter,\n drawGrid: true,\n drawAxis: true,\n independentTicks: true,\n ticker: DygraphTickers.numericTicks\n },\n y2: {\n axisLabelWidth: 50,\n pixelsPerLabel: 30,\n valueFormatter: utils.numberValueFormatter,\n axisLabelFormatter: utils.numberAxisLabelFormatter,\n drawAxis: true, // only applies when there are two axes of data.\n drawGrid: false,\n independentTicks: false,\n ticker: DygraphTickers.numericTicks\n }\n }\n};\n\nexport default DEFAULT_ATTRS;\n",
"/**\n * @license\n * Copyright 2011 Dan Vanderkam (danvdk@gmail.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/**\n * @fileoverview A wrapper around the Dygraph class which implements the\n * interface for a GViz (aka Google Visualization API) visualization.\n * It is designed to be a drop-in replacement for Google's AnnotatedTimeline,\n * so the documentation at\n * http://code.google.com/apis/chart/interactive/docs/gallery/annotatedtimeline.html\n * translates over directly.\n *\n * For a full demo, see:\n * - http://dygraphs.com/tests/gviz.html\n * - http://dygraphs.com/tests/annotation-gviz.html\n */\n\n/*global Dygraph:false */\n\"use strict\";\n\nimport Dygraph from './dygraph';\n\n/**\n * A wrapper around Dygraph that implements the gviz API.\n * @param {!HTMLDivElement} container The DOM object the visualization should\n * live in.\n * @constructor\n */\nvar GVizChart = function(container) {\n this.container = container;\n};\n\n/**\n * @param {GVizDataTable} data\n * @param {Object.<*>} options\n */\nGVizChart.prototype.draw = function(data, options) {\n // Clear out any existing dygraph.\n // TODO(danvk): would it make more sense to simply redraw using the current\n // date_graph object?\n this.container.innerHTML = '';\n if (typeof(this.date_graph) != 'undefined') {\n this.date_graph.destroy();\n }\n\n this.date_graph = new Dygraph(this.container, data, options);\n};\n\n/**\n * Google charts compatible setSelection\n * Only row selection is supported, all points in the row will be highlighted\n * @param {Array.<{row:number}>} selection_array array of the selected cells\n * @public\n */\nGVizChart.prototype.setSelection = function(selection_array) {\n var row = false;\n if (selection_array.length) {\n row = selection_array[0].row;\n }\n this.date_graph.setSelection(row);\n};\n\n/**\n * Google charts compatible getSelection implementation\n * @return {Array.<{row:number,column:number}>} array of the selected cells\n * @public\n */\nGVizChart.prototype.getSelection = function() {\n var selection = [];\n\n var row = this.date_graph.getSelection();\n\n if (row < 0) return selection;\n\n var points = this.date_graph.layout_.points;\n for (var setIdx = 0; setIdx < points.length; ++setIdx) {\n selection.push({row: row, column: setIdx + 1});\n }\n\n return selection;\n};\n\nexport default GVizChart;\n",
"/**\n * @license\n * Copyright 2011 Robert Konigsberg (konigsberg@google.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/**\n * @fileoverview The default interaction model for Dygraphs. This is kept out\n * of dygraph.js for better navigability.\n * @author Robert Konigsberg (konigsberg@google.com)\n */\n\n/*global Dygraph:false */\n\"use strict\";\n\nimport * as utils from './dygraph-utils';\n\n/**\n * You can drag this many pixels past the edge of the chart and still have it\n * be considered a zoom. This makes it easier to zoom to the exact edge of the\n * chart, a fairly common operation.\n */\nvar DRAG_EDGE_MARGIN = 100;\n\n/**\n * A collection of functions to facilitate build custom interaction models.\n * @class\n */\nvar DygraphInteraction = {};\n\n/**\n * Checks whether the beginning & ending of an event were close enough that it\n * should be considered a click. If it should, dispatch appropriate events.\n * Returns true if the event was treated as a click.\n *\n * @param {Event} event\n * @param {Dygraph} g\n * @param {Object} context\n */\nDygraphInteraction.maybeTreatMouseOpAsClick = function(event, g, context) {\n context.dragEndX = utils.dragGetX_(event, context);\n context.dragEndY = utils.dragGetY_(event, context);\n var regionWidth = Math.abs(context.dragEndX - context.dragStartX);\n var regionHeight = Math.abs(context.dragEndY - context.dragStartY);\n\n if (regionWidth < 2 && regionHeight < 2 &&\n g.lastx_ !== undefined && g.lastx_ != -1) {\n DygraphInteraction.treatMouseOpAsClick(g, event, context);\n }\n\n context.regionWidth = regionWidth;\n context.regionHeight = regionHeight;\n};\n\n/**\n * Called in response to an interaction model operation that\n * should start the default panning behavior.\n *\n * It's used in the default callback for \"mousedown\" operations.\n * Custom interaction model builders can use it to provide the default\n * panning behavior.\n *\n * @param {Event} event the event object which led to the startPan call.\n * @param {Dygraph} g The dygraph on which to act.\n * @param {Object} context The dragging context object (with\n * dragStartX/dragStartY/etc. properties). This function modifies the\n * context.\n */\nDygraphInteraction.startPan = function(event, g, context) {\n var i, axis;\n context.isPanning = true;\n var xRange = g.xAxisRange();\n\n if (g.getOptionForAxis(\"logscale\", \"x\")) {\n context.initialLeftmostDate = utils.log10(xRange[0]);\n context.dateRange = utils.log10(xRange[1]) - utils.log10(xRange[0]);\n } else {\n context.initialLeftmostDate = xRange[0];\n context.dateRange = xRange[1] - xRange[0];\n }\n context.xUnitsPerPixel = context.dateRange / (g.plotter_.area.w - 1);\n\n if (g.getNumericOption(\"panEdgeFraction\")) {\n var maxXPixelsToDraw = g.width_ * g.getNumericOption(\"panEdgeFraction\");\n var xExtremes = g.xAxisExtremes(); // I REALLY WANT TO CALL THIS xTremes!\n\n var boundedLeftX = g.toDomXCoord(xExtremes[0]) - maxXPixelsToDraw;\n var boundedRightX = g.toDomXCoord(xExtremes[1]) + maxXPixelsToDraw;\n\n var boundedLeftDate = g.toDataXCoord(boundedLeftX);\n var boundedRightDate = g.toDataXCoord(boundedRightX);\n context.boundedDates = [boundedLeftDate, boundedRightDate];\n\n var boundedValues = [];\n var maxYPixelsToDraw = g.height_ * g.getNumericOption(\"panEdgeFraction\");\n\n for (i = 0; i < g.axes_.length; i++) {\n axis = g.axes_[i];\n var yExtremes = axis.extremeRange;\n\n var boundedTopY = g.toDomYCoord(yExtremes[0], i) + maxYPixelsToDraw;\n var boundedBottomY = g.toDomYCoord(yExtremes[1], i) - maxYPixelsToDraw;\n\n var boundedTopValue = g.toDataYCoord(boundedTopY, i);\n var boundedBottomValue = g.toDataYCoord(boundedBottomY, i);\n\n boundedValues[i] = [boundedTopValue, boundedBottomValue];\n }\n context.boundedValues = boundedValues;\n }\n\n // Record the range of each y-axis at the start of the drag.\n // If any axis has a valueRange, then we want a 2D pan.\n // We can't store data directly in g.axe
"/**\n * @license\n * Copyright 2011 Dan Vanderkam (danvdk@gmail.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/**\n * @fileoverview Based on PlotKitLayout, but modified to meet the needs of\n * dygraphs.\n */\n\n/*global Dygraph:false */\n\"use strict\";\n\nimport * as utils from './dygraph-utils';\n\n/**\n * Creates a new DygraphLayout object.\n *\n * This class contains all the data to be charted.\n * It uses data coordinates, but also records the chart range (in data\n * coordinates) and hence is able to calculate percentage positions ('In this\n * view, Point A lies 25% down the x-axis.')\n *\n * Two things that it does not do are:\n * 1. Record pixel coordinates for anything.\n * 2. (oddly) determine anything about the layout of chart elements.\n *\n * The naming is a vestige of Dygraph's original PlotKit roots.\n *\n * @constructor\n */\nvar DygraphLayout = function(dygraph) {\n this.dygraph_ = dygraph;\n /**\n * Array of points for each series.\n *\n * [series index][row index in series] = |Point| structure,\n * where series index refers to visible series only, and the\n * point index is for the reduced set of points for the current\n * zoom region (including one point just outside the window).\n * All points in the same row index share the same X value.\n *\n * @type {Array.<Array.<Dygraph.PointType>>}\n */\n this.points = [];\n this.setNames = [];\n this.annotations = [];\n this.yAxes_ = null;\n\n // TODO(danvk): it's odd that xTicks_ and yTicks_ are inputs, but xticks and\n // yticks are outputs. Clean this up.\n this.xTicks_ = null;\n this.yTicks_ = null;\n};\n\n/**\n * Add points for a single series.\n *\n * @param {string} setname Name of the series.\n * @param {Array.<Dygraph.PointType>} set_xy Points for the series.\n */\nDygraphLayout.prototype.addDataset = function(setname, set_xy) {\n this.points.push(set_xy);\n this.setNames.push(setname);\n};\n\n/**\n * Returns the box which the chart should be drawn in. This is the canvas's\n * box, less space needed for the axis and chart labels.\n *\n * @return {{x: number, y: number, w: number, h: number}}\n */\nDygraphLayout.prototype.getPlotArea = function() {\n return this.area_;\n};\n\n// Compute the box which the chart should be drawn in. This is the canvas's\n// box, less space needed for axis, chart labels, and other plug-ins.\n// NOTE: This should only be called by Dygraph.predraw_().\nDygraphLayout.prototype.computePlotArea = function() {\n var area = {\n // TODO(danvk): per-axis setting.\n x: 0,\n y: 0\n };\n\n area.w = this.dygraph_.width_ - area.x - this.dygraph_.getOption('rightGap');\n area.h = this.dygraph_.height_;\n\n // Let plugins reserve space.\n var e = {\n chart_div: this.dygraph_.graphDiv,\n reserveSpaceLeft: function(px) {\n var r = {\n x: area.x,\n y: area.y,\n w: px,\n h: area.h\n };\n area.x += px;\n area.w -= px;\n return r;\n },\n reserveSpaceRight: function(px) {\n var r = {\n x: area.x + area.w - px,\n y: area.y,\n w: px,\n h: area.h\n };\n area.w -= px;\n return r;\n },\n reserveSpaceTop: function(px) {\n var r = {\n x: area.x,\n y: area.y,\n w: area.w,\n h: px\n };\n area.y += px;\n area.h -= px;\n return r;\n },\n reserveSpaceBottom: function(px) {\n var r = {\n x: area.x,\n y: area.y + area.h - px,\n w: area.w,\n h: px\n };\n area.h -= px;\n return r;\n },\n chartRect: function() {\n return {x:area.x, y:area.y, w:area.w, h:area.h};\n }\n };\n this.dygraph_.cascadeEvents_('layout', e);\n\n this.area_ = area;\n};\n\nDygraphLayout.prototype.setAnnotations = function(ann) {\n // The Dygraph object's annotations aren't parsed. We parse them here and\n // save a copy. If there is no parser, then the user must be using raw format.\n this.annotations = [];\n var parse = this.dygraph_.getOption('xValueParser') || function(
"/**\n * @license\n * Copyright 2011 Dan Vanderkam (danvdk@gmail.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n\"use strict\";\n\nvar OPTIONS_REFERENCE = null;\n\n// For \"production\" code, this gets removed by uglifyjs.\nif (typeof(process) !== 'undefined') {\nif (process.env.NODE_ENV != 'production') {\n\n// NOTE: in addition to parsing as JS, this snippet is expected to be valid\n// JSON. This assumption cannot be checked in JS, but it will be checked when\n// documentation is generated by the generate-documentation.py script. For the\n// most part, this just means that you should always use double quotes.\nOPTIONS_REFERENCE = // <JSON>\n{\n \"xValueParser\": {\n \"default\": \"parseFloat() or Date.parse()*\",\n \"labels\": [\"CSV parsing\"],\n \"type\": \"function(str) -> number\",\n \"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.\"\n },\n \"stackedGraph\": {\n \"default\": \"false\",\n \"labels\": [\"Data Line display\"],\n \"type\": \"boolean\",\n \"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. NaN values are drawn as white areas without a line on top, see stackedGraphNaNFill for details.\"\n },\n \"stackedGraphNaNFill\": {\n \"default\": \"all\",\n \"labels\": [\"Data Line display\"],\n \"type\": \"string\",\n \"description\": \"Controls handling of NaN values inside a stacked graph. NaN values are interpolated/extended for stacking purposes, but the actual point value remains NaN in the legend display. Valid option values are \\\"all\\\" (interpolate internally, repeat leftmost and rightmost value as needed), \\\"inside\\\" (interpolate internally only, use zero outside leftmost and rightmost value), and \\\"none\\\" (treat NaN as zero everywhere).\"\n },\n \"pointSize\": {\n \"default\": \"1\",\n \"labels\": [\"Data Line display\"],\n \"type\": \"integer\",\n \"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.\"\n },\n \"drawPoints\": {\n \"default\": \"false\",\n \"labels\": [\"Data Line display\"],\n \"type\": \"boolean\",\n \"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>.\"\n },\n \"drawGapEdgePoints\": {\n \"default\": \"false\",\n \"labels\": [\"Data Line display\"],\n \"type\": \"boolean\",\n \"description\": \"Draw points at the edges of gaps in the data. This improves visibility of small data segments or other data irregularities.\"\n },\n \"drawPointCallback\": {\n \"default\": \"null\",\n \"labels\": [\"Data Line display\"],\n \"type\": \"function(g, seriesName, canvasContext, cx, cy, color, pointSize)\",\n \"parameters\": [\n [ \"g\" , \"the reference graph\" ],\n [ \"seriesName\" , \"the name of the series\" ],\n [ \"canvasContext\" , \"the canvas to draw on\" ],\n [ \"cx\" , \"center x coordinate\" ],\n [ \"cy\" , \"center y coordinate\" ],\n [ \"color\" , \"series color\" ],\n [ \"pointSize\" , \"the radius of the image.\" ],\n [ \"idx\" , \"the row-index of the point in the data.\"]\n ],\n \"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 pointSi
"/**\n * @license\n * Copyright 2011 Dan Vanderkam (danvdk@gmail.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/**\n * @fileoverview DygraphOptions is responsible for parsing and returning\n * information about options.\n */\n\n// TODO: remove this jshint directive & fix the warnings.\n/*jshint sub:true */\n\"use strict\";\n\nimport * as utils from './dygraph-utils';\nimport DEFAULT_ATTRS from './dygraph-default-attrs';\nimport OPTIONS_REFERENCE from './dygraph-options-reference';\n\n/*\n * Interesting member variables: (REMOVING THIS LIST AS I CLOSURIZE)\n * global_ - global attributes (common among all graphs, AIUI)\n * user - attributes set by the user\n * series_ - { seriesName -> { idx, yAxis, options }}\n */\n\n/**\n * This parses attributes into an object that can be easily queried.\n *\n * It doesn't necessarily mean that all options are available, specifically\n * if labels are not yet available, since those drive details of the per-series\n * and per-axis options.\n *\n * @param {Dygraph} dygraph The chart to which these options belong.\n * @constructor\n */\nvar DygraphOptions = function(dygraph) {\n /**\n * The dygraph.\n * @type {!Dygraph}\n */\n this.dygraph_ = dygraph;\n\n /**\n * Array of axis index to { series : [ series names ] , options : { axis-specific options. }\n * @type {Array.<{series : Array.<string>, options : Object}>} @private\n */\n this.yAxes_ = [];\n\n /**\n * Contains x-axis specific options, which are stored in the options key.\n * This matches the yAxes_ object structure (by being a dictionary with an\n * options element) allowing for shared code.\n * @type {options: Object} @private\n */\n this.xAxis_ = {};\n this.series_ = {};\n\n // Once these two objects are initialized, you can call get();\n this.global_ = this.dygraph_.attrs_;\n this.user_ = this.dygraph_.user_attrs_ || {};\n\n /**\n * A list of series in columnar order.\n * @type {Array.<string>}\n */\n this.labels_ = [];\n\n this.highlightSeries_ = this.get(\"highlightSeriesOpts\") || {};\n this.reparseSeries();\n};\n\n/**\n * Not optimal, but does the trick when you're only using two axes.\n * If we move to more axes, this can just become a function.\n *\n * @type {Object.<number>}\n * @private\n */\nDygraphOptions.AXIS_STRING_MAPPINGS_ = {\n 'y' : 0,\n 'Y' : 0,\n 'y1' : 0,\n 'Y1' : 0,\n 'y2' : 1,\n 'Y2' : 1\n};\n\n/**\n * @param {string|number} axis\n * @private\n */\nDygraphOptions.axisToIndex_ = function(axis) {\n if (typeof(axis) == \"string\") {\n if (DygraphOptions.AXIS_STRING_MAPPINGS_.hasOwnProperty(axis)) {\n return DygraphOptions.AXIS_STRING_MAPPINGS_[axis];\n }\n throw \"Unknown axis : \" + axis;\n }\n if (typeof(axis) == \"number\") {\n if (axis === 0 || axis === 1) {\n return axis;\n }\n throw \"Dygraphs only supports two y-axes, indexed from 0-1.\";\n }\n if (axis) {\n throw \"Unknown axis : \" + axis;\n }\n // No axis specification means axis 0.\n return 0;\n};\n\n/**\n * Reparses options that are all related to series. This typically occurs when\n * options are either updated, or source data has been made available.\n *\n * TODO(konigsberg): The method name is kind of weak; fix.\n */\nDygraphOptions.prototype.reparseSeries = function() {\n var labels = this.get(\"labels\");\n if (!labels) {\n return; // -- can't do more for now, will parse after getting the labels.\n }\n\n this.labels_ = labels.slice(1);\n\n this.yAxes_ = [ { series : [], options : {}} ]; // Always one axis at least.\n this.xAxis_ = { options : {} };\n this.series_ = {};\n\n // Series are specified in the series element:\n //\n // {\n // labels: [ \"X\", \"foo\", \"bar\" ],\n // pointSize: 3,\n // series : {\n // foo : {}, // options for foo\n // bar : {} // options for bar\n // }\n // }\n //\n // So, if series is found, it's expected to contain per-series data, otherwise set a\n // default.\n var seriesDict = this.user_.series || {};\n for (var idx = 0; idx < this.labels_.length; idx++) {\n
"/**\n * @license\n * Copyright 2011 Dan Vanderkam (danvdk@gmail.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/**\n * @fileoverview Description of this file.\n * @author danvk@google.com (Dan Vanderkam)\n *\n * A ticker is a function with the following interface:\n *\n * function(a, b, pixels, options_view, dygraph, forced_values);\n * -> [ { v: tick1_v, label: tick1_label[, label_v: label_v1] },\n * { v: tick2_v, label: tick2_label[, label_v: label_v2] },\n * ...\n * ]\n *\n * The returned value is called a \"tick list\".\n *\n * Arguments\n * ---------\n *\n * [a, b] is the range of the axis for which ticks are being generated. For a\n * numeric axis, these will simply be numbers. For a date axis, these will be\n * millis since epoch (convertable to Date objects using \"new Date(a)\" and \"new\n * Date(b)\").\n *\n * opts provides access to chart- and axis-specific options. It can be used to\n * access number/date formatting code/options, check for a log scale, etc.\n *\n * pixels is the length of the axis in pixels. opts('pixelsPerLabel') is the\n * minimum amount of space to be allotted to each label. For instance, if\n * pixels=400 and opts('pixelsPerLabel')=40 then the ticker should return\n * between zero and ten (400/40) ticks.\n *\n * dygraph is the Dygraph object for which an axis is being constructed.\n *\n * forced_values is used for secondary y-axes. The tick positions are typically\n * set by the primary y-axis, so the secondary y-axis has no choice in where to\n * put these. It simply has to generate labels for these data values.\n *\n * Tick lists\n * ----------\n * Typically a tick will have both a grid/tick line and a label at one end of\n * that line (at the bottom for an x-axis, at left or right for the y-axis).\n *\n * A tick may be missing one of these two components:\n * - If \"label_v\" is specified instead of \"v\", then there will be no tick or\n * gridline, just a label.\n * - Similarly, if \"label\" is not specified, then there will be a gridline\n * without a label.\n *\n * This flexibility is useful in a few situations:\n * - For log scales, some of the tick lines may be too close to all have labels.\n * - For date scales where years are being displayed, it is desirable to display\n * tick marks at the beginnings of years but labels (e.g. \"2006\") in the\n * middle of the years.\n */\n\n/*jshint sub:true */\n/*global Dygraph:false */\n\"use strict\";\n\nimport * as utils from './dygraph-utils';\n\n/** @typedef {Array.<{v:number, label:string, label_v:(string|undefined)}>} */\nvar TickList = undefined; // the ' = undefined' keeps jshint happy.\n\n/** @typedef {function(\n * number,\n * number,\n * number,\n * function(string):*,\n * Dygraph=,\n * Array.<number>=\n * ): TickList}\n */\nvar Ticker = undefined; // the ' = undefined' keeps jshint happy.\n\n/** @type {Ticker} */\nexport var numericLinearTicks = function(a, b, pixels, opts, dygraph, vals) {\n var nonLogscaleOpts = function(opt) {\n if (opt === 'logscale') return false;\n return opts(opt);\n };\n return numericTicks(a, b, pixels, nonLogscaleOpts, dygraph, vals);\n};\n\n/** @type {Ticker} */\nexport var numericTicks = function(a, b, pixels, opts, dygraph, vals) {\n var pixels_per_tick = /** @type{number} */(opts('pixelsPerLabel'));\n var ticks = [];\n var i, j, tickV, nTicks;\n if (vals) {\n for (i = 0; i < vals.length; i++) {\n ticks.push({v: vals[i]});\n }\n } else {\n // TODO(danvk): factor this log-scale block out into a separate function.\n if (opts(\"logscale\")) {\n nTicks = Math.floor(pixels / pixels_per_tick);\n var minIdx = utils.binarySearch(a, PREFERRED_LOG_TICK_VALUES, 1);\n var maxIdx = utils.binarySearch(b, PREFERRED_LOG_TICK_VALUES, -1);\n if (minIdx == -1) {\n minIdx = 0;\n }\n if (maxIdx == -1) {\n maxIdx = PREFERRED_LOG_TICK_VALUES.length - 1;\n }\n // Count the number of tick values would appear, if we can get at least\n // nTicks / 4 accept them.\n v
"/**\n * @license\n * Copyright 2011 Dan Vanderkam (danvdk@gmail.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/**\n * @fileoverview This file contains utility functions used by dygraphs. These\n * are typically static (i.e. not related to any particular dygraph). Examples\n * include date/time formatting functions, basic algorithms (e.g. binary\n * search) and generic DOM-manipulation functions.\n */\n\n/*global Dygraph:false, Node:false */\n\"use strict\";\n\nimport * as DygraphTickers from './dygraph-tickers';\n\nexport var LOG_SCALE = 10;\nexport var LN_TEN = Math.log(LOG_SCALE);\n\n/**\n * @private\n * @param {number} x\n * @return {number}\n */\nexport var log10 = function(x) {\n return Math.log(x) / LN_TEN;\n};\n\n/**\n * @private\n * @param {number} r0\n * @param {number} r1\n * @param {number} pct\n * @return {number}\n */\nexport var logRangeFraction = function(r0, r1, pct) {\n // Computing the inverse of toPercentXCoord. The function was arrived at with\n // the following steps:\n //\n // Original calcuation:\n // pct = (log(x) - log(xRange[0])) / (log(xRange[1]) - log(xRange[0])));\n //\n // Multiply both sides by the right-side demoninator.\n // pct * (log(xRange[1] - log(xRange[0]))) = log(x) - log(xRange[0])\n //\n // add log(xRange[0]) to both sides\n // log(xRange[0]) + (pct * (log(xRange[1]) - log(xRange[0])) = log(x);\n //\n // Swap both sides of the equation,\n // log(x) = log(xRange[0]) + (pct * (log(xRange[1]) - log(xRange[0]))\n //\n // Use both sides as the exponent in 10^exp and we're done.\n // x = 10 ^ (log(xRange[0]) + (pct * (log(xRange[1]) - log(xRange[0])))\n\n var logr0 = log10(r0);\n var logr1 = log10(r1);\n var exponent = logr0 + (pct * (logr1 - logr0));\n var value = Math.pow(LOG_SCALE, exponent);\n return value;\n};\n\n/** A dotted line stroke pattern. */\nexport var DOTTED_LINE = [2, 2];\n/** A dashed line stroke pattern. */\nexport var DASHED_LINE = [7, 3];\n/** A dot dash stroke pattern. */\nexport var DOT_DASH_LINE = [7, 2, 2, 2];\n\n// Directions for panning and zooming. Use bit operations when combined\n// values are possible.\nexport var HORIZONTAL = 1;\nexport var VERTICAL = 2;\n\n/**\n * Return the 2d context for a dygraph canvas.\n *\n * This method is only exposed for the sake of replacing the function in\n * automated tests.\n *\n * @param {!HTMLCanvasElement} canvas\n * @return {!CanvasRenderingContext2D}\n * @private\n */\nexport var getContext = function(canvas) {\n return /** @type{!CanvasRenderingContext2D}*/(canvas.getContext(\"2d\"));\n};\n\n/**\n * Add an event handler.\n * @param {!Node} elem The element to add the event to.\n * @param {string} type The type of the event, e.g. 'click' or 'mousemove'.\n * @param {function(Event):(boolean|undefined)} fn The function to call\n * on the event. The function takes one parameter: the event object.\n * @private\n */\nexport var addEvent = function addEvent(elem, type, fn) {\n elem.addEventListener(type, fn, false);\n};\n\n/**\n * Remove an event handler.\n * @param {!Node} elem The element to remove the event from.\n * @param {string} type The type of the event, e.g. 'click' or 'mousemove'.\n * @param {function(Event):(boolean|undefined)} fn The function to call\n * on the event. The function takes one parameter: the event object.\n */\nexport function removeEvent(elem, type, fn) {\n elem.removeEventListener(type, fn, false);\n};\n\n/**\n * Cancels further processing of an event. This is useful to prevent default\n * browser actions, e.g. highlighting text on a double-click.\n * Based on the article at\n * http://www.switchonthecode.com/tutorials/javascript-tutorial-the-scroll-wheel\n * @param {!Event} e The event whose normal behavior should be canceled.\n * @private\n */\nexport function cancelEvent(e) {\n e = e ? e : window.event;\n if (e.stopPropagation) {\n e.stopPropagation();\n }\n if (e.preventDefault) {\n e.preventDefault();\n }\n e.cancelBubble = true;\n e.cancel = true;\n e.returnValue = false;\n return false;\n};\n\n/**\n * Convert hsv v
"/**\n * @license\n * Copyright 2006 Dan Vanderkam (danvdk@gmail.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/**\n * @fileoverview Creates an interactive, zoomable graph based on a CSV file or\n * string. Dygraph can handle multiple series with or without error bars. The\n * date/value ranges will be automatically set. Dygraph uses the\n * &lt;canvas&gt; tag, so it only works in FF1.5+.\n * @author danvdk@gmail.com (Dan Vanderkam)\n\n Usage:\n <div id=\"graphdiv\" style=\"width:800px; height:500px;\"></div>\n <script type=\"text/javascript\">\n new Dygraph(document.getElementById(\"graphdiv\"),\n \"datafile.csv\", // CSV file with headers\n { }); // options\n </script>\n\n The CSV file is of the form\n\n Date,SeriesA,SeriesB,SeriesC\n YYYYMMDD,A1,B1,C1\n YYYYMMDD,A2,B2,C2\n\n If the 'errorBars' option is set in the constructor, the input should be of\n the form\n Date,SeriesA,SeriesB,...\n YYYYMMDD,A1,sigmaA1,B1,sigmaB1,...\n YYYYMMDD,A2,sigmaA2,B2,sigmaB2,...\n\n If the 'fractions' option is set, the input should be of the form:\n\n Date,SeriesA,SeriesB,...\n YYYYMMDD,A1/B1,A2/B2,...\n YYYYMMDD,A1/B1,A2/B2,...\n\n And error bars will be calculated automatically using a binomial distribution.\n\n For further documentation and examples, see http://dygraphs.com/\n */\n\nimport DygraphLayout from './dygraph-layout';\nimport DygraphCanvasRenderer from './dygraph-canvas';\nimport DygraphOptions from './dygraph-options';\nimport DygraphInteraction from './dygraph-interaction-model';\nimport * as DygraphTickers from './dygraph-tickers';\nimport * as utils from './dygraph-utils';\nimport DEFAULT_ATTRS from './dygraph-default-attrs';\nimport OPTIONS_REFERENCE from './dygraph-options-reference';\nimport IFrameTarp from './iframe-tarp';\n\nimport DefaultHandler from './datahandler/default';\nimport ErrorBarsHandler from './datahandler/bars-error';\nimport CustomBarsHandler from './datahandler/bars-custom';\nimport DefaultFractionHandler from './datahandler/default-fractions';\nimport FractionsBarsHandler from './datahandler/bars-fractions';\nimport BarsHandler from './datahandler/bars';\n\nimport AnnotationsPlugin from './plugins/annotations';\nimport AxesPlugin from './plugins/axes';\nimport ChartLabelsPlugin from './plugins/chart-labels';\nimport GridPlugin from './plugins/grid';\nimport LegendPlugin from './plugins/legend';\nimport RangeSelectorPlugin from './plugins/range-selector';\n\nimport GVizChart from './dygraph-gviz';\n\n\"use strict\";\n\n/**\n * Creates an interactive, zoomable chart.\n *\n * @constructor\n * @param {div | String} div A div or the id of a div into which to construct\n * the chart.\n * @param {String | Function} file A file containing CSV data or a function\n * that returns this data. The most basic expected format for each line is\n * \"YYYY/MM/DD,val1,val2,...\". For more information, see\n * http://dygraphs.com/data.html.\n * @param {Object} attrs Various other attributes, e.g. errorBars determines\n * whether the input data contains error ranges. For a complete list of\n * options, see http://dygraphs.com/options.html.\n */\nvar Dygraph = function(div, data, opts) {\n this.__init__(div, data, opts);\n};\n\nDygraph.NAME = \"Dygraph\";\nDygraph.VERSION = \"2.0.0\";\n\n// Various default values\nDygraph.DEFAULT_ROLL_PERIOD = 1;\nDygraph.DEFAULT_WIDTH = 480;\nDygraph.DEFAULT_HEIGHT = 320;\n\n// For max 60 Hz. animation:\nDygraph.ANIMATION_STEPS = 12;\nDygraph.ANIMATION_DURATION = 200;\n\n/**\n * Standard plotters. These may be used by clients.\n * Available plotters are:\n * - Dygraph.Plotters.linePlotter: draws central lines (most common)\n * - Dygraph.Plotters.errorPlotter: draws error bars\n * - Dygraph.Plotters.fillPlotter: draws fills under lines (used with fillGraph)\n *\n * By default, the plotter is [fillPlotter, errorPlotter, linePlotter].\n * This causes all the lines to be drawn over all the fills/error bars.\n */\nDygraph.Plotters = DygraphCanvasRenderer._Plotters;\n\n\n// Used for initializing annotat
"/**\n * To create a \"drag\" interaction, you typically register a mousedown event\n * handler on the element where the drag begins. In that handler, you register a\n * mouseup handler on the window to determine when the mouse is released,\n * wherever that release happens. This works well, except when the user releases\n * the mouse over an off-domain iframe. In that case, the mouseup event is\n * handled by the iframe and never bubbles up to the window handler.\n *\n * To deal with this issue, we cover iframes with high z-index divs to make sure\n * they don't capture mouseup.\n *\n * Usage:\n * element.addEventListener('mousedown', function() {\n * var tarper = new IFrameTarp();\n * tarper.cover();\n * var mouseUpHandler = function() {\n * ...\n * window.removeEventListener(mouseUpHandler);\n * tarper.uncover();\n * };\n * window.addEventListener('mouseup', mouseUpHandler);\n * };\n *\n * @constructor\n */\nimport * as utils from './dygraph-utils';\n\nfunction IFrameTarp() {\n /** @type {Array.<!HTMLDivElement>} */\n this.tarps = [];\n};\n\n/**\n * Find all the iframes in the document and cover them with high z-index\n * transparent divs.\n */\nIFrameTarp.prototype.cover = function() {\n var iframes = document.getElementsByTagName(\"iframe\");\n for (var i = 0; i < iframes.length; i++) {\n var iframe = iframes[i];\n var pos = utils.findPos(iframe),\n x = pos.x,\n y = pos.y,\n width = iframe.offsetWidth,\n height = iframe.offsetHeight;\n\n var div = document.createElement(\"div\");\n div.style.position = \"absolute\";\n div.style.left = x + 'px';\n div.style.top = y + 'px';\n div.style.width = width + 'px';\n div.style.height = height + 'px';\n div.style.zIndex = 999;\n document.body.appendChild(div);\n this.tarps.push(div);\n }\n};\n\n/**\n * Remove all the iframe covers. You should call this in a mouseup handler.\n */\nIFrameTarp.prototype.uncover = function() {\n for (var i = 0; i < this.tarps.length; i++) {\n this.tarps[i].parentNode.removeChild(this.tarps[i]);\n }\n this.tarps = [];\n};\n\nexport default IFrameTarp;\n",
"/**\n * @license\n * Copyright 2012 Dan Vanderkam (danvdk@gmail.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/*global Dygraph:false */\n\n\"use strict\";\n\n/**\nCurrent bits of jankiness:\n- Uses dygraph.layout_ to get the parsed annotations.\n- Uses dygraph.plotter_.area\n\nIt would be nice if the plugin didn't require so much special support inside\nthe core dygraphs classes, but annotations involve quite a bit of parsing and\nlayout.\n\nTODO(danvk): cache DOM elements.\n*/\n\nvar annotations = function() {\n this.annotations_ = [];\n};\n\nannotations.prototype.toString = function() {\n return \"Annotations Plugin\";\n};\n\nannotations.prototype.activate = function(g) {\n return {\n clearChart: this.clearChart,\n didDrawChart: this.didDrawChart\n };\n};\n\nannotations.prototype.detachLabels = function() {\n for (var i = 0; i < this.annotations_.length; i++) {\n var a = this.annotations_[i];\n if (a.parentNode) a.parentNode.removeChild(a);\n this.annotations_[i] = null;\n }\n this.annotations_ = [];\n};\n\nannotations.prototype.clearChart = function(e) {\n this.detachLabels();\n};\n\nannotations.prototype.didDrawChart = function(e) {\n var g = e.dygraph;\n\n // Early out in the (common) case of zero annotations.\n var points = g.layout_.annotated_points;\n if (!points || points.length === 0) return;\n\n var containerDiv = e.canvas.parentNode;\n\n var bindEvt = function(eventName, classEventName, pt) {\n return function(annotation_event) {\n var a = pt.annotation;\n if (a.hasOwnProperty(eventName)) {\n a[eventName](a, pt, g, annotation_event);\n } else if (g.getOption(classEventName)) {\n g.getOption(classEventName)(a, pt, g, annotation_event );\n }\n };\n };\n\n // Add the annotations one-by-one.\n var area = e.dygraph.getArea();\n\n // x-coord to sum of previous annotation's heights (used for stacking).\n var xToUsedHeight = {};\n\n for (var i = 0; i < points.length; i++) {\n var p = points[i];\n if (p.canvasx < area.x || p.canvasx > area.x + area.w ||\n p.canvasy < area.y || p.canvasy > area.y + area.h) {\n continue;\n }\n\n var a = p.annotation;\n var tick_height = 6;\n if (a.hasOwnProperty(\"tickHeight\")) {\n tick_height = a.tickHeight;\n }\n\n // TODO: deprecate axisLabelFontSize in favor of CSS\n var div = document.createElement(\"div\");\n div.style['fontSize'] = g.getOption('axisLabelFontSize') + \"px\";\n var className = 'dygraph-annotation';\n if (!a.hasOwnProperty('icon')) {\n // camelCase class names are deprecated.\n className += ' dygraphDefaultAnnotation dygraph-default-annotation';\n }\n if (a.hasOwnProperty('cssClass')) {\n className += \" \" + a.cssClass;\n }\n div.className = className;\n\n var width = a.hasOwnProperty('width') ? a.width : 16;\n var height = a.hasOwnProperty('height') ? a.height : 16;\n if (a.hasOwnProperty('icon')) {\n var img = document.createElement(\"img\");\n img.src = a.icon;\n img.width = width;\n img.height = height;\n div.appendChild(img);\n } else if (p.annotation.hasOwnProperty('shortText')) {\n div.appendChild(document.createTextNode(p.annotation.shortText));\n }\n var left = p.canvasx - width / 2;\n div.style.left = left + \"px\";\n var divTop = 0;\n if (a.attachAtBottom) {\n var y = (area.y + area.h - height - tick_height);\n if (xToUsedHeight[left]) {\n y -= xToUsedHeight[left];\n } else {\n xToUsedHeight[left] = 0;\n }\n xToUsedHeight[left] += (tick_height + height);\n divTop = y;\n } else {\n divTop = p.canvasy - height - tick_height;\n }\n div.style.top = divTop + \"px\";\n div.style.width = width + \"px\";\n div.style.height = height + \"px\";\n div.title = p.annotation.text;\n div.style.color = g.colorsMap_[p.name];\n div.style.borderColor = g.colorsMap_[p.name];\n a.div = div;\n\n g.addAndTrackEvent(div, 'click',\n bindEvt('clickHandler', 'an
"/**\n * @license\n * Copyright 2012 Dan Vanderkam (danvdk@gmail.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n\n/*global Dygraph:false */\n\n'use strict';\n\n/*\nBits of jankiness:\n- Direct layout access\n- Direct area access\n- Should include calculation of ticks, not just the drawing.\n\nOptions left to make axis-friendly.\n ('drawAxesAtZero')\n ('xAxisHeight')\n*/\n\nimport * as utils from '../dygraph-utils';\n\n/**\n * Draws the axes. This includes the labels on the x- and y-axes, as well\n * as the tick marks on the axes.\n * It does _not_ draw the grid lines which span the entire chart.\n */\nvar axes = function() {\n this.xlabels_ = [];\n this.ylabels_ = [];\n};\n\naxes.prototype.toString = function() {\n return 'Axes Plugin';\n};\n\naxes.prototype.activate = function(g) {\n return {\n layout: this.layout,\n clearChart: this.clearChart,\n willDrawChart: this.willDrawChart\n };\n};\n\naxes.prototype.layout = function(e) {\n var g = e.dygraph;\n\n if (g.getOptionForAxis('drawAxis', 'y')) {\n var w = g.getOptionForAxis('axisLabelWidth', 'y') + 2 * g.getOptionForAxis('axisTickSize', 'y');\n e.reserveSpaceLeft(w);\n }\n\n if (g.getOptionForAxis('drawAxis', 'x')) {\n var h;\n // NOTE: I think this is probably broken now, since g.getOption() now\n // hits the dictionary. (That is, g.getOption('xAxisHeight') now always\n // has a value.)\n if (g.getOption('xAxisHeight')) {\n h = g.getOption('xAxisHeight');\n } else {\n h = g.getOptionForAxis('axisLabelFontSize', 'x') + 2 * g.getOptionForAxis('axisTickSize', 'x');\n }\n e.reserveSpaceBottom(h);\n }\n\n if (g.numAxes() == 2) {\n if (g.getOptionForAxis('drawAxis', 'y2')) {\n var w = g.getOptionForAxis('axisLabelWidth', 'y2') + 2 * g.getOptionForAxis('axisTickSize', 'y2');\n e.reserveSpaceRight(w);\n }\n } else if (g.numAxes() > 2) {\n g.error('Only two y-axes are supported at this time. (Trying ' +\n 'to use ' + g.numAxes() + ')');\n }\n};\n\naxes.prototype.detachLabels = function() {\n function removeArray(ary) {\n for (var i = 0; i < ary.length; i++) {\n var el = ary[i];\n if (el.parentNode) el.parentNode.removeChild(el);\n }\n }\n\n removeArray(this.xlabels_);\n removeArray(this.ylabels_);\n this.xlabels_ = [];\n this.ylabels_ = [];\n};\n\naxes.prototype.clearChart = function(e) {\n this.detachLabels();\n};\n\naxes.prototype.willDrawChart = function(e) {\n var g = e.dygraph;\n\n if (!g.getOptionForAxis('drawAxis', 'x') &&\n !g.getOptionForAxis('drawAxis', 'y') &&\n !g.getOptionForAxis('drawAxis', 'y2')) {\n return;\n }\n\n // Round pixels to half-integer boundaries for crisper drawing.\n function halfUp(x) { return Math.round(x) + 0.5; }\n function halfDown(y){ return Math.round(y) - 0.5; }\n\n var context = e.drawingContext;\n var containerDiv = e.canvas.parentNode;\n var canvasWidth = g.width_; // e.canvas.width is affected by pixel ratio.\n var canvasHeight = g.height_;\n\n var label, x, y, tick, i;\n\n var makeLabelStyle = function(axis) {\n return {\n position: 'absolute',\n fontSize: g.getOptionForAxis('axisLabelFontSize', axis) + 'px',\n width: g.getOptionForAxis('axisLabelWidth', axis) + 'px',\n };\n };\n\n var labelStyles = {\n x: makeLabelStyle('x'),\n y: makeLabelStyle('y'),\n y2: makeLabelStyle('y2')\n };\n\n var makeDiv = function(txt, axis, prec_axis) {\n /*\n * This seems to be called with the following three sets of axis/prec_axis:\n * x: undefined\n * y: y1\n * y: y2\n */\n var div = document.createElement('div');\n var labelStyle = labelStyles[prec_axis == 'y2' ? 'y2' : axis];\n utils.update(div.style, labelStyle);\n // TODO: combine outer & inner divs\n var inner_div = document.createElement('div');\n inner_div.className = 'dygraph-axis-label' +\n ' dygraph-axis-label-' + axis +\n (prec_axis ? ' dygraph-axis-label-' + prec_axis : '');\n inner_div.innerHTML = tx
"/**\n * @license\n * Copyright 2012 Dan Vanderkam (danvdk@gmail.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n/*global Dygraph:false */\n\n\"use strict\";\n\n// TODO(danvk): move chart label options out of dygraphs and into the plugin.\n// TODO(danvk): only tear down & rebuild the DIVs when it's necessary.\n\nvar chart_labels = function() {\n this.title_div_ = null;\n this.xlabel_div_ = null;\n this.ylabel_div_ = null;\n this.y2label_div_ = null;\n};\n\nchart_labels.prototype.toString = function() {\n return \"ChartLabels Plugin\";\n};\n\nchart_labels.prototype.activate = function(g) {\n return {\n layout: this.layout,\n // clearChart: this.clearChart,\n didDrawChart: this.didDrawChart\n };\n};\n\n// QUESTION: should there be a plugin-utils.js?\nvar createDivInRect = function(r) {\n var div = document.createElement('div');\n div.style.position = 'absolute';\n div.style.left = r.x + 'px';\n div.style.top = r.y + 'px';\n div.style.width = r.w + 'px';\n div.style.height = r.h + 'px';\n return div;\n};\n\n// Detach and null out any existing nodes.\nchart_labels.prototype.detachLabels_ = function() {\n var els = [ this.title_div_,\n this.xlabel_div_,\n this.ylabel_div_,\n this.y2label_div_ ];\n for (var i = 0; i < els.length; i++) {\n var el = els[i];\n if (!el) continue;\n if (el.parentNode) el.parentNode.removeChild(el);\n }\n\n this.title_div_ = null;\n this.xlabel_div_ = null;\n this.ylabel_div_ = null;\n this.y2label_div_ = null;\n};\n\nvar createRotatedDiv = function(g, box, axis, classes, html) {\n // TODO(danvk): is this outer div actually necessary?\n var div = document.createElement(\"div\");\n div.style.position = 'absolute';\n if (axis == 1) {\n // NOTE: this is cheating. Should be positioned relative to the box.\n div.style.left = '0px';\n } else {\n div.style.left = box.x + 'px';\n }\n div.style.top = box.y + 'px';\n div.style.width = box.w + 'px';\n div.style.height = box.h + 'px';\n div.style.fontSize = (g.getOption('yLabelWidth') - 2) + 'px';\n\n var inner_div = document.createElement(\"div\");\n inner_div.style.position = 'absolute';\n inner_div.style.width = box.h + 'px';\n inner_div.style.height = box.w + 'px';\n inner_div.style.top = (box.h / 2 - box.w / 2) + 'px';\n inner_div.style.left = (box.w / 2 - box.h / 2) + 'px';\n // TODO: combine inner_div and class_div.\n inner_div.className = 'dygraph-label-rotate-' + (axis == 1 ? 'right' : 'left');\n\n var class_div = document.createElement(\"div\");\n class_div.className = classes;\n class_div.innerHTML = html;\n\n inner_div.appendChild(class_div);\n div.appendChild(inner_div);\n return div;\n};\n\nchart_labels.prototype.layout = function(e) {\n this.detachLabels_();\n\n var g = e.dygraph;\n var div = e.chart_div;\n if (g.getOption('title')) {\n // QUESTION: should this return an absolutely-positioned div instead?\n var title_rect = e.reserveSpaceTop(g.getOption('titleHeight'));\n this.title_div_ = createDivInRect(title_rect);\n this.title_div_.style.fontSize = (g.getOption('titleHeight') - 8) + 'px';\n\n var class_div = document.createElement(\"div\");\n class_div.className = 'dygraph-label dygraph-title';\n class_div.innerHTML = g.getOption('title');\n this.title_div_.appendChild(class_div);\n div.appendChild(this.title_div_);\n }\n\n if (g.getOption('xlabel')) {\n var x_rect = e.reserveSpaceBottom(g.getOption('xLabelHeight'));\n this.xlabel_div_ = createDivInRect(x_rect);\n this.xlabel_div_.style.fontSize = (g.getOption('xLabelHeight') - 2) + 'px';\n\n var class_div = document.createElement(\"div\");\n class_div.className = 'dygraph-label dygraph-xlabel';\n class_div.innerHTML = g.getOption('xlabel');\n this.xlabel_div_.appendChild(class_div);\n div.appendChild(this.xlabel_div_);\n }\n\n if (g.getOption('ylabel')) {\n // It would make sense to shift the chart here to make room for the y-axis\n // label, but the default yAxisLabelWidth is large enough that th
"/**\n * @license\n * Copyright 2012 Dan Vanderkam (danvdk@gmail.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n/*global Dygraph:false */\n\n/*\n\nCurrent bits of jankiness:\n- Direct layout access\n- Direct area access\n\n*/\n\n\"use strict\";\n\n/**\n * Draws the gridlines, i.e. the gray horizontal & vertical lines running the\n * length of the chart.\n *\n * @constructor\n */\nvar grid = function() {\n};\n\ngrid.prototype.toString = function() {\n return \"Gridline Plugin\";\n};\n\ngrid.prototype.activate = function(g) {\n return {\n willDrawChart: this.willDrawChart\n };\n};\n\ngrid.prototype.willDrawChart = function(e) {\n // Draw the new X/Y grid. Lines appear crisper when pixels are rounded to\n // half-integers. This prevents them from drawing in two rows/cols.\n var g = e.dygraph;\n var ctx = e.drawingContext;\n var layout = g.layout_;\n var area = e.dygraph.plotter_.area;\n\n function halfUp(x) { return Math.round(x) + 0.5; }\n function halfDown(y){ return Math.round(y) - 0.5; }\n\n var x, y, i, ticks;\n if (g.getOptionForAxis('drawGrid', 'y')) {\n var axes = [\"y\", \"y2\"];\n var strokeStyles = [], lineWidths = [], drawGrid = [], stroking = [], strokePattern = [];\n for (var i = 0; i < axes.length; i++) {\n drawGrid[i] = g.getOptionForAxis('drawGrid', axes[i]);\n if (drawGrid[i]) {\n strokeStyles[i] = g.getOptionForAxis('gridLineColor', axes[i]);\n lineWidths[i] = g.getOptionForAxis('gridLineWidth', axes[i]);\n strokePattern[i] = g.getOptionForAxis('gridLinePattern', axes[i]);\n stroking[i] = strokePattern[i] && (strokePattern[i].length >= 2);\n }\n }\n ticks = layout.yticks;\n ctx.save();\n // draw grids for the different y axes\n ticks.forEach(tick => {\n if (!tick.has_tick) return;\n var axis = tick.axis;\n if (drawGrid[axis]) {\n ctx.save();\n if (stroking[axis]) {\n if (ctx.setLineDash) ctx.setLineDash(strokePattern[axis]);\n }\n ctx.strokeStyle = strokeStyles[axis];\n ctx.lineWidth = lineWidths[axis];\n\n x = halfUp(area.x);\n y = halfDown(area.y + tick.pos * area.h);\n ctx.beginPath();\n ctx.moveTo(x, y);\n ctx.lineTo(x + area.w, y);\n ctx.stroke();\n\n ctx.restore();\n }\n });\n ctx.restore();\n }\n\n // draw grid for x axis\n if (g.getOptionForAxis('drawGrid', 'x')) {\n ticks = layout.xticks;\n ctx.save();\n var strokePattern = g.getOptionForAxis('gridLinePattern', 'x');\n var stroking = strokePattern && (strokePattern.length >= 2);\n if (stroking) {\n if (ctx.setLineDash) ctx.setLineDash(strokePattern);\n }\n ctx.strokeStyle = g.getOptionForAxis('gridLineColor', 'x');\n ctx.lineWidth = g.getOptionForAxis('gridLineWidth', 'x');\n ticks.forEach(tick => {\n if (!tick.has_tick) return;\n x = halfUp(area.x + tick.pos * area.w);\n y = halfDown(area.y + area.h);\n ctx.beginPath();\n ctx.moveTo(x, y);\n ctx.lineTo(x, area.y);\n ctx.closePath();\n ctx.stroke();\n });\n if (stroking) {\n if (ctx.setLineDash) ctx.setLineDash([]);\n }\n ctx.restore();\n }\n};\n\ngrid.prototype.destroy = function() {\n};\n\nexport default grid;\n",
"/**\n * @license\n * Copyright 2012 Dan Vanderkam (danvdk@gmail.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n/*global Dygraph:false */\n\n/*\nCurrent bits of jankiness:\n- Uses two private APIs:\n 1. Dygraph.optionsViewForAxis_\n 2. dygraph.plotter_.area\n- Registers for a \"predraw\" event, which should be renamed.\n- I call calculateEmWidthInDiv more often than needed.\n*/\n\n/*global Dygraph:false */\n\"use strict\";\n\nimport * as utils from '../dygraph-utils';\n\n\n/**\n * Creates the legend, which appears when the user hovers over the chart.\n * The legend can be either a user-specified or generated div.\n *\n * @constructor\n */\nvar Legend = function() {\n this.legend_div_ = null;\n this.is_generated_div_ = false; // do we own this div, or was it user-specified?\n};\n\nLegend.prototype.toString = function() {\n return \"Legend Plugin\";\n};\n\n/**\n * This is called during the dygraph constructor, after options have been set\n * but before the data is available.\n *\n * Proper tasks to do here include:\n * - Reading your own options\n * - DOM manipulation\n * - Registering event listeners\n *\n * @param {Dygraph} g Graph instance.\n * @return {object.<string, function(ev)>} Mapping of event names to callbacks.\n */\nLegend.prototype.activate = function(g) {\n var div;\n\n var userLabelsDiv = g.getOption('labelsDiv');\n if (userLabelsDiv && null !== userLabelsDiv) {\n if (typeof(userLabelsDiv) == \"string\" || userLabelsDiv instanceof String) {\n div = document.getElementById(userLabelsDiv);\n } else {\n div = userLabelsDiv;\n }\n } else {\n div = document.createElement(\"div\");\n div.className = \"dygraph-legend\";\n // TODO(danvk): come up with a cleaner way to expose this.\n g.graphDiv.appendChild(div);\n this.is_generated_div_ = true;\n }\n\n this.legend_div_ = div;\n this.one_em_width_ = 10; // just a guess, will be updated.\n\n return {\n select: this.select,\n deselect: this.deselect,\n // TODO(danvk): rethink the name \"predraw\" before we commit to it in any API.\n predraw: this.predraw,\n didDrawChart: this.didDrawChart\n };\n};\n\n// Needed for dashed lines.\nvar calculateEmWidthInDiv = function(div) {\n var sizeSpan = document.createElement('span');\n sizeSpan.setAttribute('style', 'margin: 0; padding: 0 0 0 1em; border: 0;');\n div.appendChild(sizeSpan);\n var oneEmWidth=sizeSpan.offsetWidth;\n div.removeChild(sizeSpan);\n return oneEmWidth;\n};\n\nvar escapeHTML = function(str) {\n return str.replace(/&/g, \"&amp;\").replace(/\"/g, \"&quot;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\");\n};\n\nLegend.prototype.select = function(e) {\n var xValue = e.selectedX;\n var points = e.selectedPoints;\n var row = e.selectedRow;\n\n var legendMode = e.dygraph.getOption('legend');\n if (legendMode === 'never') {\n this.legend_div_.style.display = 'none';\n return;\n }\n\n if (legendMode === 'follow') {\n // create floating legend div\n var area = e.dygraph.plotter_.area;\n var labelsDivWidth = this.legend_div_.offsetWidth;\n var yAxisLabelWidth = e.dygraph.getOptionForAxis('axisLabelWidth', 'y');\n // determine floating [left, top] coordinates of the legend div\n // within the plotter_ area\n // offset 50 px to the right and down from the first selection point\n // 50 px is guess based on mouse cursor size\n var leftLegend = points[0].x * area.w + 50;\n var topLegend = points[0].y * area.h - 50;\n\n // if legend floats to end of the chart area, it flips to the other\n // side of the selection point\n if ((leftLegend + labelsDivWidth + 1) > area.w) {\n leftLegend = leftLegend - 2 * 50 - labelsDivWidth - (yAxisLabelWidth - area.x);\n }\n\n e.dygraph.graphDiv.appendChild(this.legend_div_);\n this.legend_div_.style.left = yAxisLabelWidth + leftLegend + \"px\";\n this.legend_div_.style.top = topLegend + \"px\";\n }\n\n var html = Legend.generateLegendHTML(e.dygraph, xValue, points, this.one_em_width_, row);\n this.legend_div_.innerHTML =
"/**\n * @license\n * Copyright 2011 Paul Felix (paul.eric.felix@gmail.com)\n * MIT-licensed (http://opensource.org/licenses/MIT)\n */\n/*global Dygraph:false,TouchEvent:false */\n\n/**\n * @fileoverview This file contains the RangeSelector plugin used to provide\n * a timeline range selector widget for dygraphs.\n */\n\n/*global Dygraph:false */\n\"use strict\";\n\nimport * as utils from '../dygraph-utils';\nimport DygraphInteraction from '../dygraph-interaction-model';\nimport IFrameTarp from '../iframe-tarp';\n\nvar rangeSelector = function() {\n this.hasTouchInterface_ = typeof(TouchEvent) != 'undefined';\n this.isMobileDevice_ = /mobile|android/gi.test(navigator.appVersion);\n this.interfaceCreated_ = false;\n};\n\nrangeSelector.prototype.toString = function() {\n return \"RangeSelector Plugin\";\n};\n\nrangeSelector.prototype.activate = function(dygraph) {\n this.dygraph_ = dygraph;\n if (this.getOption_('showRangeSelector')) {\n this.createInterface_();\n }\n return {\n layout: this.reserveSpace_,\n predraw: this.renderStaticLayer_,\n didDrawChart: this.renderInteractiveLayer_\n };\n};\n\nrangeSelector.prototype.destroy = function() {\n this.bgcanvas_ = null;\n this.fgcanvas_ = null;\n this.leftZoomHandle_ = null;\n this.rightZoomHandle_ = null;\n};\n\n//------------------------------------------------------------------\n// Private methods\n//------------------------------------------------------------------\n\nrangeSelector.prototype.getOption_ = function(name, opt_series) {\n return this.dygraph_.getOption(name, opt_series);\n};\n\nrangeSelector.prototype.setDefaultOption_ = function(name, value) {\n this.dygraph_.attrs_[name] = value;\n};\n\n/**\n * @private\n * Creates the range selector elements and adds them to the graph.\n */\nrangeSelector.prototype.createInterface_ = function() {\n this.createCanvases_();\n this.createZoomHandles_();\n this.initInteraction_();\n\n // Range selector and animatedZooms have a bad interaction. See issue 359.\n if (this.getOption_('animatedZooms')) {\n console.warn('Animated zooms and range selector are not compatible; disabling animatedZooms.');\n this.dygraph_.updateOptions({animatedZooms: false}, true);\n }\n\n this.interfaceCreated_ = true;\n this.addToGraph_();\n};\n\n/**\n * @private\n * Adds the range selector to the graph.\n */\nrangeSelector.prototype.addToGraph_ = function() {\n var graphDiv = this.graphDiv_ = this.dygraph_.graphDiv;\n graphDiv.appendChild(this.bgcanvas_);\n graphDiv.appendChild(this.fgcanvas_);\n graphDiv.appendChild(this.leftZoomHandle_);\n graphDiv.appendChild(this.rightZoomHandle_);\n};\n\n/**\n * @private\n * Removes the range selector from the graph.\n */\nrangeSelector.prototype.removeFromGraph_ = function() {\n var graphDiv = this.graphDiv_;\n graphDiv.removeChild(this.bgcanvas_);\n graphDiv.removeChild(this.fgcanvas_);\n graphDiv.removeChild(this.leftZoomHandle_);\n graphDiv.removeChild(this.rightZoomHandle_);\n this.graphDiv_ = null;\n};\n\n/**\n * @private\n * Called by Layout to allow range selector to reserve its space.\n */\nrangeSelector.prototype.reserveSpace_ = function(e) {\n if (this.getOption_('showRangeSelector')) {\n e.reserveSpaceBottom(this.getOption_('rangeSelectorHeight') + 4);\n }\n};\n\n/**\n * @private\n * Renders the static portion of the range selector at the predraw stage.\n */\nrangeSelector.prototype.renderStaticLayer_ = function() {\n if (!this.updateVisibility_()) {\n return;\n }\n this.resize_();\n this.drawStaticLayer_();\n};\n\n/**\n * @private\n * Renders the interactive portion of the range selector after the chart has been drawn.\n */\nrangeSelector.prototype.renderInteractiveLayer_ = function() {\n if (!this.updateVisibility_() || this.isChangingRange_) {\n return;\n }\n this.placeZoomHandles_();\n this.drawInteractiveLayer_();\n};\n\n/**\n * @private\n * Check to see if the range selector is enabled/disabled and update visibility accordingly.\n */\nrangeSelector.prototype.updateVisibility_ = function() {\n var enabled = this.getOpt
]
}