From 57539c89e29a1e45a6d1000ebe53c496eb88a61b Mon Sep 17 00:00:00 2001 From: Russell Valentine Date: Wed, 18 Jan 2012 23:50:13 -0600 Subject: [PATCH] Comment wording changes. Added default string stroke patterns object to allow for more code reuse. --- dygraph-canvas.js | 13 ++++--------- dygraph-utils.js | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/dygraph-canvas.js b/dygraph-canvas.js index 51b61168f..7975e7aff 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -840,15 +840,10 @@ DygraphCanvasRenderer.prototype._renderLineChart = function() { prevY = null; var drawPoints = this.dygraph_.attr_("drawPoints", setName); var strokePattern = this.dygraph_.attr_("strokePattern", setName); - if (strokePattern === 'solid') { - strokePattern = null; - } else if (strokePattern === 'dashed') { - strokePattern = [7, 3]; - } else if (strokePattern === 'dotted') { - strokePattern = [2, 2]; - } else if (strokePattern === 'dashdotted') { - strokePattern = [7, 2, 2, 2]; - } else if (strokePattern && !strokePattern.length) { + if (typeof(strokePattern) === "string") { + // replace string with array pattern + strokePattern = Dygraph.DEFAULT_STROKE_PATTERNS[strokePattern]; + } else if (!Dygraph.isArrayLike(strokePattern)) { strokePattern = null; } for (j = firstIndexInSet; j < afterLastIndexInSet; j++) { diff --git a/dygraph-utils.js b/dygraph-utils.js index 7241bb460..772f5bf40 100644 --- a/dygraph-utils.js +++ b/dygraph-utils.js @@ -35,6 +35,17 @@ Dygraph.ERROR = 3; // https://github.com/eriwen/javascript-stacktrace Dygraph.LOG_STACK_TRACES = false; +/** + * The stroke patterns arrays for the string stroke patterns. + * @private + */ +Dygraph.DEFAULT_STROKE_PATTERNS = { + solid: null, + dashed: [7,3], + dotted: [2, 2], + dashdotted: [7, 2, 2, 2] +}; + /** * @private * Log an error on the JS console at the given severity. @@ -777,11 +788,11 @@ Dygraph.isPixelChangingOptionList = function(labels, attrs) { }; /** - * Compares two arrays to see if they are equal. If any of the parameters are - * not arrays it will return false. - * @param array1 First array + * Compares two arrays to see if they are equal. If either parameter is not an + * array it will return false. + * @param array1 first array * @param array2 second array - * @return True if all parameters are arrays and contents are equal. + * @return True if both parameters are arrays, and contents are equal. */ Dygraph.compareArrays = function(array1, array2) { if (!Dygraph.isArrayLike(array1) || !Dygraph.isArrayLike(array2)) {