X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=src%2Fdygraph-options-reference.js;h=4b1a23bf6dfd9e32a67c55a341945566b6050bfb;hb=401ff9f17c622f3173cc8d34cfcf3e444620d7d0;hp=933bdab558e14bf80bfe12a615c68086951b8672;hpb=7bf909a7b076b5296734a6222e62ed1084e9c935;p=dygraphs.git diff --git a/src/dygraph-options-reference.js b/src/dygraph-options-reference.js index 933bdab..4b1a23b 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()*", @@ -157,6 +164,12 @@ Dygraph.OPTIONS_REFERENCE = // "type": "float", "description": "Fade the background while highlighting series. 1=fully visible background (disable fading), 0=hiddden background (show highlighted series only)." }, + "highlightSeriesBackgroundColor": { + "default": "rgb(255, 255, 255)", + "labels": ["Interactive Elements"], + "type": "string", + "description": "Sets the background color used to fade out the series in conjunction with 'highlightSeriesBackgroundAlpha'." + }, "includeZero": { "default": "false", "labels": ["Axis display"], @@ -450,6 +463,15 @@ Dygraph.OPTIONS_REFERENCE = // "type": "string", "description": "When to display the legend. By default, it only appears when a user mouses over the chart. Set it to \"always\" to always display a legend of some sort. When set to \"follow\", legend follows highlighted points." }, + "legendFormatter": { + "default": "null", + "labels": ["Legend"], + "type": "function(data): string", + "params": [ + [ "data", "An object containing information about the selection (or lack of a selection). This includes formatted values and series information. See here for sample values." ] + ], + "description": "Set this to supply a custom formatter for the legend. See this comment and the legendFormatter demo for usage." + }, "labelsShowZeroValues": { "default": "true", "labels": ["Legend"], @@ -831,57 +853,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;