X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=src%2Fdygraph-options-reference.js;h=3f9a640879eccdfde75fce0f782d6dbac223f4ed;hb=c4c10db644336a08b581e2efdb3ad75b950c905c;hp=933bdab558e14bf80bfe12a615c68086951b8672;hpb=bf7d192b5aef6ea82e7e627d4cfcfca1cb978f23;p=dygraphs.git diff --git a/src/dygraph-options-reference.js b/src/dygraph-options-reference.js index 933bdab..3f9a640 100644 --- a/src/dygraph-options-reference.js +++ b/src/dygraph-options-reference.js @@ -4,11 +4,18 @@ * MIT-licensed (http://opensource.org/licenses/MIT) */ +"use strict"; + +var OPTIONS_REFERENCE = null; + +// For "production" code, this gets removed by uglifyjs. +if (process.env.NODE_ENV != 'production') { + // NOTE: in addition to parsing as JS, this snippet is expected to be valid // JSON. This assumption cannot be checked in JS, but it will be checked when // documentation is generated by the generate-documentation.py script. For the // most part, this just means that you should always use double quotes. -Dygraph.OPTIONS_REFERENCE = // +OPTIONS_REFERENCE = // { "xValueParser": { "default": "parseFloat() or Date.parse()*", @@ -831,57 +838,58 @@ Dygraph.OPTIONS_REFERENCE = // // most part, this just means that you should always use double quotes. // Do a quick sanity check on the options reference. -(function() { - "use strict"; - var warn = function(msg) { if (window.console) window.console.warn(msg); }; - var flds = ['type', 'default', 'description']; - var valid_cats = [ - 'Annotations', - 'Axis display', - 'Chart labels', - 'CSV parsing', - 'Callbacks', - 'Data', - 'Data Line display', - 'Data Series Colors', - 'Error Bars', - 'Grid', - 'Interactive Elements', - 'Range Selector', - 'Legend', - 'Overall display', - 'Rolling Averages', - 'Series', - 'Value display/formatting', - 'Zooming', - 'Debugging', - 'Configuration', - 'Deprecated' - ]; - var i; - var cats = {}; - for (i = 0; i < valid_cats.length; i++) cats[valid_cats[i]] = true; +var warn = function(msg) { if (window.console) window.console.warn(msg); }; +var flds = ['type', 'default', 'description']; +var valid_cats = [ + 'Annotations', + 'Axis display', + 'Chart labels', + 'CSV parsing', + 'Callbacks', + 'Data', + 'Data Line display', + 'Data Series Colors', + 'Error Bars', + 'Grid', + 'Interactive Elements', + 'Range Selector', + 'Legend', + 'Overall display', + 'Rolling Averages', + 'Series', + 'Value display/formatting', + 'Zooming', + 'Debugging', + 'Configuration', + 'Deprecated' +]; +var i; +var cats = {}; +for (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 (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'); - } +for (var k in OPTIONS_REFERENCE) { + if (!OPTIONS_REFERENCE.hasOwnProperty(k)) continue; + var op = OPTIONS_REFERENCE[k]; + for (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'); - } else { - for (i = 0; i < labels.length; i++) { - if (!cats.hasOwnProperty(labels[i])) { - warn('Option "' + k + '" has label "' + labels[i] + - '", which is invalid.'); - } + } + var labels = op.labels; + if (typeof(labels) !== 'object') { + warn('Option "' + k + '" is missing a "labels": [...] option'); + } else { + for (i = 0; i < labels.length; i++) { + if (!cats.hasOwnProperty(labels[i])) { + warn('Option "' + k + '" has label "' + labels[i] + + '", which is invalid.'); } } } -})(); +} + +} + +export default OPTIONS_REFERENCE;