-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Improve dashboard charts - migrate to chart.js #26923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
magento-engcom-team
merged 12 commits into
magento:2.4-develop
from
Bartlomiejsz:feature/dashboards_charts
Mar 24, 2020
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d00b206
Improve dashboard charts - migrate to chart.js
Bartlomiejsz 5da031e
Remove unnecessary chart.js files, move retrieving request params to …
Bartlomiejsz d48cc2f
improvement: cover Chart with integration test
Nazar65 e45bb96
fix incorrect namespace
Nazar65 820d3a4
improve widget name
Nazar65 2d63d4f
Exclude chart.js from js bundling
Bartlomiejsz c6f5f81
Merge branch '2.4-develop' into feature/dashboards_charts
lenaorobei f6d047a
fix expected count items
Nazar65 1ac6b5d
remove unstable cas on tests
Nazar65 c724d3c
refactor assertion to avoid unstable data
Nazar65 cd5dfa6
Merge branch '2.4-develop' into feature/dashboards_charts
lenaorobei 7fc4e5c
Integration test fix
lenaorobei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
|
||
/** | ||
* Adminhtml dashboard diagram tabs | ||
* @deprecated dashboard graphs were migrated to dynamic chart.js solution | ||
* @see dashboard.diagrams in adminhtml_dashboard_index.xml | ||
* | ||
* @author Magento Core Team <[email protected]> | ||
*/ | ||
|
@@ -18,6 +20,8 @@ class Diagrams extends \Magento\Backend\Block\Widget\Tabs | |
protected $_template = 'Magento_Backend::widget/tabshoriz.phtml'; | ||
|
||
/** | ||
* Internal constructor, that is called from real constructor | ||
* | ||
* @return void | ||
*/ | ||
protected function _construct() | ||
|
@@ -28,6 +32,8 @@ protected function _construct() | |
} | ||
|
||
/** | ||
* Preparing global layout | ||
* | ||
* @return $this | ||
*/ | ||
protected function _prepareLayout() | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ | |
|
||
/** | ||
* Adminhtml dashboard google chart block | ||
* @deprecated dashboard graphs were migrated to dynamic chart.js solution | ||
* @see dashboard.chart.amounts and dashboard.chart.orders in adminhtml_dashboard_index.xml | ||
* | ||
* @author Magento Core Team <[email protected]> | ||
*/ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,21 +3,29 @@ | |
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Backend\Block\Dashboard; | ||
|
||
use Magento\Backend\Block\Dashboard\Tab\Products\Ordered; | ||
use Magento\Backend\Block\Widget\Tabs; | ||
|
||
/** | ||
* Adminhtml dashboard bottom tabs | ||
* | ||
* @api | ||
* @author Magento Core Team <[email protected]> | ||
*/ | ||
class Grids extends \Magento\Backend\Block\Widget\Tabs | ||
class Grids extends Tabs | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $_template = 'Magento_Backend::widget/tabshoriz.phtml'; | ||
|
||
/** | ||
* Internal constructor, that is called from real constructor | ||
* | ||
* @return void | ||
*/ | ||
protected function _construct() | ||
|
@@ -49,7 +57,7 @@ protected function _prepareLayout() | |
[ | ||
'label' => __('Bestsellers'), | ||
'content' => $this->getLayout()->createBlock( | ||
\Magento\Backend\Block\Dashboard\Tab\Products\Ordered::class | ||
Ordered::class | ||
)->toHtml(), | ||
'active' => true | ||
] | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,36 +5,42 @@ | |
*/ | ||
namespace Magento\Backend\Block\Dashboard\Orders; | ||
|
||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Backend\Helper\Data; | ||
use Magento\Framework\Module\Manager; | ||
use Magento\Reports\Model\ResourceModel\Order\CollectionFactory; | ||
|
||
/** | ||
* Adminhtml dashboard recent orders grid | ||
* | ||
* @api | ||
ihor-sviziev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @author Magento Core Team <[email protected]> | ||
* @SuppressWarnings(PHPMD.DepthOfInheritance) | ||
*/ | ||
class Grid extends \Magento\Backend\Block\Dashboard\Grid | ||
{ | ||
/** | ||
* @var \Magento\Reports\Model\ResourceModel\Order\CollectionFactory | ||
* @var CollectionFactory | ||
*/ | ||
protected $_collectionFactory; | ||
|
||
/** | ||
* @var \Magento\Framework\Module\Manager | ||
* @var Manager | ||
*/ | ||
protected $_moduleManager; | ||
|
||
/** | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Magento\Backend\Helper\Data $backendHelper | ||
* @param \Magento\Framework\Module\Manager $moduleManager | ||
* @param \Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory | ||
* @param Context $context | ||
* @param Data $backendHelper | ||
* @param Manager $moduleManager | ||
* @param CollectionFactory $collectionFactory | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Backend\Helper\Data $backendHelper, | ||
\Magento\Framework\Module\Manager $moduleManager, | ||
\Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory, | ||
Context $context, | ||
Data $backendHelper, | ||
Manager $moduleManager, | ||
CollectionFactory $collectionFactory, | ||
array $data = [] | ||
) { | ||
$this->_moduleManager = $moduleManager; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,35 +3,42 @@ | |
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Backend\Block\Dashboard; | ||
|
||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Framework\Module\Manager; | ||
use Magento\Reports\Model\ResourceModel\Order\CollectionFactory; | ||
|
||
/** | ||
* Adminhtml dashboard sales statistics bar | ||
* | ||
* @api | ||
* @author Magento Core Team <[email protected]> | ||
*/ | ||
class Sales extends \Magento\Backend\Block\Dashboard\Bar | ||
class Sales extends Bar | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $_template = 'Magento_Backend::dashboard/salebar.phtml'; | ||
|
||
/** | ||
* @var \Magento\Framework\Module\Manager | ||
* @var Manager | ||
*/ | ||
protected $_moduleManager; | ||
|
||
/** | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory | ||
* @param \Magento\Framework\Module\Manager $moduleManager | ||
* @param Context $context | ||
* @param CollectionFactory $collectionFactory | ||
* @param Manager $moduleManager | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory, | ||
\Magento\Framework\Module\Manager $moduleManager, | ||
Context $context, | ||
CollectionFactory $collectionFactory, | ||
Manager $moduleManager, | ||
array $data = [] | ||
) { | ||
$this->_moduleManager = $moduleManager; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,15 @@ | |
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Backend\Block\Dashboard\Tab; | ||
|
||
/** | ||
* Adminhtml dashboard order amounts diagram | ||
* @deprecated dashboard graphs were migrated to dynamic chart.js solution | ||
* @see dashboard.chart.amounts in adminhtml_dashboard_index.xml | ||
* | ||
* @author Magento Core Team <[email protected]> | ||
*/ | ||
namespace Magento\Backend\Block\Dashboard\Tab; | ||
|
||
class Amounts extends \Magento\Backend\Block\Dashboard\Graph | ||
{ | ||
/** | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,15 @@ | |
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Backend\Block\Dashboard\Tab; | ||
|
||
/** | ||
* Adminhtml dashboard orders diagram | ||
* @deprecated dashboard graphs were migrated to dynamic chart.js solution | ||
* @see dashboard.chart.orders in adminhtml_dashboard_index.xml | ||
* | ||
* @author Magento Core Team <[email protected]> | ||
*/ | ||
namespace Magento\Backend\Block\Dashboard\Tab; | ||
|
||
class Orders extends \Magento\Backend\Block\Dashboard\Graph | ||
{ | ||
/** | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,39 +3,42 @@ | |
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Adminhtml dashboard totals bar | ||
* | ||
* @author Magento Core Team <[email protected]> | ||
*/ | ||
namespace Magento\Backend\Block\Dashboard; | ||
|
||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Framework\Module\Manager; | ||
use Magento\Reports\Model\ResourceModel\Order\Collection; | ||
use Magento\Reports\Model\ResourceModel\Order\CollectionFactory; | ||
use Magento\Store\Model\Store; | ||
|
||
/** | ||
* Totals block. | ||
* Adminhtml dashboard totals bar | ||
* @api | ||
*/ | ||
class Totals extends \Magento\Backend\Block\Dashboard\Bar | ||
class Totals extends Bar | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $_template = 'Magento_Backend::dashboard/totalbar.phtml'; | ||
|
||
/** | ||
* @var \Magento\Framework\Module\Manager | ||
* @var Manager | ||
*/ | ||
protected $_moduleManager; | ||
|
||
/** | ||
* @param \Magento\Backend\Block\Template\Context $context | ||
* @param \Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory | ||
* @param \Magento\Framework\Module\Manager $moduleManager | ||
* @param Context $context | ||
* @param CollectionFactory $collectionFactory | ||
* @param Manager $moduleManager | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory, | ||
\Magento\Framework\Module\Manager $moduleManager, | ||
Context $context, | ||
CollectionFactory $collectionFactory, | ||
Manager $moduleManager, | ||
array $data = [] | ||
) { | ||
$this->_moduleManager = $moduleManager; | ||
|
@@ -60,7 +63,7 @@ protected function _prepareLayout() | |
); | ||
$period = $this->getRequest()->getParam('period', '24h'); | ||
|
||
/* @var $collection \Magento\Reports\Model\ResourceModel\Order\Collection */ | ||
/* @var $collection Collection */ | ||
$collection = $this->_collectionFactory->create()->addCreateAtPeriodFilter( | ||
$period | ||
)->calculateTotals( | ||
|
@@ -80,7 +83,7 @@ protected function _prepareLayout() | |
} elseif (!$collection->isLive()) { | ||
$collection->addFieldToFilter( | ||
'store_id', | ||
['eq' => $this->_storeManager->getStore(\Magento\Store\Model\Store::ADMIN_CODE)->getId()] | ||
['eq' => $this->_storeManager->getStore(Store::ADMIN_CODE)->getId()] | ||
); | ||
} | ||
} | ||
|
@@ -94,5 +97,7 @@ protected function _prepareLayout() | |
$this->addTotal(__('Tax'), $totals->getTax()); | ||
$this->addTotal(__('Shipping'), $totals->getShipping()); | ||
$this->addTotal(__('Quantity'), $totals->getQuantity() * 1, true); | ||
|
||
return $this; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.