Skip to content

Commit

Permalink
Comment wording changes. Added default string stroke patterns object …
Browse files Browse the repository at this point in the history
…to allow for more code reuse.
  • Loading branch information
bluthen committed Jan 19, 2012
1 parent de28662 commit 57539c8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
13 changes: 4 additions & 9 deletions dygraph-canvas.js
Expand Up @@ -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++) {
Expand Down
19 changes: 15 additions & 4 deletions dygraph-utils.js
Expand Up @@ -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.
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 57539c8

Please sign in to comment.