// Normalize

This commit is contained in:
rMalie
2012-01-25 14:40:12 +00:00
parent 8db038f0e8
commit ccbf3acc8d
21 changed files with 202 additions and 206 deletions
+18 -18
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -28,19 +28,19 @@
class ChartCore
{
protected static $poolId = 0;
protected $width = 600;
protected $height = 300;
// Time mode
protected $timeMode = false;
protected $from;
protected $to;
protected $format;
protected $granularity;
protected $curves = array();
/** @prototype void public static function init(void) */
public static function init()
{
@@ -50,13 +50,13 @@ class ChartCore
return true;
}
}
/** @prototype void public function __construct() */
public function __construct()
{
++self::$poolId;
}
/** @prototype void public function setSize(int $width, int $height) */
public function setSize($width, $height)
{
@@ -68,14 +68,14 @@ class ChartCore
public function setTimeMode($from, $to, $granularity)
{
$this->granularity = $granularity;
if (Validate::isDate($from))
$from = strtotime($from);
$this->from = $from;
if (Validate::isDate($to))
$to = strtotime($to);
$this->to = $to;
if ($granularity == 'd')
$this->format = '%d/%m/%y';
if ($granularity == 'w')
@@ -84,17 +84,17 @@ class ChartCore
$this->format = '%m/%y';
if ($granularity == 'y')
$this->format = '%y';
$this->timeMode = true;
}
public function getCurve($i)
{
if (!array_key_exists($i, $this->curves))
$this->curves[$i] = new Curve();
return $this->curves[$i];
}
/** @prototype void public function display() */
public function display()
{
@@ -112,7 +112,7 @@ class ChartCore
if (!$curve->getPoint($i))
$curve->setPoint($i, 0);
}
$jsCurves = array();
foreach ($this->curves as $curve)
$jsCurves[] = $curve->getValues($this->timeMode);
@@ -142,12 +142,12 @@ class Curve
$this->values = $values;
}
public function getValues($timeMode = false)
public function getValues($time_mode = false)
{
ksort($this->values);
$string = '';
foreach ($this->values as $key => $value)
$string .= '['.addslashes((string)$key).($timeMode ? '000' : '').','.(float)$value.'],';
$string .= '['.addslashes((string)$key).($time_mode ? '000' : '').','.(float)$value.'],';
return '{data:['.rtrim($string, ',').']'.(!empty($this->label) ? ',label:"'.$this->label.'"' : '').''.(!empty($this->type) ? ','.$this->type : '').'}';
}
@@ -156,12 +156,12 @@ class Curve
{
$this->values[(string)$x] = (float)$y;
}
public function setLabel($label)
{
$this->label = $label;
}
public function setType($type)
{
$this->type = '';
@@ -170,7 +170,7 @@ class Curve
if ($type == 'steps')
$this->type = 'lines:{show:true,steps:true}';
}
public function getPoint($x)
{
if (array_key_exists((string)$x, $this->values))