diff --git a/flot.module b/flot.module
index 5e6f782..42322b6 100644
--- a/flot.module
+++ b/flot.module
@@ -84,18 +84,18 @@ function template_preprocess_flot_graph(&$variables) {
   if (isset($variables['legend']) && $variables['legend']) {
     if (!isset($options->legend)) {
       // Default position bottom
-      $options->legend->show = TRUE;
-      $options->legend->position = 'ne';
+      $options->legend['show'] = TRUE;
+      $options->legend['position'] = 'ne';
     }
     else {
-      $options->legend->show = TRUE;
-      if (!isset($options->legend->position)) {
-        $options->legend->position = 'ne';
+      $options->legend['show'] = TRUE;
+      if (!isset($options->legend['position'])) {
+        $options->legend['position'] = 'ne';
       }
     }
   }
   else {
-    $options->legend->show = FALSE;
+    $options->legend['show'] = FALSE;
   }
   $variables['options'] = $options;
   $legend_element = array();
