diff --git a/flot.module b/flot.module
index dc9e2c7..5e35cb3 100644
--- a/flot.module
+++ b/flot.module
@@ -95,7 +95,8 @@ function template_preprocess_flot_graph(&$variables) {
   }
   $variables['options'] = $options;
   $legend_element = array();
-  if (isset($options->legend) && $options->legend->position == 'bottom' && !isset($options->legend->container)) {
+  $is_legend_set = isset($options->legend) && $options->legend !== FALSE;
+  if ($is_legend_set && $options->legend->position == 'bottom' && !isset($options->legend->container)) {
     $variables['element']['legendid'] = $variables['element']['id'] . '-legend';
     $options->legend->container = '#' . $variables['element']['legendid'];
     $options->legend->containerid = $variables['element']['legendid'];
@@ -147,7 +148,8 @@ function template_preprocess_flot_graph(&$variables) {
     $zoom_options->series->shadowSize = 0;
     $zoom_options->grid->hoverable = FALSE;
     $zoom_options->selection['mode'] = 'x';
-    $zoom_options->legend->show = FALSE;
+    !isset($zoom_options->legend) && $zoom_options->legend = new stdClass();
+    is_object($zoom_options->legend) && $zoom_options->legend->show = FALSE;
     if (isset($zoom_options->xaxis)) {
       unset($zoom_options->xaxis->min);
       unset($zoom_options->xaxis->max);
