Support highlightSeriesOpts, and, standardize on field names.
[dygraphs.git] / dygraph-utils.js
index 707bbca..04d2ae3 100644 (file)
@@ -1080,3 +1080,30 @@ Dygraph.IFrameTarp.prototype.uncover = function() {
   }
   this.tarps = [];
 };
+
+/**
+ * Determine whether |data| is delimited by CR, CRLF, LF, LFCR.
+ * @param {string} data
+ * @return {string|null} the delimiter that was detected.
+ */
+Dygraph.detectLineDelimiter = function(data) {
+  for (var i = 0; i < data.length; i++) {
+    var code = data.charAt(i);
+    if (code === '\r') {
+      // Might actually be "\r\n".
+      if (((i + 1) < data.length) && (data.charAt(i + 1) === '\n')) {
+        return '\r\n';
+      }
+      return code;
+    }
+    if (code === '\n') {
+      // Might actually be "\n\r".
+      if (((i + 1) < data.length) && (data.charAt(i + 1) === '\r')) {
+        return '\n\r';
+      }
+      return code;
+    }
+  }
+
+  return null;
+};