<?php
/**
 * @file morris.module
 * 
 * @author Adrian Rollett
 */

function morris_example_block_info() {
  $blocks = array();

  $blocks['morris_example'] = array(
    'info' => t('Morris Example'),
  );

  return $blocks;
}

function morris_example_block_view($delta = '') {
  //The $delta parameter tells us which block is being requested.
  switch ($delta) {
    case 'morris_example':
      // The subject is displayed at the top of the block. Note that it
      // should be passed through t() for translation. The title configured
      // for the block using Drupal UI supercedes this one.
      $block['subject'] = t('Example Morris Graph');
      // The content of the block is typically generated by calling a custom
      // function.
      $block['content'] = morris_example_block_generate();
      break;
  }
  return $block;
}

function morris_example_block_generate() {
  $test = new Morris();
  $test->setData(array(2001, 2002), array(array(1, 2), array(4, 5)));
  $test->display();
  $content = '<div style="height: 150px; width: 280px;" id="morris" />';
  return $content;
}
