<?php
/**
 * @version		$Id: view.html.php 143 2009-06-25 11:37:24Z eddieajau $
 * @copyright	Copyright (C) 2009 New Life in IT Pty Ltd. All rights reserved.
 * @license		GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
 * @link		http://www.theartofjoomla.com
 */

// no direct access
defined('_JEXEC') or die;

jimport('joomla.application.component.view');

/**
 * @package		TAOJ.Quanta
 * @subpackage	com_quanta
 */
class QuantaViewScatter extends JView
{
	protected $state;
	protected $item;
	protected $items;
	protected $pagination;

	/**
	 * Display the view
	 */
	public function display($tpl = null)
	{
		$state		= $this->get('State');
		$record		= $this->get('Item');
		$points		= $this->get('Items');
		$pagination	= $this->get('Pagination');

		// Check for errors.
		if (count($errors = $this->get('Errors'))) {
			JError::raiseError(500, implode("\n", $errors));
			return false;
		}

		// Create the reverse lookup on record id.
		$sets = array();
		$sets[$record->id] = &$record;

		// Load the chart class.
		JLoader::import('chart.scatter', JPATH_QUANTA.DS.'libraries');

		// Inital the chart, data and parameters.
		$chart = new JChartScatter($points, $state->params, $sets);

		// Set the chart sub-type.
		//$chart->setSubType($this->params->get('chart-subtype'));
		$chart->setSubType('Line');

		$this->assignRef('state',		$state);
		$this->assignRef('record',		$record);
		$this->assignRef('points',		$points);
		$this->assignRef('chart',		$chart);
		$this->assignRef('pagination',	$pagination);

		parent::display($tpl);

		$this->_prepareDocument();
	}

	/**
	 * Prepares the metadata in the document.
	 */
	protected function _prepareDocument()
	{
	}
}