Commits

Ralph Bean committed aa29e02

Protect against division by zero.

Comments (0)

Files changed (2)

 
 setup(
     name='tw2.protovis.custom',
-    version='0.1.a5',
+    version='0.1.a6',
     description='toscawidgets2 wrapper for the stanford protovis toolkit',
     long_description=long_description,
     author='Ralph Bean',

tw2/protovis/custom/widgets.py

     p_margin = twc.Param("Integer margin between bars.", default=1)
 
     def prepare(self):
-        outer_dw = math.floor(self.p_width / len(self.p_data))
-        inner_dw = outer_dw - self.p_margin
+        outer_dw, inner_dw = 1, 1
+        if self.p_data:
+            outer_dw = math.floor(self.p_width / len(self.p_data))
+            inner_dw = outer_dw - self.p_margin
 
         self.init_js = js(
             """