Creando Gráficas

A continuación les mostramos como crear gráficas usando Motte. Es importante recordar que para que la aplicación funcione será necesario contar con los directorios 'motte', 'cache', 'log', 'model' y 'view' dentro del directorio raíz de nuestra aplicación y revisar los permisos sobre dichos directorios.

Para que éste ejemplo funcione debe descargar Motte y colocarlo dentro del directorio ROOT de la aplicación.

/cfg.motte.php

<?php
/**
 * Basic System Configuration
 *
 * @filesource
 * @author Motte Core Team
 * @url  http://motte.codigolibre.net
 * @package TestPkg
 * @subpackage publicFrontEnd
 * @version 0.1a
 * @license http://opensource.org/licenses/gpl-license.php GNU Public license (GPLv2+)
 */
 
define('ROOT_DIR','.');
 
define('MODULE_DIR',ROOT_DIR.'/');
 
define('MOTTE', ROOT_DIR.'/motte');
define('MTE_CACHE', ROOT_DIR.'/cache');
define('MTE_CACHE_HTML', ROOT_DIR.'/cache');
define('MTE_MODEL', ROOT_DIR.'/model');
define('MTE_VIEW', ROOT_DIR.'/view');
 
include_once(MOTTE.'/motte.inc.php');
?>

/index.php

<?php
/**
 * Basic Application for creating graphics
 *
 * @filesource
 * @author Motte Core Team
 * @url  http://motte.codigolibre.net
 * @package TestPkg
 * @subpackage publicFrontEnd
 * @version 0.1a
 * @license http://opensource.org/licenses/gpl-license.php GNU Public license (GPLv2+)
 */
 
include('cfg.motte.php');
$app = new mteController();
$app->addConfig(MODULE_NAME);
 
$app->isValidUrl();
 
// Testing graphics
$grafica = new mtePlot();
$grafica->addSerie('beer');
$grafica->addPoint('beer','Gauna', 50);
$grafica->addPoint('beer','Gagliardi', 28);
$grafica->addPoint('beer','Dodero', 20);
$grafica->addPoint('beer','Erartes', 10);
$grafica->addPoint('beer','Boksar', 30);
 
$grafica->addSerie('wine');
$grafica->addPoint('wine','Gauna', 30);
$grafica->addPoint('wine','Gagliardi', 10);
$grafica->addPoint('wine','Dodero', 20);
$grafica->addPoint('wine','Erartes', 28);
$grafica->addPoint('wine','Boksar', 50);
 
$grafica->setTitle('Motte Core Team - beer drinking levels');
$grafica->setCompanyLogo(MTE_COMPANY_LOGO);
$grafica->createChart(mteConst::MTE_GRAPH_VERTICALBAR, 'beer', MTE_CACHE.'/mte_beer_HB.png',600, 250);
$grafica->createChart(mteConst::MTE_GRAPH_HORIZONTALBAR, 'beer', MTE_CACHE.'/mte_beer_VB.png', 600, 250);
$grafica->createChart(mteConst::MTE_GRAPH_PIE, 'beer', MTE_CACHE.'/mte_beer_PIE.png',  600, 250);
$grafica->createChart(mteConst::MTE_GRAPH_LINE, 'beer', MTE_CACHE.'/mte_beer_LINE.png', 600, 250);
$grafica->setTitle('Motte Core Team - wine drinking levels');
$grafica->createChart(mteConst::MTE_GRAPH_VERTICALBAR, 'wine', MTE_CACHE.'/mte_wine_HB.png',600, 250);
$grafica->createChart(mteConst::MTE_GRAPH_HORIZONTALBAR, 'wine', MTE_CACHE.'/mte_wine_VB.png', 600, 250);
$grafica->createChart(mteConst::MTE_GRAPH_PIE, 'wine', MTE_CACHE.'/mte_wine_PIE.png',  600, 250);
$grafica->createChart(mteConst::MTE_GRAPH_LINE, 'wine', MTE_CACHE.'/mte_wine_LINE.png', 600, 250);
$grafica->setTitle('Motte Core Team - drinking levels');
$grafica->createChart(mteConst::MTE_GRAPH_VERTICALBAR, array('beer','wine'), MTE_CACHE.'/mte_drinks_HB.png',600, 250);
$grafica->createChart(mteConst::MTE_GRAPH_HORIZONTALBAR, array('beer','wine'), MTE_CACHE.'/mte_drinks_VB.png', 600, 250);
$grafica->createChart(mteConst::MTE_GRAPH_LINE, array('beer','wine'), MTE_CACHE.'/mte_drinks_LINE.png', 600, 250);
 
$htmlDinamico .= '<img src="'.MTE_CACHE.'/mte_beer_HB.png'.'" alt="motte" /><br><hr><br>';
$htmlDinamico .= '<img src="'.MTE_CACHE.'/mte_beer_VB.png'.'" alt="motte" /><br><hr><br>';
$htmlDinamico .= '<img src="'.MTE_CACHE.'/mte_beer_PIE.png'.'" alt="motte" /><br><hr><br>';
$htmlDinamico .= '<img src="'.MTE_CACHE.'/mte_beer_LINE.png'.'" alt="motte" /><br><hr><br>';
$htmlDinamico .= '<img src="'.MTE_CACHE.'/mte_wine_HB.png'.'" alt="motte" /><br><hr><br>';
$htmlDinamico .= '<img src="'.MTE_CACHE.'/mte_wine_VB.png'.'" alt="motte" /><br><hr><br>';
$htmlDinamico .= '<img src="'.MTE_CACHE.'/mte_wine_PIE.png'.'" alt="motte" /><br><hr><br>';
$htmlDinamico .= '<img src="'.MTE_CACHE.'/mte_wine_LINE.png'.'" alt="motte" /><br><hr><br>';
$htmlDinamico .= '<img src="'.MTE_CACHE.'/mte_drinks_HB.png'.'" alt="motte" /><br><hr><br>';
$htmlDinamico .= '<img src="'.MTE_CACHE.'/mte_drinks_VB.png'.'" alt="motte" /><br><hr><br>';
$htmlDinamico .= '<img src="'.MTE_CACHE.'/mte_drinks_LINE.png'.'" alt="motte" /><br><hr><br>';
 
$pag = $app->generateHtmlPage();
$pag->setContent($htmlDinamico);
$pag->showHtml();
?>

Ejemplos de las gráficas generadas

Grafica de consumo de cerveza por los desarrolladores

Grafica de consumo de vino por los desarrolladores

Grafica de consumo de bebidas por los desarrolladores

documentacion/ejemplos/graficas.txt · Última modificación: 2009/11/24 11:22 (editor externo)
Recent changes RSS feed Creative Commons License Donate Driven by DokuWiki

Valid XHTML 1.0 Strict