Permalink
Browse files

FnordMetric.util.zeroFill

  • Loading branch information...
asmuth committed Mar 5, 2013
1 parent f3c3df5 commit be1dcecf79fdb20e024d49d38582e6d76a080939
Showing with 18 additions and 54 deletions.
  1. +1 −1 fnordmetric-ui/.gitignore
  2. +1 −1 fnordmetric-ui/js/fnordmetric.js
  3. +16 −1 fnordmetric-ui/js/fnordmetric.util.js
  4. +0 −51 fnordmetric-ui/test.html
@@ -1 +1 @@
-test.html
+test*
@@ -147,7 +147,7 @@ var FnordMetric = (function(pre){
if (parts[0] != "null")
for (ind in parts) {
var tuple = parts[ind].split(":");
- tuple[0] = parseInt(tuple[0], 10) / 1000;
+ tuple[0] = parseInt(parseInt(tuple[0], 10) / 1000, 10);
vals[tuple[0]] = tuple[1];
}
@@ -111,6 +111,21 @@ FnordMetric.util.parseTime = function(str) {
}
FnordMetric.util.zeroFill = function(obj) {
- console.log("FIXPAUL", obj);
+ var ticks = {};
+
+ for (key in obj)
+ for (tick in obj[key])
+ ticks[tick] = 1;
+
+ ticks = Object.keys(ticks);
+
+ if (ticks.length == 0)
+ ticks.push(0);
+
+ for (key in obj)
+ for (ind in ticks)
+ if (typeof obj[key][ticks[ind]] == 'undefined')
+ obj[key][ticks[ind]] = 0;
+
return obj;
}
View
@@ -1,51 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <title>FnordMetric</title>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
- <script src='./js/d3.fnordmetric.js' type='text/javascript'></script>
- <script src='./js/fnordmetric.js' type='text/javascript'></script>
- <script src='./js/fnordmetric.rickshaw.js' type='text/javascript'></script>
- <script src='./js/fnordmetric.util.js' type='text/javascript'></script>
- <script src='./js/fnordmetric.widgets.timeseries.js' type='text/javascript'></script>
- <script src='./js/fnordmetric.widgets.counter.js' type='text/javascript'></script>
- <link href='./css/fnordmetric.graph.css' type='text/css' rel='stylesheet' />
- <style type="text/css">
- body{ background:#111; }
- body.dark .fnordmetric_legend li.line .label{ color:#fff; }
- body.dark .fnordmetric_graph .y_grid .tick { stroke:rgba(255,255,255,.15); stroke-dasharray:0; }
- body.dark .fnordmetric_graph .y_ticks text { fill:#ffffff; }
- body.dark .fnordmetric_graph .x_tick .title { color:#ffffff; }
- </style>
- </head>
- <body class="dark">
-
- <span
- data-fnordmetric="counter"
- data-gauge="fubar-sum-10"
- data-autoupdate="1"
- data-at="-30"
- data-unit="fubar"
- style="float:left;color:#fff; font-size:24px;">0</span>
-
- <div
- data-fnordmetric="timeseries"
- data-chart-style="line"
- data-height="400"
- data-since="-10m"
- data-until="now"
- data-autoupdate="10"
- data-gauges="fubar-sum-10"
- style="float:left;width:900px; "></div>
-
- <script>
- FnordMetric.setup({
- "address": "localhost:4242",
- "namespace": "myapp"
- });
- </script>
-
- </body>
-</html>
-
-

0 comments on commit be1dcec

Please sign in to comment.