From: Dan Vanderkam Date: Thu, 29 Aug 2013 03:39:23 +0000 (-0400) Subject: 100 warnings X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=ed811dc4a5bc6ee6da8d393f2430a151d49483bd;p=dygraphs.git 100 warnings --- diff --git a/dygraph-canvas.js b/dygraph-canvas.js index 91d78c7..53eed63 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -503,12 +503,12 @@ linePlotter_ = function(e) { // TODO(danvk): Check if there's any performance impact of just calling // getOption() inside of drawStyledLine_. Passing in so many parameters makes // this code a bit nasty. - var borderWidth = g.getOption("strokeBorderWidth", setName); + var borderWidth = g.getNumericOption("strokeBorderWidth", setName); var drawPointCallback = g.getOption("drawPointCallback", setName) || Dygraph.Circles.DEFAULT; var strokePattern = g.getOption("strokePattern", setName); - var drawPoints = g.getOption("drawPoints", setName); - var pointSize = g.getOption("pointSize", setName); + var drawPoints = g.getBooleanOption("drawPoints", setName); + var pointSize = g.getNumericOption("pointSize", setName); if (borderWidth && strokeWidth) { drawStyledLine_(e, diff --git a/dygraph-externs.js b/dygraph-externs.js index 08af6f5..e2153ae 100644 --- a/dygraph-externs.js +++ b/dygraph-externs.js @@ -105,7 +105,7 @@ var DygraphAxisType; /** * @typedef {{ * dygraph: !Dygraph, - * points: Array, + * points: !Array, * setName: string, * drawingContext: !CanvasRenderingContext2D, * color: string, diff --git a/dygraph.js b/dygraph.js index 4d4f6c3..b5a50a2 100644 --- a/dygraph.js +++ b/dygraph.js @@ -654,6 +654,36 @@ Dygraph.prototype.getOptionForAxis = function(name, axis) { }; /** +// This is a convenience function for working with the Closure Compiler. + * @param {string} name The name of the option (e.g. 'strokeWidth') + * @param {string=} opt_seriesName Series name to get per-series values. + * @return {number} The value of the option. + */ +Dygraph.prototype.getNumericOption = function(name, opt_seriesName) { + return /** @type{number} */(this.getOption(name, opt_seriesName)); +} + +/** +// This is a convenience function for working with the Closure Compiler. + * @param {string} name The name of the option (e.g. 'strokeWidth') + * @param {string=} opt_seriesName Series name to get per-series values. + * @return {string} The value of the option. + */ +Dygraph.prototype.getStringOption = function(name, opt_seriesName) { + return /** @type{string} */(this.getOption(name, opt_seriesName)); +} + +/** +// This is a convenience function for working with the Closure Compiler. + * @param {string} name The name of the option (e.g. 'strokeWidth') + * @param {string=} opt_seriesName Series name to get per-series values. + * @return {boolean} The value of the option. + */ +Dygraph.prototype.getBoolOption = function(name, opt_seriesName) { + return /** @type{boolean} */(this.getOption(name, opt_seriesName)); +} + +/** * @private * @param {string} axis The name of the axis (i.e. 'x', 'y' or 'y2') * @return {function(string)} A function mapping string -> option value @@ -2625,7 +2655,7 @@ Dygraph.prototype.computeYAxes_ = function() { /** * Returns the number of y-axes on the chart. - * @return {Number} the number of axes. + * @return {number} the number of axes. */ Dygraph.prototype.numAxes = function() { return this.attributes_.numAxes(); @@ -2634,9 +2664,9 @@ Dygraph.prototype.numAxes = function() { /** * @private * Returns axis properties for the given series. - * @param { String } setName The name of the series for which to get axis + * @param {string} setName The name of the series for which to get axis * properties, e.g. 'Y1'. - * @return { Object } The axis properties. + * @return {DygraphAxisType} The axis properties. */ Dygraph.prototype.axisPropertiesForSeries = function(series) { // TODO(danvk): handle errors.