[Piwik-svn] r196 - in trunk: config libs/open-flash-chart misc modules modules/DataTable modules/LogStats modules/ViewDataTable modules/Visualization plugins/Home plugins/Home/templates
svnmaster at piwik.org
svnmaster at piwik.org
Sat Jan 19 16:41:52 CET 2008
Author: matt
Date: 2008-01-19 16:41:52 +0100 (Sat, 19 Jan 2008)
New Revision: 196
Added:
trunk/modules/Visualization/ChartEvolution.php
Removed:
trunk/libs/open-flash-chart/php-ofc-library/
Modified:
trunk/config/global.ini.php
trunk/misc/generateVisits.php
trunk/modules/DataTable/Array.php
trunk/modules/DataTable/Simple.php
trunk/modules/LogStats/Generator.php
trunk/modules/ViewDataTable.php
trunk/modules/ViewDataTable/Cloud.php
trunk/modules/ViewDataTable/GenerateGraphData.php
trunk/modules/ViewDataTable/Graph.php
trunk/modules/ViewDataTable/Html.php
trunk/modules/Visualization/Chart.php
trunk/modules/Visualization/OpenFlashChart.php
trunk/plugins/Home/Controller.php
trunk/plugins/Home/templates/cloud.tpl
trunk/plugins/Home/templates/datatable.tpl
trunk/plugins/Home/templates/datatable_actions.tpl
trunk/plugins/Home/templates/graph.tpl
trunk/plugins/Home/templates/index.tpl
Log:
- updated open flash chart
- added evolution chart!!!! http://piwik.org/demo
Modified: trunk/config/global.ini.php
===================================================================
--- trunk/config/global.ini.php 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/config/global.ini.php 2008-01-19 15:41:52 UTC (rev 196)
@@ -48,7 +48,7 @@
[Debug]
; if set to true, the archiving process will always be triggered, even if the archive has already been computed
; this is useful when making changes to the archiving code so we can
-always_archive_data = true
+always_archive_data = false
[General]
; Time in seconds after which an archive will be computed again.
Modified: trunk/misc/generateVisits.php
===================================================================
--- trunk/misc/generateVisits.php 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/misc/generateVisits.php 2008-01-19 15:41:52 UTC (rev 196)
@@ -52,13 +52,13 @@
* Generate visits / actions for the last 31 days
*/
-$daysToCompute = 10;
+$daysToCompute = 1;
// do NOT edit this line
$startTime = time() - ($daysToCompute-1)*86400;
while($startTime <= time())
{
- $visits = rand(1,20);
+ $visits = rand(10,20);
$actions=10;
// $actions = 10;
// $visits = rand(10,30);
Modified: trunk/modules/DataTable/Array.php
===================================================================
--- trunk/modules/DataTable/Array.php 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/modules/DataTable/Array.php 2008-01-19 15:41:52 UTC (rev 196)
@@ -28,6 +28,10 @@
$this->nameKey = $name;
}
+ public function getRowsCount()
+ {
+ return count($this->array);
+ }
public $metaData = array();
public function setMetaData( $mixed )
{
Modified: trunk/modules/DataTable/Simple.php
===================================================================
--- trunk/modules/DataTable/Simple.php 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/modules/DataTable/Simple.php 2008-01-19 15:41:52 UTC (rev 196)
@@ -38,7 +38,7 @@
* 'Label row 1' => Value row 1,
* 'Label row 2' => Value row 2,
* )
- */
+ */
function loadFromArray($array)
{
foreach($array as $label => $value)
@@ -50,9 +50,15 @@
}
}
+
function getColumn( $label )
{
- return $this->getRowFromLabel($label)->getColumn('value');
+ $row = $this->getRowFromLabel($label);
+ if($row === false)
+ {
+ return false;
+ }
+ return $row->getColumn('value');
}
}
Modified: trunk/modules/LogStats/Generator.php
===================================================================
--- trunk/modules/LogStats/Generator.php 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/modules/LogStats/Generator.php 2008-01-19 15:41:52 UTC (rev 196)
@@ -181,6 +181,7 @@
return (float) $sec + ((float) $usec * 100000);
}
mt_srand(make_seed());
+
$common = array(
'res' => array('1289x800','1024x768','800x600','564x644','200x100','50x2000',),
'col' => array(24,32,16),
@@ -268,7 +269,7 @@
*
* We even set the _SERVER values
*/
- private function generateNewVisit()
+ protected function generateNewVisit()
{
$this->setCurrentRequest( 'urlref' , $this->getRandom('urlref'));
$this->setCurrentRequest( 'idsite', $this->getRandom('idsite'));
@@ -297,7 +298,7 @@
* download or outlink clicks, etc.
*
*/
- private function generateActionVisit()
+ protected function generateActionVisit()
{
// we don't keep the previous action values
// reinit them to empty string
@@ -372,7 +373,7 @@
* Returns a random URL using the $host as the URL host.
* Depth level depends on @see setMaximumUrlDepth()
*/
- private function getRandomUrlFromHost( $host )
+ protected function getRandomUrlFromHost( $host )
{
$url = $host;
@@ -398,7 +399,7 @@
*
* @return string The generated random string
*/
- private function getRandomString($maxLength = 15, $minLength = 5, $type = 'ALL')
+ protected function getRandomString($maxLength = 15, $minLength = 5, $type = 'ALL')
{
$len = mt_rand($minLength, $maxLength);
@@ -463,7 +464,7 @@
/**
* Set the _GET and _REQUEST superglobal to the current generated array of values
*/
- private function setFakeRequest()
+ protected function setFakeRequest()
{
$_REQUEST = $_GET = $this->currentget;
}
@@ -474,7 +475,7 @@
* @param string Name of the parameter to set
* @param string Value of the parameter
*/
- private function setCurrentRequest($name,$value)
+ protected function setCurrentRequest($name,$value)
{
$this->currentget[$name] = $value;
}
@@ -486,7 +487,7 @@
*
* @return mixed Random value for the parameter named $name
*/
- private function getRandom( $name )
+ protected function getRandom( $name )
{
if(!isset($this->allget[$name]))
{
@@ -504,7 +505,7 @@
* Returns either 0 or 1
* @return int
*/
- private function getRandom01()
+ protected function getRandom01()
{
return mt_rand(0,1);
}
@@ -514,7 +515,7 @@
* - set the fake request
* - load the LogStats class and call the method to launch the recording
*/
- private function saveVisit()
+ protected function saveVisit()
{
$this->setFakeRequest();
$process = new Piwik_LogStats_Generator_Main;
Modified: trunk/modules/ViewDataTable/Cloud.php
===================================================================
--- trunk/modules/ViewDataTable/Cloud.php 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/modules/ViewDataTable/Cloud.php 2008-01-19 15:41:52 UTC (rev 196)
@@ -93,6 +93,7 @@
$view->labelDetails = $labelDetails;
$view->cloudValues = $cloudValues;
+ $view->showFooter = $this->showFooter;
$this->view = $view;
}
}
Modified: trunk/modules/ViewDataTable/GenerateGraphData.php
===================================================================
--- trunk/modules/ViewDataTable/GenerateGraphData.php 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/modules/ViewDataTable/GenerateGraphData.php 2008-01-19 15:41:52 UTC (rev 196)
@@ -64,34 +64,75 @@
else
{
// echo $this->dataTable;
- // We apply a filter to the DataTable, decoding the label column (useful for keywords for example)
- $filter = new Piwik_DataTable_Filter_ColumnCallbackReplace(
- $this->dataTable,
- 'label',
- 'urldecode'
- );
- $data = array();
- foreach($this->dataTable->getRows() as $row)
- {
- $label = $row->getColumn('label');
- $value = $row->getColumn('nb_unique_visitors');
- // case no unique visitors
- if($value === false)
- {
- $value = $row->getColumn('nb_visits');
- }
- $data[] = array(
- 'label' => $label,
- 'value' => $value,
- 'url' => $row->getDetail('url'),
- );
- }
+ $data = $this->generateDataFromDataTable();
$this->view->setData($data);
$this->view->customizeGraph();
}
}
+
+ protected function generateDataFromDataTable()
+ {
+ // We apply a filter to the DataTable, decoding the label column (useful for keywords for example)
+ $filter = new Piwik_DataTable_Filter_ColumnCallbackReplace(
+ $this->dataTable,
+ 'label',
+ 'urldecode'
+ );
+ $data = array();
+ foreach($this->dataTable->getRows() as $row)
+ {
+ $label = $row->getColumn('label');
+ $value = $row->getColumn('nb_unique_visitors');
+ // case no unique visitors
+ if($value === false)
+ {
+ $value = $row->getColumn('nb_visits');
+ }
+ $data[] = array(
+ 'label' => $label,
+ 'value' => $value,
+ 'url' => $row->getDetail('url'),
+ );
+ }
+ return $data;
+ }
}
-
+
+class Piwik_ViewDataTable_GenerateGraphData_ChartEvolution extends Piwik_ViewDataTable_GenerateGraphData
+{
+ function __construct()
+ {
+ require_once "Visualization/ChartEvolution.php";
+ $this->view = new Piwik_Visualization_ChartEvolution;
+ }
+
+ protected function generateDataFromDataTable()
+ {
+ // we have to fill a $data array with each row = array('label' => X, 'value' => y)
+
+ $data = array();
+ foreach($this->dataTable->getArray() as $keyName => $table)
+ {
+ $value = false;
+
+ $onlyRow = $table->getRowFromId(0);
+ if($onlyRow !== false)
+ {
+ $value = $onlyRow->getColumn('value');
+ }
+
+ if($value === false)
+ {
+ $value = 0;
+ }
+ $data[] = array(
+ 'label' => $keyName,
+ 'value' => $value
+ );
+ }
+ return $data;
+ }
+}
/**
*
* @package Piwik_ViewDataTable
Modified: trunk/modules/ViewDataTable/Graph.php
===================================================================
--- trunk/modules/ViewDataTable/Graph.php 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/modules/ViewDataTable/Graph.php 2008-01-19 15:41:52 UTC (rev 196)
@@ -16,6 +16,9 @@
*/
abstract class Piwik_ViewDataTable_Graph extends Piwik_ViewDataTable
{
+ protected $width = 400;
+ protected $height = 250;
+
function init($currentControllerAction,
$moduleNameAndMethod )
{
@@ -26,6 +29,7 @@
$this->disableOffsetInformation();
$this->disableExcludeLowPopulation();
$this->disableSearchBox();
+ $this->parametersToModify = array( 'viewDataTable' => $this->valueParameterViewDataTable);
}
public function main()
@@ -40,10 +44,9 @@
$this->id = $this->getUniqIdTable();
$view->id = $this->id;
$view->method = $this->method;
-
- $parametersToModify = array( 'viewDataTable' => $this->valueParameterViewDataTable);
-
- $url = Piwik_Url::getCurrentQueryStringWithParametersModified($parametersToModify);
+
+ $this->parametersToModify['action'] = $this->currentControllerAction;
+ $url = Piwik_Url::getCurrentQueryStringWithParametersModified($this->parametersToModify);
$view->jsInvocationTag = $this->getFlashInvocationCode($url);
// print($url);exit;
$view->urlData = $url;
@@ -52,39 +55,32 @@
$view->codeEmbed = $this->codeEmbed;
$view->javascriptVariablesToSet = $this->getJavascriptVariablesToSet();
+ $view->showFooter = $this->showFooter;
$this->view = $view;
- }
-
- protected function getCodeEmbed( $url )
- {
}
- protected function getFlashInvocationCode(
- $url = 'libs/open-flash-chart/data-files/nodata.txt',
- $width = 500,
- $height = 250,
- $use_swfobject = true )
- {
+ //TODO change $use_swfobject = true
+ public function getFlashInvocationCode(
+ $url = 'libs/open-flash-chart/data-files/nodata.txt',
+ $use_swfobject = false )
+ {
+ $width = $this->width;
+ $height = $this->height;
+
$libPathInPiwik = 'libs/open-flash-chart/';
-
$currentPath = Piwik_Url::getCurrentUrlWithoutFileName();
-
$pathToLibraryOpenChart = $currentPath . $libPathInPiwik;
$url = $currentPath . $url;
+ // escape the & and stuff:
+ $url = urlencode($url);
- $div_name = $this->id;
-
- $obj_id = $this->id . "_chart";
- $div_name = $this->id . "_flashContent";
+ $obj_id = $this->id . "Chart";
+ $div_name = $this->id . "FlashContent";
// I think we may use swfobject for all browsers, not JUST for IE...
//
//$ie = strstr(getenv('HTTP_USER_AGENT'), 'MSIE');
- //
- // escape the & and stuff:
- //
- $url = urlencode($url);
$return = '';
if( $use_swfobject )
@@ -93,9 +89,7 @@
$return .= '
<div id="'. $div_name .'"></div>
<script type="text/javascript">
- var so = new SWFObject("'.$pathToLibraryOpenChart.'open-flash-chart.swf", "ofc", "'. $width . '", "' . $height . '", "9", "#FFFFFF");
- so.addVariable("width", "' . $width . '");
- so.addVariable("height", "' . $height . '");
+ var so = new SWFObject("'.$pathToLibraryOpenChart.'open-flash-chart.swf", "chart", "'. $width . '", "' . $height . '", "9", "#FFFFFF");
so.addVariable("data", "'. $url . '");
so.addParam("allowScriptAccess", "sameDomain");
so.write("'. $div_name .'");
@@ -107,7 +101,7 @@
$return .= '
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
- width="' . $width . '" height="' . $height . '" id="ie_'. $obj_id .'" align="middle">
+ width="' . $width . '" height="' . $height . '" id="'. $obj_id .'" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="'.$pathToLibraryOpenChart.'open-flash-chart.swf?width='. $width .'&height='. $height . '&data='. $url .'" />
<param name="quality" value="high" />
@@ -119,10 +113,37 @@
$return .= '</noscript>';
}
+ // doesn't work embed because needs to be in BODY
+// $return = '<script type="text/javascript" src="libs/swfobject/swfobject.js"></script> ' . $return;
return $return;
}
}
-
+
+/**
+ *
+ * @package Piwik_ViewDataTable
+ *
+ */
+class Piwik_ViewDataTable_Graph_ChartEvolution extends Piwik_ViewDataTable_Graph
+{
+ function __construct()
+ {
+ $this->valueParameterViewDataTable = 'generateDataChartEvolution';
+ $this->width=700;
+ $this->height=150;
+
+ }
+
+ function init($currentControllerAction,
+ $moduleNameAndMethod )
+ {
+ parent::init($currentControllerAction,
+ $moduleNameAndMethod );
+
+ $this->parametersToModify['date'] = 'last30';
+ $this->doNotShowFooter();
+ }
+}
/**
*
* @package Piwik_ViewDataTable
Modified: trunk/modules/ViewDataTable/Html.php
===================================================================
--- trunk/modules/ViewDataTable/Html.php 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/modules/ViewDataTable/Html.php 2008-01-19 15:41:52 UTC (rev 196)
@@ -73,7 +73,9 @@
$view->nbColumns = $nbColumns;
$view->javascriptVariablesToSet = $this->getJavascriptVariablesToSet();
-
+
+ $view->showFooter = $this->showFooter;
+
$this->view = $view;
}
Modified: trunk/modules/ViewDataTable.php
===================================================================
--- trunk/modules/ViewDataTable.php 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/modules/ViewDataTable.php 2008-01-19 15:41:52 UTC (rev 196)
@@ -24,6 +24,7 @@
protected $JSoffsetInformation = true;
protected $JSexcludeLowPopulation = true;
protected $JSsortEnabled = true;
+ protected $showFooter = true;
protected $currentControllerAction;
@@ -44,11 +45,11 @@
*
* @return Piwik_ViewDataTable Data table
*/
- static public function factory( $type = null )
+ static public function factory( $type = null, $defaultType = 'table')
{
if(is_null($type))
{
- $type = Piwik_Common::getRequestVar('viewDataTable', 'table', 'string');
+ $type = Piwik_Common::getRequestVar('viewDataTable', $defaultType, 'string');
}
switch($type)
@@ -62,10 +63,15 @@
require_once "ViewDataTable/Graph.php";
return new Piwik_ViewDataTable_Graph_ChartPie();
break;
-
- case 'graphVerticalBar':
- require_once "ViewDataTable/Graph.php";
- return new Piwik_ViewDataTable_Graph_ChartVerticalBar();
+
+ case 'graphVerticalBar':
+ require_once "ViewDataTable/Graph.php";
+ return new Piwik_ViewDataTable_Graph_ChartVerticalBar();
+ break;
+
+ case 'graphEvolution':
+ require_once "ViewDataTable/Graph.php";
+ return new Piwik_ViewDataTable_Graph_ChartEvolution();
break;
case 'generateDataChartVerticalBar':
@@ -76,6 +82,12 @@
case 'generateDataChartPie':
require_once "ViewDataTable/GenerateGraphData.php";
return new Piwik_ViewDataTable_GenerateGraphData_ChartPie();
+ break;
+
+ case 'generateDataChartEvolution':
+ require_once "ViewDataTable/GenerateGraphData.php";
+ return new Piwik_ViewDataTable_GenerateGraphData_ChartEvolution();
+
break;
case 'table':
@@ -102,6 +114,9 @@
$this->variablesDefault['filter_excludelowpop_default'] = 'false';
$this->variablesDefault['filter_excludelowpop_value_default'] = 'false';
}
+
+
+ abstract public function main();
/**
* For convenience, the client code can call methods that are defined in a specific children class
@@ -138,7 +153,7 @@
return $uniqIdTable;
}
- protected function getJavascriptVariablesToSet( )
+ protected function getJavascriptVariablesToSet()
{
// build javascript variables to set
$javascriptVariablesToSet = array();
@@ -318,6 +333,16 @@
{
return $this->JSsearchBox;
}
+
+ /**
+ * When this method is called, the output will not contain the template datatable_footer.tpl
+ *
+ * @return void
+ */
+ public function doNotShowFooter()
+ {
+ $this->showFooter = false;
+ }
public function disableExcludeLowPopulation()
{
Modified: trunk/modules/Visualization/Chart.php
===================================================================
--- trunk/modules/Visualization/Chart.php 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/modules/Visualization/Chart.php 2008-01-19 15:41:52 UTC (rev 196)
@@ -21,6 +21,33 @@
{
$this->dataGraph = $data;
}
+ function getCount()
+ {
+ return count($this->dataGraph);
+ }
+ function customizeGraph()
+ {
+ $this->set_num_decimals ( 0 );
+ $this->set_is_decimal_separator_comma( false );
+ $this->set_is_thousand_separator_disabled( true );
+ $this->y_axis_colour = '#ffffff';
+ $this->x_axis_colour = '#596171';
+ $this->x_grid_colour = $this->y_grid_colour = '#E0E1E4';
+
+ // approx 5 x labels on the graph
+ $steps = ceil($this->getCount() / 5);
+ $steps = $steps + $steps % 2; // make sure modulo 2
+
+ $this->set_x_label_style( 10, $this->x_axis_colour, 0, $steps, $this->x_grid_colour );
+ $this->set_x_axis_steps( $steps / 2 );
+
+
+ $stepsY = ceil($this->getCount() / 4);
+ $this->y_label_steps( $stepsY / 3 );
+
+
+
+ }
function prepareData()
{
@@ -44,7 +71,7 @@
$this->arrayData = $data;
$this->arrayLabel = $label;
- $this->maxData = $max;
+ $this->maxData = $max + 10 - $max % 10;
// var_dump($label);var_dump($data);
}
Added: trunk/modules/Visualization/ChartEvolution.php
===================================================================
--- trunk/modules/Visualization/ChartEvolution.php (rev 0)
+++ trunk/modules/Visualization/ChartEvolution.php 2008-01-19 15:41:52 UTC (rev 196)
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
+ * @version $Id: ChartVerticalBar.php 168 2008-01-14 05:26:43Z matt $
+ *
+ * @package Piwik_Visualization
+ */
+
+require_once "Visualization/Chart.php";
+
+/**
+ *
+ * @package Piwik_Visualization
+ *
+ */
+class Piwik_Visualization_ChartEvolution extends Piwik_Visualization_Chart
+{
+
+ function customizeGraph()
+ {
+ //TODO add this call in other child
+ parent::customizeGraph();
+ $this->prepareData();
+ $this->set_y_max( $this->maxData );
+
+ $this->bg_colour = '#ffffff';
+ $this->set_data( $this->arrayData );
+ $this->set_x_labels( $this->arrayLabel );
+ $this->area_hollow( 2, 4, 15,'0x3357A0', ' visits', 10 );
+
+ $this->set_tool_tip( '#x_label# <br>#val# #key# ' );
+
+
+ }
+
+}
\ No newline at end of file
Modified: trunk/modules/Visualization/OpenFlashChart.php
===================================================================
--- trunk/modules/Visualization/OpenFlashChart.php 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/modules/Visualization/OpenFlashChart.php 2008-01-19 15:41:52 UTC (rev 196)
@@ -21,560 +21,1447 @@
{
function __construct()
{
- $this->data = array();
- $this->x_labels = array();
- $this->y_min = 0;
- $this->y_max = 20;
- $this->y_steps = 5;
- $this->title = '';
- $this->title_style = '';
-
- $this->x_tick_size = -1;
-
- $this->y2_max = '';
- $this->y2_min = '';
-
- // GRID styles:
- $this->x_axis_colour = '';
- $this->x_axis_3d = '';
- $this->x_grid_colour = '';
- $this->x_axis_steps = 1;
- $this->y_axis_colour = '';
- $this->y_grid_colour = '';
- $this->y2_axis_colour = '';
-
- // AXIS LABEL styles:
- $this->x_label_style = '';
- $this->y_label_style = '';
- $this->y_label_style_right = '';
-
-
- // AXIS LEGEND styles:
- $this->x_legend = '';
- $this->x_legend_size = 20;
- $this->x_legend_colour = '#000000';
-
- $this->y_legend = '';
- $this->y_legend_right = '';
- //$this->y_legend_size = 20;
- //$this->y_legend_colour = '#000000';
-
- $this->lines = array();
- $this->line_default = '&line=3,#87421F&'. "\r\n";
-
- $this->bg_colour = '';
- $this->bg_image = '';
-
- $this->inner_bg_colour = '';
- $this->inner_bg_colour_2 = '';
- $this->inner_bg_angle = '';
-
- // PIE chart ------------
- $this->pie = '';
- $this->pie_values = '';
- $this->pie_colours = '';
- $this->pie_labels = '';
-
- $this->tool_tip = '';
-
- // which data lines are attached to the
- // right Y axis?
- $this->y2_lines = array();
- }
-
- function set_data( $a )
- {
- if( count( $this->data ) == 0 )
- $this->data[] = '&values='.implode(',',$a).'&'."\r\n";
- else
- $this->data[] = '&values_'. (count( $this->data )+1) .'='.implode(',',$a).'&'."\r\n";
- }
-
- function set_tool_tip( $tip )
- {
- $this->tool_tip = $tip;
- }
-
- function set_x_labels( $a )
- {
- $this->x_labels = $a;
- }
-
- function set_x_label_style( $size, $colour='', $orientation=0, $step=-1, $grid_colour='' )
- {
-
- $this->x_label_style = '&x_label_style='. $size;
-
- if( strlen( $colour ) > 0 )
- $this->x_label_style .= ','. $colour;
-
- if( $orientation > -1 )
- $this->x_label_style .= ','. $orientation;
-
- if( $step > 0 )
- $this->x_label_style .= ','. $step;
-
- if( strlen( $grid_colour ) > 0 )
- $this->x_label_style .= ','. $grid_colour;
-
- $this->x_label_style .= "&\r\n";
- }
-
- function set_bg_colour( $colour )
- {
- $this->bg_colour = $colour;
- }
-
- function set_bg_image( $url, $x='center', $y='center' )
- {
- $this->bg_image = $url;
- $this->bg_image_x = $x;
- $this->bg_image_y = $y;
- }
-
- function attach_to_y_right_axis( $data_number )
- {
- $this->y2_lines[] = $data_number;
- }
-
- function set_inner_background( $col, $col2='', $angle=-1 )
- {
-
- $this->inner_bg_colour = $col;
-
-
- if( strlen($col2) > 0 )
- $this->inner_bg_colour_2 = $col2;
-
- if( $angle != -1 )
- $this->inner_bg_angle = $angle;
-
- }
-
- function _set_y_label_style( $name, $size, $colour )
- {
- $tmp = '&'. $name .'='. $size;
-
- if( strlen( $colour ) > 0 )
- $tmp .= ','. $colour;
-
- return $tmp;
- }
-
- function set_y_label_style( $size, $colour='' )
- {
- $this->y_label_style = $this->_set_y_label_style( 'y_label_style', $size, $colour );
- }
-
- function set_y_right_label_style( $size, $colour='' )
- {
- $this->y_label_style_right = $this->_set_y_label_style( 'y2_label_style', $size, $colour );
- }
-
- function set_y_max( $max )
- {
-
- $this->y_max = intval( $max );
- }
-
- function set_y_min( $min )
- {
-
- $this->y_min = intval( $min );
- }
-
- function set_y_right_max( $max )
- {
- $this->y2_max = '&y2_max='. $max .'&'."\r\n";
- }
-
- function set_y_right_min( $min )
- {
- $this->y2_min = '&y2_min='. $min .'&'."\r\n";
- }
-
- function y_label_steps( $val )
- {
- $this->y_steps = intval( $val );
- }
-
- function title( $title, $style='' )
- {
- $this->title = $title;
- if( strlen( $style ) > 0 )
- $this->title_style = $style;
- }
-
- function set_x_legend( $text, $size=-1, $colour='' )
- {
- $this->x_legend = $text;
- if( $size > -1 )
- $this->x_legend_size = $size;
-
- if( strlen( $colour )>0 )
- $this->x_legend_colour = $colour;
- }
-
- function set_x_tick_size( $size )
- {
- if( $size > 0 )
- $this->x_tick_size = $size;
- }
-
- function set_x_axis_steps( $steps )
- {
- if ( $steps > 0 )
- $this->x_axis_steps = $steps;
- }
-
- function set_x_axis_3d( $size )
- {
- if( $size > 0 )
- $this->x_axis_3d = '&x_axis_3d='. $size ."&\r\n";
- }
-
- // PRIVATE METHOD
- function _set_y_legend( $label, $text, $size, $colour )
- {
- $tmp = '&'. $label .'=';
- $tmp .= $text;
-
- if( $size > -1 )
- $tmp .= ','. $size;
-
- if( strlen( $colour )>0 )
- $tmp .= ','. $colour;
-
- $tmp .= "&\r\n";
-
- return $tmp;
- }
-
- function set_y_legend( $text, $size=-1, $colour='' )
- {
- $this->y_legend = $this->_set_y_legend( 'y_legend', $text, $size, $colour );
- }
-
- function set_y_right_legend( $text, $size=-1, $colour='' )
- {
- $this->y_legend_right = $this->_set_y_legend( 'y2_legend', $text, $size, $colour );
- }
-
- function line( $width, $colour='', $text='', $size=-1, $circles=-1 )
- {
- $tmp = '&line';
-
- if( count( $this->lines ) > 0 )
- $tmp .= '_'. (count( $this->lines )+1);
-
- $tmp .= '=';
-
- if( $width > 0 )
- {
- $tmp .= $width;
- $tmp .= ','. $colour;
- }
-
- if( strlen( $text ) > 0 )
- {
- $tmp .= ','. $text;
- $tmp .= ','. $size;
- }
-
- if( $circles > 0 )
- $tmp .= ','. $circles;
-
- $tmp .= "&\r\n";;
-
- $this->lines[] = $tmp;
- }
-
- function line_dot( $width, $dot_size, $colour, $text='', $font_size='' )
- {
- $tmp = '&line_dot';
-
- if( count( $this->lines ) > 0 )
- $tmp .= '_'. (count( $this->lines )+1);
-
- $tmp .= "=$width,$colour,$text";
-
- if( strlen( $font_size ) > 0 )
- $tmp .= ",$font_size,$dot_size";
-
- $tmp .= "&\r\n";
-
- $this->lines[] = $tmp;
- }
-
- function line_hollow( $width, $dot_size, $colour, $text='', $font_size='' )
- {
- $tmp = '&line_hollow';
-
- if( count( $this->lines ) > 0 )
- $tmp .= '_'. (count( $this->lines )+1);
-
- $tmp .= "=$width,$colour,$text";
-
- if( strlen( $font_size ) > 0 )
- $tmp .= ",$font_size,$dot_size";
-
- $tmp .= "&\r\n";
- $this->lines[] = $tmp;
- }
-
- function area_hollow( $width, $dot_size, $colour, $alpha, $text='', $font_size='', $fill_colour='' )
- {
- $tmp = '&area_hollow';
-
- if( count( $this->lines ) > 0 )
- $tmp .= '_'. (count( $this->lines )+1);
-
- $tmp .= "=$width,$dot_size,$colour,$alpha";
-
- if( strlen( $text ) > 0 )
- $tmp .= ",$text,$font_size";
-
- if( strlen( $fill_colour ) > 0 )
- $tmp .= ','. $fill_colour;
-
- $tmp .= "&\r\n";
-
- $this->lines[] = $tmp;
- }
-
-
- function bar( $alpha, $colour='', $text='', $size=-1 )
- {
- $tmp = '&bar';
-
- if( count( $this->lines ) > 0 )
- $tmp .= '_'. (count( $this->lines )+1);
-
- $tmp .= '=';
- $tmp .= $alpha .','. $colour .','. $text .','. $size;
- $tmp .= "&\r\n";;
-
- $this->lines[] = $tmp;
- }
-
- function bar_filled( $alpha, $colour, $colour_outline, $text='', $size=-1 )
- {
- $tmp = '&filled_bar';
-
- if( count( $this->lines ) > 0 )
- $tmp .= '_'. (count( $this->lines )+1);
-
- $tmp .= "=$alpha,$colour,$colour_outline,$text,$size&\r\n";
-
- $this->lines[] = $tmp;
- }
-
- function bar_3D( $alpha, $colour='', $text='', $size=-1 )
- {
- $tmp = '&bar_3d';
-
- if( count( $this->lines ) > 0 )
- $tmp .= '_'. (count( $this->lines )+1);
-
- $tmp .= '=';
- $tmp .= $alpha .','. $colour .','. $text .','. $size;
- $tmp .= "&\r\n";;
-
- $this->lines[] = $tmp;
- }
-
- function bar_glass( $alpha, $colour, $outline_colour, $text='', $size=-1 )
- {
- $tmp = '&bar_glass';
-
- if( count( $this->lines ) > 0 )
- $tmp .= '_'. (count( $this->lines )+1);
-
- $tmp .= '=';
- $tmp .= $alpha .','. $colour .','. $outline_colour .','. $text .','. $size;
- $tmp .= "&\r\n";;
-
- $this->lines[] = $tmp;
- }
-
- function bar_fade( $alpha, $colour='', $text='', $size=-1 )
- {
- $tmp = '&bar_fade';
-
- if( count( $this->lines ) > 0 )
- $tmp .= '_'. (count( $this->lines )+1);
-
- $tmp .= '=';
- $tmp .= $alpha .','. $colour .','. $text .','. $size;
- $tmp .= "&\r\n";;
-
- $this->lines[] = $tmp;
- }
-
- function x_axis_colour( $axis, $grid='' )
- {
- $this->x_axis_colour = $axis;
- $this->x_grid_colour = $grid;
- }
-
- function y_axis_colour( $axis, $grid='' )
- {
- $this->y_axis_colour = '&y_axis_colour='. $axis .'&'."\r\n";
-
- if( strlen( $grid ) > 0 )
- $this->y_grid_colour = '&y_grid_colour='. $grid .'&'."\r\n";
- }
-
- function y_right_axis_colour( $colour )
- {
- $this->y2_axis_colour = '&y2_axis_colour='. $colour .'&'."\r\n";
- }
-
-
- function pie( $alpha, $line_colour, $label_colour )
- {
- $this->pie = $alpha.','.$line_colour.','.$label_colour;
-
- }
-
- function pie_values( $values, $labels )
- {
- $this->pie_values = implode(',',$values);
- $this->pie_labels = implode(',',$labels);
- }
-
-
- function pie_slice_colours( $colours )
- {
- $this->pie_colours = implode(',',$colours);
- }
-
-
-
- function render()
- {
- //$tmp = "&padding=70,5,50,40&\r\n";
- $tmp = '';
-
- if( strlen( $this->title ) > 0 )
- {
- $tmp .= '&title='. $this->title .',';
- $tmp .= $this->title_style .'&';
- $tmp .= "\r\n";
- }
-
- if( strlen( $this->x_legend ) > 0 )
- {
- $tmp .= '&x_legend='. $this->x_legend .',';
- $tmp .= $this->x_legend_size .',';
- $tmp .= $this->x_legend_colour ."&\r\n";
- }
-
- if( strlen( $this->x_label_style ) > 0 )
- $tmp .= $this->x_label_style;
-
- if( $this->x_tick_size > 0 )
- $tmp .= "&x_ticks=". $this->x_tick_size ."&\r\n";
-
- if( $this->x_axis_steps > 0 )
- $tmp .= "&x_axis_steps=". $this->x_axis_steps ."&\r\n";
-
- if( strlen( $this->x_axis_3d ) > 0 )
- $tmp .= $this->x_axis_3d;
-
- $tmp .= $this->y_legend;
- $tmp .= $this->y_legend_right;
-
- if( strlen( $this->y_label_style ) > 0 )
- $tmp .= $this->y_label_style;
-
- $tmp .= '&y_ticks=5,10,'. $this->y_steps .'&'."\r\n";
-
- if( count( $this->lines ) == 0 )
- {
- $tmp .= $this->line_default;
- }
- else
- {
- foreach( $this->lines as $line )
- $tmp .= $line;
- }
-
- foreach( $this->data as $data )
- $tmp .= $data;
-
- if( count( $this->y2_lines ) > 0 )
- {
- $tmp .= '&y2_lines=';
- $tmp .= implode( ',', $this->y2_lines );
- $tmp .= '&'."\r\n";
- //
- // Should this be an option? I think so...
- //
- $tmp .= '&show_y2=true&'."\r\n";
- }
-
- if( count( $this->x_labels ) > 0 )
- $tmp .= '&x_labels='.implode(',',$this->x_labels).'&'."\r\n";
-
- $tmp .= '&y_min='. $this->y_min .'&'."\r\n";
- $tmp .= '&y_max='. $this->y_max .'&'."\r\n";
-
- $tmp .= $this->y2_max;
- $tmp .= $this->y2_min;
-
- if( strlen( $this->bg_colour ) > 0 )
- $tmp .= '&bg_colour='. $this->bg_colour .'&'."\r\n";
-
- if( strlen( $this->bg_image ) > 0 )
- {
- $tmp .= '&bg_image='. $this->bg_image .'&'."\r\n";
- $tmp .= '&bg_image_x='. $this->bg_image_x .'&'."\r\n";
- $tmp .= '&bg_image_y='. $this->bg_image_y .'&'."\r\n";
- }
-
-
- if( strlen( $this->x_axis_colour ) > 0 )
- {
- $tmp .= '&x_axis_colour='. $this->x_axis_colour .'&'."\r\n";
- $tmp .= '&x_grid_colour='. $this->x_grid_colour .'&'."\r\n";
- }
-
- if( strlen( $this->y_axis_colour ) > 0 )
- $tmp .= $this->y_axis_colour;
-
- if( strlen( $this->y_grid_colour ) > 0 )
- $tmp .= $this->y_grid_colour;
-
- if( strlen( $this->y2_axis_colour ) > 0 )
- $tmp .= $this->y2_axis_colour;
-
- if( strlen( $this->inner_bg_colour ) > 0 )
- {
- $tmp .= '&inner_background='.$this->inner_bg_colour;
- if( strlen( $this->inner_bg_colour_2 ) > 0 )
- {
-
- $tmp .= ','. $this->inner_bg_colour_2;
- $tmp .= ','. $this->inner_bg_angle;
- }
- $tmp .= '&'."\r\n";
- }
-
- if( strlen( $this->pie ) > 0 )
- {
-
- $tmp .= '&pie='. $this->pie .'&'."\r\n";
- $tmp .= '&values='. $this->pie_values .'&'."\r\n";
- $tmp .= '&pie_labels='. $this->pie_labels .'&'."\r\n";
- $tmp .= '&colours='. $this->pie_colours .'&'."\r\n";
- }
-
- if( strlen( $this->tool_tip ) > 0 )
- {
- $tmp .= '&tool_tip='. $this->tool_tip .'&'."\r\n";
- }
-
- return $tmp;
- }
-}
\ No newline at end of file
+ $this->data_sets = array();
+
+
+ $this->data = array();
+ $this->links = array();
+ $this->width = 250;
+ $this->height = 200;
+ $this->base = 'js/';
+ $this->x_labels = array();
+ $this->y_min = '';
+ $this->y_max = '';
+ $this->x_min = '';
+ $this->x_max = '';
+ $this->y_steps = '';
+ $this->title = '';
+ $this->title_style = '';
+ $this->occurence = 0;
+
+ $this->x_offset = '';
+
+ $this->x_tick_size = -1;
+
+ $this->y2_max = '';
+ $this->y2_min = '';
+
+ // GRID styles:
+ $this->x_axis_colour = '';
+ $this->x_axis_3d = '';
+ $this->x_grid_colour = '';
+ $this->x_axis_steps = 1;
+ $this->y_axis_colour = '';
+ $this->y_grid_colour = '';
+ $this->y2_axis_colour = '';
+
+ // AXIS LABEL styles:
+ $this->x_label_style = '';
+ $this->y_label_style = '';
+ $this->y_label_style_right = '';
+
+
+ // AXIS LEGEND styles:
+ $this->x_legend = '';
+ $this->x_legend_size = 20;
+ $this->x_legend_colour = '#000000';
+
+ $this->y_legend = '';
+ $this->y_legend_right = '';
+ //$this->y_legend_size = 20;
+ //$this->y_legend_colour = '#000000';
+
+ $this->lines = array();
+ $this->line_default['type'] = 'line';
+ $this->line_default['values'] = '3,#87421F';
+ $this->js_line_default = 'so.addVariable("line","3,#87421F");';
+
+ $this->bg_colour = '';
+ $this->bg_image = '';
+
+ $this->inner_bg_colour = '';
+ $this->inner_bg_colour_2 = '';
+ $this->inner_bg_angle = '';
+
+ // PIE chart ------------
+ $this->pie = '';
+ $this->pie_values = '';
+ $this->pie_colours = '';
+ $this->pie_labels = '';
+
+ $this->tool_tip = '';
+
+ // which data lines are attached to the
+ // right Y axis?
+ $this->y2_lines = array();
+
+ // Number formatting:
+ $this->y_format='';
+ $this->num_decimals='';
+ $this->is_fixed_num_decimals_forced='';
+ $this->is_decimal_separator_comma='';
+ $this->is_thousand_separator_disabled='';
+
+ //
+ // set some default value incase the user forgets
+ // to set them, so at least they see *something*
+ // even is it is only the axis and some ticks
+ //
+ $this->set_y_min( 0 );
+ $this->set_y_max( 20 );
+ $this->set_x_axis_steps( 1 );
+ $this->y_label_steps( 5 );
+ }
+
+ /**
+ * Set the unique_id to use for the flash object id.
+ */
+ function set_unique_id()
+ {
+ $this->unique_id = uniqid();
+ }
+
+ /**
+ * Get the flash object ID for the last rendered object.
+ */
+ function get_unique_id()
+ {
+ return ($this->unique_id);
+ }
+
+ /**
+ * Set the base path for the swfobject.js
+ *
+ * @param base_path a string argument.
+ * The path to the swfobject.js file
+ */
+ function set_js_path($path)
+ {
+ $this->js_path = $path;
+ }
+
+ /**
+ * Set the base path for the open-flash-chart.swf
+ *
+ * @param path a string argument.
+ * The path to the open-flash-chart.swf file
+ */
+ function set_swf_path($path)
+ {
+ $this->swf_path = $path;
+ }
+
+ /**
+ * Set the type of output data.
+ *
+ * @param type a string argument.
+ * The type of data. Currently only type is js, or nothing.
+ */
+ function set_output_type($type)
+ {
+ $this->output_type = $type;
+ }
+
+ // is this needed now?
+ function increment_occurence()
+ {
+ $this->occurence++;
+ }
+
+ /**
+ * returns the next line label for multiple lines.
+ */
+ function next_line()
+ {
+ $line_num = '';
+ if( count( $this->lines ) > 0 )
+ $line_num = '_'. (count( $this->lines )+1);
+
+ return $line_num;
+ }
+
+ // escape commas (,)
+ function esc( $text )
+ {
+ // we replace the comma so it is not URL escaped
+ // if it is, flash just thinks it is a comma
+ // which is no good if we are splitting the
+ // string on commas.
+ $tmp = str_replace( ',', '#comma#', $text );
+ // now we urlescape all dodgy characters (like & % $ etc..)
+ return urlencode( $tmp );
+ }
+
+ /**
+ * Format the text to the type of output.
+ */
+ function format_output($output_type,$function,$values)
+ {
+ if($output_type == 'js')
+ {
+ $tmp = 'so.addVariable("'. $function .'","'. $values . '");';
+ }
+ else
+ {
+ $tmp = '&'. $function .'='. $values .'&';
+ }
+
+ return $tmp;
+ }
+
+ /**
+ * Set the text and style of the title.
+ *
+ * @param title a string argument.
+ * The text of the title.
+ * @param style a string.
+ * CSS styling of the title.
+ */
+ function set_title( $title, $style='' )
+ {
+ $this->title = $title;
+ if( strlen( $style ) > 0 )
+ $this->title_style = $style;
+ }
+
+ /**
+ * Set the width of the chart.
+ *
+ * @param width an int argument.
+ * The width of the chart frame.
+ */
+ function set_width( $width )
+ {
+ $this->width = $width;
+ }
+
+ /**
+ * Set the height of the chart.
+ *
+ * @param height an int argument.
+ * The height of the chart frame.
+ */
+ function set_height( $height )
+ {
+ $this->height = $height;
+ }
+
+ /**
+ * Set the base path of the swfobject.
+ *
+ * @param base a string argument.
+ * The base path of the swfobject.
+ */
+ function set_base( $base='js/' )
+ {
+ $this->base = $base;
+ }
+
+ // Number formatting:
+ function set_y_format( $val )
+ {
+ $this->y_format = $val;
+ }
+
+ function set_num_decimals( $val )
+ {
+ $this->num_decimals = $val;
+ }
+
+ function set_is_fixed_num_decimals_forced( $val )
+ {
+ $this->is_fixed_num_decimals_forced = $val?'true':'false';
+ }
+
+ function set_is_decimal_separator_comma( $val )
+ {
+ $this->is_decimal_separator_comma = $val?'true':'false';
+ }
+
+ function set_is_thousand_separator_disabled( $val )
+ {
+ $this->is_thousand_separator_disabled = $val?'true':'false';
+ }
+
+ /**
+ * Set the data for the chart
+ * @param a an array argument.
+ * An array of the data to add to the chart.
+ */
+ function set_data( $a )
+ {
+ $this->data[] = implode(',',$a);
+ }
+
+ // UGH, these evil functions are making me fell ill
+ function set_links( $a )
+ {
+ $this->links[] = implode(',',$a);
+ }
+
+ // $val is a boolean
+ function set_x_offset( $val )
+ {
+ $this->x_offset = $val?'true':'false';
+ }
+
+ /**
+ * Set the tooltip to be displayed on each chart item.\n
+ * \n
+ * Replaceable tokens that can be used in the string include: \n
+ * #val# - The actual value of whatever the mouse is over. \n
+ * #key# - The key string. \n
+ * \<br> - New line. \n
+ * #x_label# - The X label string. \n
+ * #x_legend# - The X axis legend text. \n
+ * Default string is: "#x_label#<br>#val#" \n
+ *
+ * @param tip a string argument.
+ * A formatted string to show as the tooltip.
+ */
+ function set_tool_tip( $tip )
+ {
+ $this->tool_tip = $this->esc( $tip );
+ }
+
+ /**
+ * Set the x axis labels
+ *
+ * @param a an array argument.
+ * An array of the x axis labels.
+ */
+ function set_x_labels( $a )
+ {
+ $this->x_labels = $a;
+ }
+
+ /**
+ * Set the look and feel of the x axis labels
+ *
+ * @param font_size an int argument.
+ * The font size.
+ * @param colour a string argument.
+ * The hex colour value.
+ * @param orientation an int argument.
+ * The orientation of the x-axis text.
+ * 0 - Horizontal
+ * 1 - Vertical
+ * 2 - 45 degrees
+ * @param step an int argument.
+ * Show the label on every $step label.
+ * @param grid_colour a string argument.
+ */
+ function set_x_label_style( $size, $colour='', $orientation=0, $step=-1, $grid_colour='' )
+ {
+ $this->x_label_style = $size;
+
+ if( strlen( $colour ) > 0 )
+ $this->x_label_style .= ','. $colour;
+
+ if( $orientation > -1 )
+ $this->x_label_style .= ','. $orientation;
+
+ if( $step > 0 )
+ $this->x_label_style .= ','. $step;
+
+ if( strlen( $grid_colour ) > 0 )
+ $this->x_label_style .= ','. $grid_colour;
+ }
+
+ /**
+ * Set the background colour.
+ * @param colour a string argument.
+ * The hex colour value.
+ */
+ function set_bg_colour( $colour )
+ {
+ $this->bg_colour = $colour;
+ }
+
+ /**
+ * Set a background image.
+ * @param url a string argument.
+ * The location of the image.
+ * @param x a string argument.
+ * The x location of the image. 'Right', 'Left', 'Center'
+ * @param y a string argument.
+ * The y location of the image. 'Top', 'Bottom', 'Middle'
+ */
+ function set_bg_image( $url, $x='center', $y='center' )
+ {
+ $this->bg_image = $url;
+ $this->bg_image_x = $x;
+ $this->bg_image_y = $y;
+ }
+
+ /**
+ * Attach a set of data (a line, area or bar chart) to the right Y axis.
+ * @param data_number an int argument.
+ * The numbered order the data was attached using set_data.
+ */
+ function attach_to_y_right_axis( $data_number )
+ {
+ $this->y2_lines[] = $data_number;
+ }
+
+ /**
+ * Set the background colour of the grid portion of the chart.
+ * @param col a string argument.
+ * The hex colour value of the background.
+ * @param col2 a string argument.
+ * The hex colour value of the second colour if you want a gradient.
+ * @param angle an int argument.
+ * The angle in degrees to make the gradient.
+ */
+ function set_inner_background( $col, $col2='', $angle=-1 )
+ {
+ $this->inner_bg_colour = $col;
+
+ if( strlen($col2) > 0 )
+ $this->inner_bg_colour_2 = $col2;
+
+ if( $angle != -1 )
+ $this->inner_bg_angle = $angle;
+ }
+
+ /**
+ * Internal function to build the y label style for y and y2
+ */
+ function _set_y_label_style( $size, $colour )
+ {
+ $tmp = $size;
+
+ if( strlen( $colour ) > 0 )
+ $tmp .= ','. $colour;
+ return $tmp;
+ }
+
+ /**
+ * Set the look and feel of the y axis labels
+ *
+ * @param font_size an int argument.
+ * The font size.
+ * @param colour a string argument.
+ * The hex colour value.
+ */
+ function set_y_label_style( $size, $colour='' )
+ {
+ $this->y_label_style = $this->_set_y_label_style( $size, $colour );
+ }
+
+ /**
+ * Set the look and feel of the right y axis labels
+ *
+ * @param font_size an int argument.
+ * The font size.
+ * @param colour a string argument.
+ * The hex colour value.
+ */
+ function set_y_right_label_style( $size, $colour='' )
+ {
+ $this->y_label_style_right = $this->_set_y_label_style( $size, $colour );
+ }
+
+ function set_x_max( $max )
+ {
+ $this->x_max = intval( $max );
+ }
+
+ function set_x_min( $min )
+ {
+ $this->x_min = intval( $min );
+ }
+
+ /**
+ * Set the maximum value of the y axis.
+ *
+ * @param max an int argument.
+ * The maximum value.
+ */
+ function set_y_max( $max )
+ {
+ $this->y_max = intval( $max );
+ }
+
+ /**
+ * Set the minimum value of the y axis.
+ *
+ * @param min an int argument.
+ * The minimum value.
+ */
+ function set_y_min( $min )
+ {
+ $this->y_min = intval( $min );
+ }
+
+ /**
+ * Set the maximum value of the right y axis.
+ *
+ * @param max an int argument.
+ * The maximum value.
+ */
+ function set_y_right_max( $max )
+ {
+ $this->y2_max = intval($max);
+ }
+
+ /**
+ * Set the minimum value of the right y axis.
+ *
+ * @param min an int argument.
+ * The minimum value.
+ */
+ function set_y_right_min( $min )
+ {
+ $this->y2_min = intval($min);
+ }
+
+ /**
+ * Show the y label on every $step label.
+ *
+ * @param val an int argument.
+ * Show the label on every $step label.
+ */
+ function y_label_steps( $val )
+ {
+ $this->y_steps = intval( $val );
+ }
+
+ function title( $title, $style='' )
+ {
+ $this->title = $this->esc( $title );
+ if( strlen( $style ) > 0 )
+ $this->title_style = $style;
+ }
+
+ /**
+ * Set the parameters of the x legend.
+ *
+ * @param text a string argument.
+ * The text of the x legend.
+ * @param font_size an int argument.
+ * The font size of the x legend text.
+ * @param colour a string argument
+ * The hex value of the font colour.
+ */
+ function set_x_legend( $text, $size=-1, $colour='' )
+ {
+ $this->x_legend = $this->esc( $text );
+ if( $size > -1 )
+ $this->x_legend_size = $size;
+
+ if( strlen( $colour )>0 )
+ $this->x_legend_colour = $colour;
+ }
+
+ /**
+ * Set the size of the x label ticks.
+ *
+ * @param size an int argument.
+ * The size of the ticks in pixels.
+ */
+ function set_x_tick_size( $size )
+ {
+ if( $size > 0 )
+ $this->x_tick_size = $size;
+ }
+
+ /**
+ * Set how often you would like to show a tick on the x axis.
+ *
+ * @param steps an int argument.
+ * Show a tick ever $steps.
+ */
+ function set_x_axis_steps( $steps )
+ {
+ if ( $steps > 0 )
+ $this->x_axis_steps = $steps;
+ }
+
+ /**
+ * Set the depth in pixels of the 3D X axis slab.
+ *
+ * @param size an int argument.
+ * The depth in pixels of the 3D X axis.
+ */
+ function set_x_axis_3d( $size )
+ {
+ if( $size > 0 )
+ $this->x_axis_3d = intval($size);
+ }
+
+ /**
+ * The private method of building the y legend output.
+ */
+ function _set_y_legend( $text, $size, $colour )
+ {
+ $tmp = $text;
+
+ if( $size > -1 )
+ $tmp .= ','. $size;
+
+ if( strlen( $colour )>0 )
+ $tmp .= ','. $colour;
+
+ return $tmp;
+ }
+
+ /**
+ * Set the parameters of the y legend.
+ *
+ * @param text a string argument.
+ * The text of the y legend.
+ * @param font_size an int argument.
+ * The font size of the y legend text.
+ * @param colour a string argument
+ * The hex colour value of the font colour.
+ */
+ function set_y_legend( $text, $size=-1, $colour='' )
+ {
+ $this->y_legend = $this->_set_y_legend( $text, $size, $colour );
+ }
+
+ /**
+ * Set the parameters of the right y legend.
+ *
+ * @param text a string argument.
+ * The text of the right y legend.
+ * @param font_size an int argument.
+ * The font size of the right y legend text.
+ * @param colour a string argument
+ * The hex value of the font colour.
+ */
+ function set_y_right_legend( $text, $size=-1, $colour='' )
+ {
+ $this->y_legend_right = $this->_set_y_legend( $text, $size, $colour );
+ }
+
+ /**
+ * Set the colour of the x axis line and grid.
+ *
+ * @param axis a string argument.
+ * The hex colour value of the x axis line.
+ * @param grid a string argument.
+ * The hex colour value of the x axis grid.
+ */
+ function x_axis_colour( $axis, $grid='' )
+ {
+ $this->x_axis_colour = $axis;
+ $this->x_grid_colour = $grid;
+ }
+
+ /**
+ * Set the colour of the y axis line and grid.
+ *
+ * @param axis a string argument.
+ * The hex colour value of the y axis line.
+ * @param grid a string argument.
+ * The hex colour value of the y axis grid.
+ */
+ function y_axis_colour( $axis, $grid='' )
+ {
+ $this->y_axis_colour = $axis;
+
+ if( strlen( $grid ) > 0 )
+ $this->y_grid_colour = $grid;
+ }
+
+ /**
+ * Set the colour of the right y axis line.
+ *
+ * @param colour a string argument.
+ * The hex colour value of the right y axis line.
+ */
+ function y_right_axis_colour( $colour )
+ {
+ $this->y2_axis_colour = $colour;
+ }
+
+ /**
+ * Draw a line without markers on values.
+ *
+ * @param width an int argument.
+ * The width of the line in pixels.
+ * @param colour a string argument.
+ * The hex colour value of the line.
+ * @param text a string argument.
+ * The label of the line.
+ * @param font_size an int argument.
+ * Font size of the label
+ * @param circles an int argument
+ * Need to find out.
+ */
+ function line( $width, $colour='', $text='', $size=-1, $circles=-1 )
+ {
+ $type = 'line'. $this->next_line();
+
+ $description = '';
+ if( $width > 0 )
+ {
+ $description .= $width;
+ $description .= ','. $colour;
+ }
+
+ if( strlen( $text ) > 0 )
+ {
+ $description.= ','. $text;
+ $description .= ','. $size;
+ }
+
+ if( $circles > 0 )
+ $description .= ','. $circles;
+
+ $this->lines[$type] = $description;
+ }
+
+ /**
+ * Draw a line with solid dot markers on values.
+ *
+ * @param width an int argument.
+ * The width of the line in pixels.
+ * @param dot_size an int argument.
+ * Size in pixels of the dot.
+ * @param colour a string argument.
+ * The hex colour value of the line.
+ * @param text a string argument.
+ * The label of the line.
+ * @param font_size an int argument.
+ * Font size of the label.
+ */
+ function line_dot( $width, $dot_size, $colour, $text='', $font_size='' )
+ {
+ $type = 'line_dot'. $this->next_line();
+
+ $description = "$width,$colour,$text";
+
+ if( strlen( $font_size ) > 0 )
+ $description .= ",$font_size,$dot_size";
+
+ $this->lines[$type] = $description;
+ }
+
+ /**
+ * Draw a line with hollow dot markers on values.
+ *
+ * @param width an int argument.
+ * The width of the line in pixels.
+ * @param dot_size an int argument.
+ * Size in pixels of the dot.
+ * @param colour a string argument.
+ * The hex colour value of the line.
+ * @param text a string argument.
+ * The label of the line.
+ * @param font_size an int argument.
+ * Font size of the label.
+ */
+ function line_hollow( $width, $dot_size, $colour, $text='', $font_size='' )
+ {
+ $type = 'line_hollow'. $this->next_line();
+
+ $description = "$width,$colour,$text";
+
+ if( strlen( $font_size ) > 0 )
+ $description .= ",$font_size,$dot_size";
+
+ $this->lines[$type] = $description;
+ }
+
+ /**
+ * Draw an area chart.
+ *
+ * @param width an int argument.
+ * The width of the line in pixels.
+ * @param dot_size an int argument.
+ * Size in pixels of the dot.
+ * @param colour a string argument.
+ * The hex colour value of the line.
+ * @param alpha an int argument.
+ * The percentage of transparency of the fill colour.
+ * @param text a string argument.
+ * The label of the line.
+ * @param font_size an int argument.
+ * Font size of the label.
+ * @param fill_colour a string argument.
+ * The hex colour value of the fill colour.
+ */
+ function area_hollow( $width, $dot_size, $colour, $alpha, $text='', $font_size='', $fill_colour='' )
+ {
+ $type = 'area_hollow'. $this->next_line();
+
+ $description = "$width,$dot_size,$colour,$alpha";
+
+ if( strlen( $text ) > 0 )
+ $description .= ",$text,$font_size";
+
+ if( strlen( $fill_colour ) > 0 )
+ $description .= ','. $fill_colour;
+
+ $this->lines[$type] = $description;
+ }
+
+ /**
+ * Draw a bar chart.
+ *
+ * @param alpha an int argument.
+ * The percentage of transparency of the bar colour.
+ * @param colour a string argument.
+ * The hex colour value of the line.
+ * @param text a string argument.
+ * The label of the line.
+ * @param font_size an int argument.
+ * Font size of the label.
+ */
+ function bar( $alpha, $colour='', $text='', $size=-1 )
+ {
+ $type = 'bar'. $this->next_line();
+
+ $description = $alpha .','. $colour .','. $text .','. $size;
+
+ $this->lines[$type] = $description;
+ }
+
+ /**
+ * Draw a bar chart with an outline.
+ *
+ * @param alpha an int argument.
+ * The percentage of transparency of the bar colour.
+ * @param colour a string argument.
+ * The hex colour value of the line.
+ * @param colour_outline a strng argument.
+ * The hex colour value of the outline.
+ * @param text a string argument.
+ * The label of the line.
+ * @param font_size an int argument.
+ * Font size of the label.
+ */
+ function bar_filled( $alpha, $colour, $colour_outline, $text='', $size=-1 )
+ {
+ $type = 'filled_bar'. $this->next_line();
+
+ $description = "$alpha,$colour,$colour_outline,$text,$size";
+
+ $this->lines[$type] = $description;
+ }
+
+ function bar_sketch( $alpha, $offset, $colour, $colour_outline, $text='', $size=-1 )
+ {
+ $type = 'bar_sketch'. $this->next_line();
+
+ $description = "$alpha,$offset,$colour,$colour_outline,$text,$size";
+
+ $this->lines[$type] = $description;
+ }
+
+ /**
+ * Draw a 3D bar chart.
+ *
+ * @param alpha an int argument.
+ * The percentage of transparency of the bar colour.
+ * @param colour a string argument.
+ * The hex colour value of the line.
+ * @param text a string argument.
+ * The label of the line.
+ * @param font_size an int argument.
+ * Font size of the label.
+ */
+ function bar_3D( $alpha, $colour='', $text='', $size=-1 )
+ {
+ $type = 'bar_3d'. $this->next_line();
+
+ $description = $alpha .','. $colour .','. $text .','. $size;
+
+ $this->lines[$type] = $description;
+ }
+
+ /**
+ * Draw a 3D bar chart that looks like glass.
+ *
+ * @param alpha an int argument.
+ * The percentage of transparency of the bar colour.
+ * @param colour a string argument.
+ * The hex colour value of the line.
+ * @param outline_colour a string argument.
+ * The hex colour value of the outline.
+ * @param text a string argument.
+ * The label of the line.
+ * @param font_size an int argument.
+ * Font size of the label.
+ */
+ function bar_glass( $alpha, $colour, $outline_colour, $text='', $size=-1 )
+ {
+ $type = 'bar_glass'. $this->next_line();
+
+ $description = $alpha .','. $colour .','. $outline_colour .','. $text .','. $size;
+
+ $this->lines[$type] = $description;
+ }
+
+ /**
+ * Draw a faded bar chart.
+ *
+ * @param alpha an int argument.
+ * The percentage of transparency of the bar colour.
+ * @param colour a string argument.
+ * The hex colour value of the line.
+ * @param text a string argument.
+ * The label of the line.
+ * @param font_size an int argument.
+ * Font size of the label.
+ */
+ function bar_fade( $alpha, $colour='', $text='', $size=-1 )
+ {
+ $type = 'bar_fade'. $this->next_line();
+
+ $description = $alpha .','. $colour .','. $text .','. $size;
+
+ $this->lines[$type] = $description;
+ }
+
+ function candle( $data, $alpha, $line_width, $colour, $text='', $size=-1 )
+ {
+ $type = 'candle'. $this->next_line();
+
+ $description = $alpha .','. $line_width .','. $colour .','. $text .','. $size;
+
+ $this->lines[$type] = $description;
+
+ $a = array();
+ foreach( $data as $can )
+ $a[] = $can->toString();
+
+ $this->data[] = implode(',',$a);
+ }
+
+ function hlc( $data, $alpha, $line_width, $colour, $text='', $size=-1 )
+ {
+ $type = 'hlc'. $this->next_line();
+
+ $description = $alpha .','. $line_width .','. $colour .','. $text .','. $size;
+
+ $this->lines[$type] = $description;
+
+ $a = array();
+ foreach( $data as $can )
+ $a[] = $can->toString();
+
+ $this->data[] = implode(',',$a);
+ }
+
+ function scatter( $data, $line_width, $colour, $text='', $size=-1 )
+ {
+ $type = 'scatter'. $this->next_line();
+
+ $description = $line_width .','. $colour .','. $text .','. $size;
+
+ $this->lines[$type] = $description;
+
+ $a = array();
+ foreach( $data as $can )
+ $a[] = $can->toString();
+
+ $this->data[] = implode(',',$a);
+ }
+
+
+ //
+ // Patch by, Jeremy Miller (14th Nov, 2007)
+ //
+ /**
+ * Draw a pie chart.
+ *
+ * @param alpha an int argument.
+ * The percentage of transparency of the pie colour.
+ * @param line_colour a string argument.
+ * The hex colour value of the outline.
+ * @param label_colour a string argument.
+ * The hex colour value of the label.
+ * @param gradient a boolean argument.
+ * Use a gradient true or false.
+ * @param border_size an int argument.
+ * Size of the border in pixels.
+ */
+ function pie( $alpha, $line_colour, $label_colour, $gradient = true, $border_size = false )
+ {
+ $this->pie = $alpha.','.$line_colour.','.$label_colour;
+ if( !$gradient )
+ {
+ $this->pie .= ','.!$gradient;
+ }
+ if ($border_size)
+ {
+ if ($gradient === false)
+ {
+ $this->pie .= ',';
+ }
+ $this->pie .= ','.$border_size;
+ }
+ }
+
+ /**
+ * Set the values of the pie chart.
+ *
+ * @param values an array argument.
+ * An array of the values for the pie chart.
+ * @param labels an array argument.
+ * An array of the labels for the pie pieces.
+ * @param links an array argument.
+ * An array of the links to the pie pieces.
+ */
+ function pie_values( $values, $labels=array(), $links=array() )
+ {
+ $this->pie_values = implode(',',$values);
+ $this->pie_labels = implode(',',$labels);
+ $this->pie_links = implode(",",$links);
+ }
+
+ /**
+ * Set the pie slice colours.
+ *
+ * @param colours an array argument.
+ * The hex colour values of the pie pieces.
+ */
+ function pie_slice_colours( $colours )
+ {
+ $this->pie_colours = implode(',',$colours);
+ }
+
+
+ /**
+ * Render the output.
+ */
+ function render($output_type = '')
+ {
+ $tmp = array();
+
+ if($output_type == 'js')
+ {
+ $this->increment_occurence();
+
+ $tmp[] = '<div id="my_chart' . $this->occurence . '"></div>';
+ $tmp[] = '<script type="text/javascript" src="' . $this->base . 'swfobject.js"></script>';
+ $tmp[] = '<script type="text/javascript">';
+ $tmp[] = 'var so = new SWFObject("open-flash-chart.swf", "ofc", "'. $this->width . '", "' . $this->height . '", "9", "#FFFFFF");';
+ $tmp[] = 'so.addVariable("variables","true");';
+ }
+
+ if( strlen( $this->title ) > 0 )
+ {
+ $values = $this->title;
+ $values .= ','. $this->title_style;
+ $tmp[] = $this->format_output($output_type,'title',$values);
+ }
+
+ if( strlen( $this->x_legend ) > 0 )
+ {
+ $values = $this->x_legend;
+ $values .= ','. $this->x_legend_size;
+ $values .= ','. $this->x_legend_colour;
+ $tmp[] = $this->format_output($output_type,'x_legend',$values);
+ }
+
+ if( strlen( $this->x_label_style ) > 0 )
+ $tmp[] = $this->format_output($output_type,'x_label_style',$this->x_label_style);
+
+ if( $this->x_tick_size > 0 )
+ $tmp[] = $this->format_output($output_type,'x_ticks',$this->x_tick_size);
+
+ if( $this->x_axis_steps > 0 )
+ $tmp[] = $this->format_output($output_type,'x_axis_steps',$this->x_axis_steps);
+
+ if( strlen( $this->x_axis_3d ) > 0 )
+ $tmp[] = $this->format_output($output_type,'x_axis_3d',$this->x_axis_3d);
+
+ if( strlen( $this->y_legend ) > 0 )
+ $tmp[] = $this->format_output($output_type,'y_legend',$this->y_legend);
+
+ if( strlen( $this->y_legend_right ) > 0 )
+ $tmp[] = $this->format_output($output_type,'y2_legend',$this->y_legend_right);
+
+ if( strlen( $this->y_label_style ) > 0 )
+ $tmp[] = $this->format_output($output_type,'y_label_style',$this->y_label_style);
+
+ $values = '5,10,'. $this->y_steps;
+ $tmp[] = $this->format_output($output_type,'y_ticks',$values);
+
+ if( count( $this->lines ) == 0 && count($this->data_sets)==0 )
+ {
+ $tmp[] = $this->format_output($output_type,$this->line_default['type'],$this->line_default['values']);
+ }
+ else
+ {
+ foreach( $this->lines as $type=>$description )
+ $tmp[] = $this->format_output($output_type,$type,$description);
+ }
+
+ $num = 1;
+ foreach( $this->data as $data )
+ {
+ if( $num==1 )
+ {
+ $tmp[] = $this->format_output($output_type, 'values', $data);
+ }
+ else
+ {
+ $tmp[] = $this->format_output($output_type,'values_'. $num, $data);
+ }
+
+ $num++;
+ }
+
+ $num = 1;
+ foreach( $this->links as $link )
+ {
+ if( $num==1 )
+ {
+ $tmp[] = $this->format_output($output_type, 'links', $link);
+ }
+ else
+ {
+ $tmp[] = $this->format_output($output_type,'links_'. $num, $link);
+ }
+
+ $num++;
+ }
+
+ if( count( $this->y2_lines ) > 0 )
+ {
+ $tmp[] = $this->format_output($output_type,'y2_lines',implode( ',', $this->y2_lines ));
+ //
+ // Should this be an option? I think so...
+ //
+ $tmp[] = $this->format_output($output_type,'show_y2','true');
+ }
+
+ if( count( $this->x_labels ) > 0 )
+ $tmp[] = $this->format_output($output_type,'x_labels',implode(',',$this->x_labels));
+ else
+ {
+ if( strlen($this->x_min) > 0 )
+ $tmp[] = $this->format_output($output_type,'x_min',$this->x_min);
+
+ if( strlen($this->x_max) > 0 )
+ $tmp[] = $this->format_output($output_type,'x_max',$this->x_max);
+ }
+
+ $tmp[] = $this->format_output($output_type,'y_min',$this->y_min);
+ $tmp[] = $this->format_output($output_type,'y_max',$this->y_max);
+
+ if( strlen($this->y2_min) > 0 )
+ $tmp[] = $this->format_output($output_type,'y2_min',$this->y2_min);
+
+ if( strlen($this->y2_max) > 0 )
+ $tmp[] = $this->format_output($output_type,'y2_max',$this->y2_max);
+
+ if( strlen( $this->bg_colour ) > 0 )
+ $tmp[] = $this->format_output($output_type,'bg_colour',$this->bg_colour);
+
+ if( strlen( $this->bg_image ) > 0 )
+ {
+ $tmp[] = $this->format_output($output_type,'bg_image',$this->bg_image);
+ $tmp[] = $this->format_output($output_type,'bg_image_x',$this->bg_image_x);
+ $tmp[] = $this->format_output($output_type,'bg_image_y',$this->bg_image_y);
+ }
+
+ if( strlen( $this->x_axis_colour ) > 0 )
+ {
+ $tmp[] = $this->format_output($output_type,'x_axis_colour',$this->x_axis_colour);
+ $tmp[] = $this->format_output($output_type,'x_grid_colour',$this->x_grid_colour);
+ }
+
+ if( strlen( $this->y_axis_colour ) > 0 )
+ $tmp[] = $this->format_output($output_type,'y_axis_colour',$this->y_axis_colour);
+
+ if( strlen( $this->y_grid_colour ) > 0 )
+ $tmp[] = $this->format_output($output_type,'y_grid_colour',$this->y_grid_colour);
+
+ if( strlen( $this->y2_axis_colour ) > 0 )
+ $tmp[] = $this->format_output($output_type,'y2_axis_colour',$this->y2_axis_colour);
+
+ if( strlen( $this->x_offset ) > 0 )
+ $tmp[] = $this->format_output($output_type,'x_offset',$this->x_offset);
+
+ if( strlen( $this->inner_bg_colour ) > 0 )
+ {
+ $values = $this->inner_bg_colour;
+ if( strlen( $this->inner_bg_colour_2 ) > 0 )
+ {
+ $values .= ','. $this->inner_bg_colour_2;
+ $values .= ','. $this->inner_bg_angle;
+ }
+ $tmp[] = $this->format_output($output_type,'inner_background',$values);
+ }
+
+ if( strlen( $this->pie ) > 0 )
+ {
+ $tmp[] = $this->format_output($output_type,'pie',$this->pie);
+ $tmp[] = $this->format_output($output_type,'values',$this->pie_values);
+ $tmp[] = $this->format_output($output_type,'pie_labels',$this->pie_labels);
+ $tmp[] = $this->format_output($output_type,'colours',$this->pie_colours);
+ $tmp[] = $this->format_output($output_type,'links',$this->pie_links);
+ }
+
+ if( strlen( $this->tool_tip ) > 0 )
+ $tmp[] = $this->format_output($output_type,'tool_tip',$this->tool_tip);
+
+
+
+ if( strlen( $this->y_format ) > 0 )
+ $tmp[] = $this->format_output($output_type,'y_format',$this->y_format);
+
+ if( strlen( $this->num_decimals ) > 0 )
+ $tmp[] = $this->format_output($output_type,'num_decimals',$this->num_decimals);
+
+ if( strlen( $this->is_fixed_num_decimals_forced ) > 0 )
+ $tmp[] = $this->format_output($output_type,'is_fixed_num_decimals_forced',$this->is_fixed_num_decimals_forced);
+
+ if( strlen( $this->is_decimal_separator_comma ) > 0 )
+ $tmp[] = $this->format_output($output_type,'is_decimal_separator_comma',$this->is_decimal_separator_comma);
+
+ if( strlen( $this->is_thousand_separator_disabled ) > 0 )
+ $tmp[] = $this->format_output($output_type,'is_thousand_separator_disabled',$this->is_thousand_separator_disabled);
+
+
+ $count = 1;
+ foreach( $this->data_sets as $set )
+ {
+ $tmp[] = $set->toString( $output_type, $count>1?'_'.$count:'' );
+ $count++;
+ }
+
+ if($output_type == 'js')
+ {
+ $tmp[] = 'so.write("my_chart' . $this->occurence . '");';
+ $tmp[] = '</script>';
+ }
+
+ return implode("\r\n",$tmp);
+ }
+}
+
+class bar
+{
+ var $colour;
+ var $alpha;
+ var $data;
+ var $links;
+ var $_key;
+ var $key;
+ var $key_size;
+ var $var;
+
+ function bar( $alpha, $colour )
+ {
+ $this->var = 'bar';
+
+ $this->alpha = $alpha;
+ $this->colour = $colour;
+ $this->data = array();
+ $this->links = array();
+ $this->_key = false;
+ }
+
+ function key( $key, $size )
+ {
+ $this->_key = true;
+ $this->key = graph::esc( $key );
+ $this->key_size = $size;
+ }
+
+ function add( $data, $link )
+ {
+ $this->data[] = $data;
+ $this->links[] = $link;
+ }
+
+ // return the variables for this
+ // bar chart
+ function _get_variable_list()
+ {
+ $values = array();
+ $values[] = $this->alpha;
+ $values[] = $this->colour;
+
+ if( $this->_key )
+ {
+ $values[] = $this->key;
+ $values[] = $this->key_size;
+ }
+
+ return $values;
+ }
+
+ function toString( $output_type, $set_num )
+ {
+ $values = implode( ',', $this->_get_variable_list() );
+
+ $tmp = array();
+
+ if( $output_type == 'js' )
+ {
+ $tmp[] = 'so.addVariable("'. $this->var .'","'. $values . '");';
+
+ $tmp[] = 'so.addVariable("values'. $set_num .'","'. implode( ',', $this->data ) .'");';
+
+ if( count( $this->links ) > 0 )
+ $tmp[] = 'so.addVariable("values'. $set_num .'","'. implode( ',', $this->links ) .'");';
+
+ }
+ else
+ {
+ $tmp[] = '&'. $this->var. $set_num .'='. $values .'&';
+ $tmp[] = '&values'. $set_num .'='. implode( ',', $this->data ) .'&';
+
+ if( count( $this->links ) > 0 )
+ $tmp[] = '&links'. $set_num .'='. implode( ',', $this->links ) .'&';
+ }
+
+ return implode( "\r\n", $tmp );
+ }
+
+}
+
+class bar_3d extends bar
+{
+ function bar_3d( $alpha, $colour )
+ {
+ parent::bar( $alpha, $colour );
+ $this->var = 'bar_3d';
+ }
+}
+
+class bar_fade extends bar
+{
+ function bar_fade( $alpha, $colour )
+ {
+ parent::bar( $alpha, $colour );
+ $this->var = 'bar_fade';
+ }
+}
+
+class bar_outline extends bar
+{
+ var $outline_colour;
+
+ function bar_outline( $alpha, $colour, $outline_colour )
+ {
+ parent::bar( $alpha, $colour );
+ $this->var = 'filled_bar';
+ $this->outline_colour = $outline_colour;
+ }
+
+ // override the base method
+ function _get_variable_list()
+ {
+ $values = array();
+ $values[] = $this->alpha;
+ $values[] = $this->colour;
+ $values[] = $this->outline_colour;
+
+ if( $this->_key )
+ {
+ $values[] = $this->key;
+ $values[] = $this->key_size;
+ }
+
+ return $values;
+ }
+}
+
+class bar_glass extends bar_outline
+{
+ function bar_glass( $alpha, $colour, $outline_colour )
+ {
+ parent::bar_outline( $alpha, $colour, $outline_colour );
+ $this->var = 'bar_glass';
+ }
+}
+
+//
+// this has an outline colour and a 'jiggle' parameter
+// called offset
+//
+class bar_sketch extends bar_outline
+{
+ var $offset;
+
+ function bar_sketch( $alpha, $offset, $colour, $outline_colour )
+ {
+ parent::bar_outline( $alpha, $colour, $outline_colour );
+ $this->var = 'bar_sketch';
+ $this->offset = $offset;
+ }
+
+ // override the base method
+ function _get_variable_list()
+ {
+ $values = array();
+ $values[] = $this->alpha;
+ $values[] = $this->offset;
+ $values[] = $this->colour;
+ $values[] = $this->outline_colour;
+
+ if( $this->_key )
+ {
+ $values[] = $this->key;
+ $values[] = $this->key_size;
+ }
+
+ return $values;
+ }
+}
+
+class candle
+{
+ var $out;
+
+ function candle( $high, $open, $close, $low )
+ {
+ $this->out = array();
+ $this->out[] = $high;
+ $this->out[] = $open;
+ $this->out[] = $close;
+ $this->out[] = $low;
+ }
+
+ function toString()
+ {
+ return '['. implode( ',', $this->out ) .']';
+ }
+}
+
+class hlc
+{
+ var $out;
+
+ function hlc( $high, $low, $close )
+ {
+ $this->out = array();
+ $this->out[] = $high;
+ $this->out[] = $low;
+ $this->out[] = $close;
+ }
+
+ function toString()
+ {
+ return '['. implode( ',', $this->out ) .']';
+ }
+}
+
+class point
+{
+ var $out;
+
+ function point( $x, $y, $size_px )
+ {
+ $this->out = array();
+ $this->out[] = $x;
+ $this->out[] = $y;
+ $this->out[] = $size_px;
+ }
+
+ function toString()
+ {
+ return '['. implode( ',', $this->out ) .']';
+ }
+}
+
\ No newline at end of file
Modified: trunk/plugins/Home/Controller.php
===================================================================
--- trunk/plugins/Home/Controller.php 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/plugins/Home/Controller.php 2008-01-19 15:41:52 UTC (rev 196)
@@ -63,6 +63,8 @@
$view->dataTableOutlinks = $this->getOutlinks( true );
/* General visits */
+ $view->graphLastVisits = $this->getLastVisitsGraph( true );
+
$dataTableVisit = $this->getVisitsSummary();
$view->nbUniqVisitors = $dataTableVisit->getColumn('nb_uniq_visitors');
$view->nbVisits = $dataTableVisit->getColumn('nb_visits');
@@ -107,6 +109,8 @@
/* Referers */
+ $view->graphLastDistinctKeywords = $this->getLastDistinctKeywordsGraph(true);
+
$view->dataTableRefererType = $this->getRefererType(true);
$view->dataTableKeywords = $this->getKeywords(true);
$view->dataTableSearchEngines = $this->getSearchEngines(true);
@@ -288,13 +292,29 @@
*/
function getVisitsSummary()
{
- $requestString = 'method=' . "VisitsSummary.get" . '&format=original'.
- // we disable filters for example "search for pattern", in the case this method is called
- // by a method that already calls the API with some generic filters applied
+ $requestString = 'method=' . "VisitsSummary.get" . '&format=original'.
+ // we disable filters for example "search for pattern", in the case this method is called
+ // by a method that already calls the API with some generic filters applied
'&disable_generic_filters=true';
$request = new Piwik_API_Request($requestString);
return $request->process();
}
+
+ function getLastVisitsGraph( $fetch = false )
+ {
+ require_once "ViewDataTable/Graph.php";
+ $view = Piwik_ViewDataTable::factory(null, 'graphEvolution');
+ $view->init( __FUNCTION__, "VisitsSummary.getVisits" );
+ return $this->renderView($view, $fetch);
+ }
+ function getLastDistinctKeywordsGraph( $fetch = false )
+ {
+ require_once "ViewDataTable/Graph.php";
+ $view = Piwik_ViewDataTable::factory(null, 'graphEvolution');
+ $view->init( __FUNCTION__, "Referers.getNumberOfDistinctKeywords" );
+ return $this->renderView($view, $fetch);
+ }
+
/**
* VisitFrequency
*/
Modified: trunk/plugins/Home/templates/cloud.tpl
===================================================================
--- trunk/plugins/Home/templates/cloud.tpl 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/plugins/Home/templates/cloud.tpl 2008-01-19 15:41:52 UTC (rev 196)
@@ -61,6 +61,8 @@
{$value.wordTruncated}{/if}{if false !== $labelDetails[$value.word].url}</a>{/if}</span>
{/foreach}
{/if}
-{include file="Home/templates/datatable_footer.tpl"}
+{if $showFooter}
+ {include file="Home/templates/datatable_footer.tpl"}
+{/if}
</div>
</div>
\ No newline at end of file
Modified: trunk/plugins/Home/templates/datatable.tpl
===================================================================
--- trunk/plugins/Home/templates/datatable.tpl 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/plugins/Home/templates/datatable.tpl 2008-01-19 15:41:52 UTC (rev 196)
@@ -30,6 +30,8 @@
</tbody>
</table>
{/if}
- {include file="Home/templates/datatable_footer.tpl"}
+ {if $showFooter}
+ {include file="Home/templates/datatable_footer.tpl"}
+ {/if}
{/if}
</div>
\ No newline at end of file
Modified: trunk/plugins/Home/templates/datatable_actions.tpl
===================================================================
--- trunk/plugins/Home/templates/datatable_actions.tpl 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/plugins/Home/templates/datatable_actions.tpl 2008-01-19 15:41:52 UTC (rev 196)
@@ -30,7 +30,9 @@
</table>
{/if}
- {include file="Home/templates/datatable_footer.tpl"}
+ {if $showFooter}
+ {include file="Home/templates/datatable_footer.tpl"}
+ {/if}
{/if}
</div>
\ No newline at end of file
Modified: trunk/plugins/Home/templates/graph.tpl
===================================================================
--- trunk/plugins/Home/templates/graph.tpl 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/plugins/Home/templates/graph.tpl 2008-01-19 15:41:52 UTC (rev 196)
@@ -1,14 +1,15 @@
<div id="{$id}" class="parentDiv">
{$jsInvocationTag}
<br/><br/>
-<small>
-<form name="urlForm" id="{$formId}">
+
+<form class="formEmbedCode" id="{$formId}">
Embed <input name="embed_code" value="{$codeEmbed}" onclick="javascript:document.getElementById('{$formId}').embed_code.focus();document.getElementById('{$formId}').embed_code.select();" readonly="true" type="text">
| <a target="_blank" href="{$urlData}">Graph data</a>
</form>
-</small>
-
-{include file="Home/templates/datatable_footer.tpl"}
+{if $showFooter}
+ {include file="Home/templates/datatable_footer.tpl"}
+{/if}
+
</div>
\ No newline at end of file
Modified: trunk/plugins/Home/templates/index.tpl
===================================================================
--- trunk/plugins/Home/templates/index.tpl 2008-01-18 17:18:40 UTC (rev 195)
+++ trunk/plugins/Home/templates/index.tpl 2008-01-19 15:41:52 UTC (rev 196)
@@ -154,12 +154,22 @@
font-weight: lighter;
}
-#messageToUsers, #messageToUsers a{
+#messageToUsers, #messageToUsers a {
color:red;
font-size:0.9em;
text-decoration : none;
width:100%;
}
+
+
+.formEmbedCode, .formEmbedCode a {
+ font-size: 10px;
+ text-decoration : none;
+}
+.formEmbedCode input {
+ background-color: #FBFDFF;
+ border: 1px solid #ECECEC;
+}
</style>
{/literal}
@@ -187,6 +197,10 @@
<span id="generatedMenu"></span>
<div class="section" id="Visits_summary">
+ <h3>Visits</h3>
+ {$graphLastVisits}
+
+ <h3>Report</h3>
<p>{$nbUniqVisitors} unique visitors</p>
<p>{$nbVisits} visits</p>
<p>{$nbActions} actions (page views)</p>
@@ -211,6 +225,10 @@
</div>
<div class="section" id="Referers">
+
+ <h3>Number of distinct keywords</h3>
+ {$graphLastDistinctKeywords}
+
<h3>Referer Type</h3>
{$dataTableRefererType}
More information about the Piwik-svn
mailing list