Commits

Ralph Bean committed d84ff71

Added protovis line chart

Comments (0)

Files changed (2)

tw2/rrd/samples.py

         data_directory + '/cpu_wio.rrd',
     ]
 
+class DemoRRDLineChart(tw2.rrd.RRDLineChart):
+    rrd_filenames = [
+        data_directory + '/cpu_user.rrd',
+        data_directory + '/cpu_system.rrd',
+        data_directory + '/cpu_wio.rrd',
+    ]
+
 class DemoRRDStreamGraph(tw2.rrd.RRDStreamGraph):
-    steps = 10
     logarithmic = True
     rrd_filenames = [
         data_directory + '/cpu_user.rrd',

tw2/rrd/widgets.py

 import tw2.core.util as util
 import tw2.jqplugins.flot as flot
 import tw2.protovis.custom
+import tw2.protovis.conventional
 
 import pyrrd.rrd
 
         self.data = self.fetch()
         super(RRDFlotWidget, self).prepare()
 
+class RRDLineChart(tw2.protovis.conventional.LineChart, RRDMixin):
+    p_data = twc.Variable("Internally produced")
+    p_labels = twc.Variable("Internally produced")
+
+    p_time_series = True
+    p_time_series_format = "%b %Y"
+
+    def prepare(self):
+        data = self.fetch()
+        self.p_labels = [d['label'] for d in data]
+        self.p_data = [
+            [
+                {
+                    'x': int(d[0]),
+                    'y': d[1],
+                } for d in series['data']
+            ] for series in data
+        ]
+        print self.p_data[0][0]
+        super(RRDLineChart, self).prepare()
+
 class RRDStreamGraph(tw2.protovis.custom.StreamGraph, RRDMixin):
     """ TODO -- this guy needs a lot of work until he looks cool. """
+
     p_data = twc.Variable("Internally produced")
     logarithmic = twc.Param("Logscale?  Boolean!", default=False)