import Dygraph from '../../src/dygraph';
import DygraphOptions from '../../src/dygraph-options';
+import OPTIONS_REFERENCE from '../../src/dygraph-options-reference';
describe("dygraph-options-tests", function() {
};
it('testLogWarningForNonexistentOption', function() {
- if (typeof(Dygraph.OPTIONS_REFERENCE) === 'undefined') {
+ if (!OPTIONS_REFERENCE) {
return; // this test won't pass in non-debug mode.
}
});
it('testOnlyLogsEachWarningOnce', function() {
- if (typeof(Dygraph.OPTIONS_REFERENCE) === 'undefined') {
+ if (!OPTIONS_REFERENCE) {
return; // this test won't pass in non-debug mode.
}
--- /dev/null
+#!/bin/bash
+browserify \
+ -v \
+ -t babelify \
+ -t [ envify --NODE_ENV production ] \
+ --debug \
+ --standalone Dygraph \
+ src/dygraph.js \
+ | uglifyjs -c -m \
+ > dist/dygraph.js
"chai": "^3.3.0",
"closure-compiler": "^0.2.6",
"coveralls": "^2.11.2",
+ "envify": "^3.4.0",
+ "exorcist": "^0.4.0",
"gulp": "^3.8.10",
"gulp-concat": "^2.4.3",
"gulp-eslint": "^0.2.0",
"phantomjs": "^1.9.7-8",
"pre-commit": "^1.0.6",
"source-map": "^0.4.2",
- "uglify-js": "^2",
+ "uglify-js": "^2.5.0",
"watchify": "^3.4.0"
},
"scripts": {
* 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 = // <JSON>
+OPTIONS_REFERENCE = // <JSON>
{
"xValueParser": {
"default": "parseFloat() or Date.parse()*",
// 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;
// TODO: remove this jshint directive & fix the warnings.
/*jshint sub:true */
-/*global Dygraph:false */
"use strict";
import * as utils from './dygraph-utils';
import DEFAULT_ATTRS from './dygraph-default-attrs';
+import OPTIONS_REFERENCE from './dygraph-options-reference';
/*
* Interesting member variables: (REMOVING THIS LIST AS I CLOSURIZE)
}
utils.update(this.xAxis_.options, axis_opts["x"] || {});
- // if (DEBUG) this.validateOptions_();
+ // For "production" code, this gets removed by uglifyjs.
+ if (process.env.NODE_ENV != 'production') {
+ this.validateOptions_();
+ }
};
/**
return this.labels_;
};
-// TODO: fix this
-// if (DEBUG) {
-if (false) {
+// For "production" code, this gets removed by uglifyjs.
+if (process.env.NODE_ENV != 'production') {
/**
* Validate all options.
- * This requires Dygraph.OPTIONS_REFERENCE, which is only available in debug builds.
+ * This requires OPTIONS_REFERENCE, which is only available in debug builds.
* @private
*/
DygraphOptions.prototype.validateOptions_ = function() {
- if (typeof Dygraph.OPTIONS_REFERENCE === 'undefined') {
+ if (typeof OPTIONS_REFERENCE === 'undefined') {
throw 'Called validateOptions_ in prod build.';
}
var that = this;
var validateOption = function(optionName) {
- if (!Dygraph.OPTIONS_REFERENCE[optionName]) {
+ if (!OPTIONS_REFERENCE[optionName]) {
that.warnInvalidOption_(optionName);
}
};
*/
-// For "production" code, this gets set to false by uglifyjs.
-// if (typeof(DEBUG) === 'undefined') DEBUG=true;
-var DEBUG = true;
-
import DygraphLayout from './dygraph-layout';
import DygraphCanvasRenderer from './dygraph-canvas';
import DygraphOptions from './dygraph-options';
import * as DygraphTickers from './dygraph-tickers';
import * as utils from './dygraph-utils';
import DEFAULT_ATTRS from './dygraph-default-attrs';
+import OPTIONS_REFERENCE from './dygraph-options-reference';
import DefaultHandler from './datahandler/default';
import ErrorBarsHandler from './datahandler/bars-error';
import GVizChart from './dygraph-gviz';
-/*global DygraphLayout:false, DygraphCanvasRenderer:false, DygraphOptions:false, G_vmlCanvasManager:false,ActiveXObject:false */
"use strict";
/**
* @return { ... } The value of the option.
*/
Dygraph.prototype.attr_ = function(name, seriesName) {
- // if (DEBUG) {
- // if (typeof(Dygraph.OPTIONS_REFERENCE) === 'undefined') {
- // console.error('Must include options reference JS for testing');
- // } else if (!Dygraph.OPTIONS_REFERENCE.hasOwnProperty(name)) {
- // console.error('Dygraphs is using property ' + name + ', which has no ' +
- // 'entry in the Dygraphs.OPTIONS_REFERENCE listing.');
- // // Only log this error once.
- // Dygraph.OPTIONS_REFERENCE[name] = true;
- // }
- // }
+ // For "production" code, this gets removed by uglifyjs.
+ if (process.env.NODE_ENV != 'production') {
+ if (typeof(OPTIONS_REFERENCE) === 'undefined') {
+ console.error('Must include options reference JS for testing');
+ } else if (!OPTIONS_REFERENCE.hasOwnProperty(name)) {
+ console.error('Dygraphs is using property ' + name + ', which has no ' +
+ 'entry in the Dygraphs.OPTIONS_REFERENCE listing.');
+ // Only log this error once.
+ OPTIONS_REFERENCE[name] = true;
+ }
+ }
return seriesName ? this.attributes_.getForSeries(name, seriesName) : this.attributes_.get(name);
};
--- /dev/null
+#!/bin/bash
+watchify \
+ -v \
+ -t babelify \
+ -t [ envify --NODE_ENV development ] \
+ --debug \
+ --standalone Dygraph \
+ -o dist/dygraph.js \
+ src/dygraph.js
+#!/bin/bash
watchify \
- -v -t babelify \
+ -v \
+ -t babelify \
+ -t [ envify --NODE_ENV development ] \
--debug \
-o dist/tests.js \
- auto_tests/tests/sanity.js \
- auto_tests/tests/pathological_cases.js \
- auto_tests/tests/axis_labels.js \
- auto_tests/tests/annotations.js \
- auto_tests/tests/callback.js \
- auto_tests/tests/connect_separated_points.js \
- auto_tests/tests/fill_step_plot.js \
- auto_tests/tests/custom_bars.js \
- auto_tests/tests/css.js \
- auto_tests/tests/data_api.js \
- auto_tests/tests/date_formats.js \
- auto_tests/tests/date_ticker.js \
- auto_tests/tests/error_bars.js \
- auto_tests/tests/dygraph-options-tests.js \
- auto_tests/tests/fast_canvas_proxy.js \
- auto_tests/tests/formats.js \
- auto_tests/tests/hidpi.js \
- auto_tests/tests/interaction_model.js \
- auto_tests/tests/missing_points.js \
- auto_tests/tests/multi_csv.js \
-
-
-cat <<END
-auto_tests/tests/multiple_axes.js \
-auto_tests/tests/no_hours.js \
-auto_tests/tests/numeric_ticker.js \
-auto_tests/tests/parser.js \
-auto_tests/tests/per_axis.js \
-auto_tests/tests/per_series.js \
-auto_tests/tests/plugins.js \
-auto_tests/tests/plugins_legend.js \
-auto_tests/tests/range_selector.js \
-auto_tests/tests/range_tests.js \
-auto_tests/tests/resize.js \
-auto_tests/tests/rolling_average.js \
-auto_tests/tests/scientific_notation.js \
-auto_tests/tests/scrolling_div.js \
-auto_tests/tests/selection.js \
-auto_tests/tests/simple_drawing.js \
-auto_tests/tests/smooth_plotter.js \
-auto_tests/tests/stacked.js \
-auto_tests/tests/step_plot_per_series.js \
-auto_tests/tests/synchronize.js \
-auto_tests/tests/to_dom_coords.js \
-auto_tests/tests/two_digit_years.js \
-auto_tests/tests/update_options.js \
-auto_tests/tests/update_while_panning.js \
-auto_tests/tests/utils_test.js \
-auto_tests/tests/axis_labels-deprecated.js \
-auto_tests/tests/visibility.js
-auto_tests/tests/gviz.js \
-END > /dev/null
-
-
-# These ones are going to be hard
-cat <<END
-# There are differences between how installPattern and setLineDash work:
-auto_tests/tests/grid_per_axis.js
-END > /dev/null
+ auto_tests/tests/*.js