Added graph axis title according to date range

This commit is contained in:
Shreesh Arora
2024-05-17 17:35:33 +05:30
parent 3cb96190ad
commit 0beaafdb87
3 changed files with 4 additions and 4 deletions

View File

@@ -77,6 +77,7 @@ abstract class ModuleGraphCore extends Module
if (is_callable(array($this, 'setDayValues'))) {
$this->setDayValues($layers);
}
$this->_titles['x'][] = $this->l('Time');
}
// If the granularity is inferior to 1 month
// @TODO : change to manage 28 to 31 days
@@ -110,6 +111,7 @@ abstract class ModuleGraphCore extends Module
if (is_callable(array($this, 'setMonthValues'))) {
$this->setMonthValues($layers);
}
$this->_titles['x'][] = $this->l('Date');
}
// If the granularity is less than 1 year
elseif (strtotime('-1 year', strtotime($this->_employee->stats_date_to)) < strtotime($this->_employee->stats_date_from)) {
@@ -141,6 +143,7 @@ abstract class ModuleGraphCore extends Module
if (is_callable(array($this, 'setYearValues'))) {
$this->setYearValues($layers);
}
$this->_titles['x'][] = $this->l('Month');
}
// If the granularity is greater than 1 year
else {
@@ -163,6 +166,7 @@ abstract class ModuleGraphCore extends Module
if (is_callable(array($this, 'setAllTimeValues'))) {
$this->setAllTimeValues($layers);
}
$this->_titles['x'][] = $this->l('Year');
}
}

View File

@@ -358,7 +358,6 @@ class StatsProduct extends ModuleGraph
}
$this->_titles['main'][] = $this->l('Room nights');
$this->_titles['main'][] = $this->l('Views (x100)');
$this->_titles['x'] = $this->l('Date');
$this->_titles['y'] = $this->l('Room nights, Views (x100)');
$this->_formats['y'] = 'd';

View File

@@ -190,7 +190,6 @@ class StatsRegistrations extends ModuleGraph
protected function setYearValues($layers)
{
$this->_titles['x'][] = $this->l('Month');
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query.$this->getDate());
foreach ($result as $row) {
$mounth = (int)substr($row['date_add'], 5, 2);
@@ -203,7 +202,6 @@ class StatsRegistrations extends ModuleGraph
protected function setMonthValues($layers)
{
$this->_titles['x'][] = $this->l('Date');
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query.$this->getDate());
foreach ($result as $row) {
$this->_values[(int)Tools::substr($row['date_add'], 8, 2)]++;
@@ -212,7 +210,6 @@ class StatsRegistrations extends ModuleGraph
protected function setDayValues($layers)
{
$this->_titles['x'][] = $this->l('Time');
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query.$this->getDate());
foreach ($result as $row) {
$this->_values[(int)Tools::substr($row['date_add'], 11, 2)]++;