Add a simple Usage Gallery to the dygraphs home page.
[dygraphs.git] / dygraph-utils.js
index a391190..3d77148 100644 (file)
@@ -44,16 +44,18 @@ Dygraph.log = function(severity, message) {
   if (typeof(printStackTrace) != 'undefined') {
     // Remove uninteresting bits: logging functions and paths.
     var st = printStackTrace({guess:false});
-    while (st[0].indexOf("Function.log") != 0) {
+    while (st[0].indexOf("stacktrace") != -1) {
       st.splice(0, 1);
     }
+
     st.splice(0, 2);
     for (var i = 0; i < st.length; i++) {
-      st[i] = st[i].replace(/\([^)]*\/(.*)\)/, '($1)')
+      st[i] = st[i].replace(/\([^)]*\/(.*)\)/, '@$1')
           .replace(/\@.*\/([^\/]*)/, '@$1')
           .replace('[object Object].', '');
     }
-    message += ' (' + st.splice(0, 1) + ')';
+    var top_msg = st.splice(0, 1)[0];
+    message += ' (' + top_msg.replace(/^.*@ ?/, '') + ')';
   }
 
   if (typeof(console) != 'undefined') {
@@ -463,6 +465,11 @@ Dygraph.binarySearch = function(val, arry, abs, low, high) {
 Dygraph.dateParser = function(dateStr) {
   var dateStrSlashed;
   var d;
+
+  // Let the system try the format first.
+  d = Dygraph.dateStrToMillis(dateStr);
+  if (d && !isNaN(d)) return d;
+
   if (dateStr.search("-") != -1) {  // e.g. '2009-7-12' or '2009-07-12'
     dateStrSlashed = dateStr.replace("-", "/", "g");
     while (dateStrSlashed.search("-") != -1) {
@@ -616,6 +623,15 @@ Dygraph.createCanvas = function() {
 
 /**
  * @private
+ * Checks whether the user is on an Android browser.
+ * Android does not fully support the <canvas> tag, e.g. w/r/t/ clipping.
+ */
+Dygraph.isAndroid = function() {
+  return /Android/.test(navigator.userAgent);
+};
+
+/**
+ * @private
  * Call a function N times at a given interval, then call a cleanup function
  * once. repeat_fn is called once immediately, then (times - 1) times
  * asynchronously. If times=1, then cleanup_fn() is also called synchronously.