diff --git a/flot.module b/flot.module
index 5e35cb3..9d09638 100644
--- a/flot.module
+++ b/flot.module
@@ -174,11 +174,12 @@ function template_preprocess_flot_graph(&$variables) {
       });
     ';
     drupal_add_js($jszoomdata, array('type' => 'inline', 'scope' => 'footer'));
-    $width = array();
-    preg_match('/width:(.*)px;/', $variables['element']['graph']['style'], $width);
+    $match = array();
+    preg_match('/width:(.*)px;/', $variables['element']['graph']['style'], $match);
+    $width = isset($match[1]) && $match[1] ? $match[1] . 'px' : 'auto';
     $zoom_element = array(
       'id' => $variables['element']['graph']['id'] . '-zoom',
-      'style' => 'width:' . $width[1] . 'px;height:100px',
+      'style' => 'width:' . $width . ';height:100px',
       'class' => array('flot-zoom'),
     );
   }
