html5 boiler plate
[scannr.git] / js / flotr2 / examples / js / examples / basic-bars.js
blob:a/js/flotr2/examples/js/examples/basic-bars.js -> blob:b/js/flotr2/examples/js/examples/basic-bars.js
--- a/js/flotr2/examples/js/examples/basic-bars.js
+++ b/js/flotr2/examples/js/examples/basic-bars.js
@@ -1,1 +1,69 @@
+(function () {
 
+Flotr.ExampleList.add({
+  key : 'basic-bars',
+  name : 'Basic Bars',
+  callback : basic_bars
+});
+
+Flotr.ExampleList.add({
+  key : 'basic-bars-horizontal',
+  name : 'Horizontal Bars',
+  args : [true],
+  callback : basic_bars,
+  tolerance : 5
+});
+
+function basic_bars (container, horizontal) {
+
+  var
+    horizontal = (horizontal ? true : false), // Show horizontal bars
+    d1 = [],                                  // First data series
+    d2 = [],                                  // Second data series
+    point,                                    // Data point variable declaration
+    i;
+
+  for (i = 0; i < 4; i++) {
+
+    if (horizontal) { 
+      point = [Math.ceil(Math.random()*10), i];
+    } else {
+      point = [i, Math.ceil(Math.random()*10)];
+    }
+
+    d1.push(point);
+        
+    if (horizontal) { 
+      point = [Math.ceil(Math.random()*10), i+0.5];
+    } else {
+      point = [i+0.5, Math.ceil(Math.random()*10)];
+    }
+
+    d2.push(point);
+  };
+              
+  // Draw the graph
+  Flotr.draw(
+    container,
+    [d1, d2],
+    {
+      bars : {
+        show : true,
+        horizontal : horizontal,
+        shadowSize : 0,
+        barWidth : 0.5
+      },
+      mouse : {
+        track : true,
+        relative : true
+      },
+      yaxis : {
+        min : 0,
+        autoscaleMargin : 1
+      }
+    }
+  );
+}
+
+})();
+