I want show chart dashboard in month custom.Ex: I select 01/2017 that mean chart show from 01/01/2017 to 31/01/2017. I find function getChartUrl() in vendor\magento\module-backend\Block\Dashboard\Graph.php return url image of chart but i can not override it.
list($ dateStart, $ dateEnd) = $ this->_collectionFactory->create()->getDateRange( $ this->getDataHelper()->getParam('period'), '', '', true );
I find in vendor/magento/module-reports/Model/ResourceModel/Order/Collection.php can set custom date but in getChartUrl() have not. How custom it?
public function getDateRange($ range, $ customStart, $ customEnd, $ returnObjects = false) { $ dateEnd = new \DateTime(); $ dateStart = new \DateTime(); // go to the end of a day $ dateEnd->setTime(23, 59, 59); $ dateStart->setTime(0, 0, 0); switch ($ range) { case '24h': $ dateEnd = new \DateTime(); $ dateEnd->modify('+1 hour'); $ dateStart = clone $ dateEnd; $ dateStart->modify('-1 day'); break; case '7d': // substract 6 days we need to include // only today and not hte last one from range $ dateStart->modify('-6 days'); break; case '1m': $ dateStart->setDate( $ dateStart->format('Y'), $ dateStart->format('m'), $ this->_scopeConfig->getValue( 'reports/dashboard/mtd_start', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ) ); break; case 'custom': $ dateStart = $ customStart ? $ customStart : $ dateEnd; $ dateEnd = $ customEnd ? $ customEnd : $ dateEnd; break; case '1y': case '2y': $ startMonthDay = explode( ',', $ this->_scopeConfig->getValue( 'reports/dashboard/ytd_start', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ) ); $ startMonth = isset($ startMonthDay[0]) ? (int)$ startMonthDay[0] : 1; $ startDay = isset($ startMonthDay[1]) ? (int)$ startMonthDay[1] : 1; $ dateStart->setDate($ dateStart->format('Y'), $ startMonth, $ startDay); if ($ range == '2y') { $ dateStart->modify('-1 year'); } break; } if ($ returnObjects) { return [$ dateStart, $ dateEnd]; } else { return ['from' => $ dateStart, 'to' => $ dateEnd, 'datetime' => true]; } }