├── .gitignore ├── app ├── code │ └── community │ │ └── Onilab │ │ └── GoogleCharts │ │ ├── Helper │ │ └── Data.php │ │ ├── Block │ │ └── Adminhtml │ │ │ └── Dashboard │ │ │ ├── Tab │ │ │ ├── Amounts.php │ │ │ └── Orders.php │ │ │ └── Graph.php │ │ └── etc │ │ └── config.xml ├── etc │ └── modules │ │ └── Onilab_GoogleCharts.xml └── design │ └── adminhtml │ └── default │ └── default │ ├── layout │ └── onilab │ │ └── google_charts.xml │ └── template │ └── onilab │ └── google_charts │ ├── scripts.phtml │ └── dashboard │ └── graph.phtml ├── composer.json ├── modman └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /app/code/community/Onilab/GoogleCharts/Helper/Data.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | community 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/design/adminhtml/default/default/layout/onilab/google_charts.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ]]> 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Magento 2.x support: 2 | ===================== 3 | 4 | The repo for Magento 2 version of our module is available in the new repository of the module : [https://github.com/onilab/magento-2-google-api-chart-fix/](https://github.com/onilab/magento-2-google-api-chart-fix/). 5 | 6 | About this module: 7 | =================== 8 | 9 | https://onilab.com/blog/chart-broken-in-magento-1-2-admin-dashboard-reasons-hotfix/ 10 | 11 | Installation: 12 | =============== 13 | 14 | 1. Copy files to your Magento root path 15 | 2. Clear all caches 16 | 3. Go to the dashboard 17 | 4. Enjoy 18 | 19 | 20 | What Magento version is supported? 21 | ----------------------------------- 22 | 23 | The module has been successfully deployed and tested against the following Magento versions: 24 | * Magento EE 1.14 25 | * Magento CE 1.9 26 | 27 | 28 | Bugs / RFC 29 | ---------- 30 | 31 | Don't hesitate to: 32 | 33 | * Submit a bug, RFC, idea of new feature 34 | * Submit a merge request 35 | 36 | -------------------------------------------------------------------------------- /app/code/community/Onilab/GoogleCharts/Block/Adminhtml/Dashboard/Tab/Amounts.php: -------------------------------------------------------------------------------- 1 | setHtmlId('amounts'); 13 | parent::__construct(); 14 | } 15 | 16 | /** 17 | * Prepare chart data 18 | * 19 | * @return void 20 | */ 21 | protected function _prepareData() 22 | { 23 | $this->setDataHelperName('adminhtml/dashboard_order'); 24 | $this->getDataHelper()->setParam('store', $this->getRequest()->getParam('store')); 25 | $this->getDataHelper()->setParam('website', $this->getRequest()->getParam('website')); 26 | $this->getDataHelper()->setParam('group', $this->getRequest()->getParam('group')); 27 | 28 | $this->setDataRows('revenue'); 29 | $this->_axisMaps = array( 30 | 'x' => 'range', 31 | 'y' => 'revenue' 32 | ); 33 | 34 | parent::_prepareData(); 35 | } 36 | 37 | public function getTitle() 38 | { 39 | return $this->__('Amounts'); 40 | } 41 | } -------------------------------------------------------------------------------- /app/code/community/Onilab/GoogleCharts/Block/Adminhtml/Dashboard/Tab/Orders.php: -------------------------------------------------------------------------------- 1 | setHtmlId('orders'); 13 | parent::__construct(); 14 | } 15 | 16 | /** 17 | * Prepare chart data 18 | * 19 | * @return void 20 | */ 21 | protected function _prepareData() 22 | { 23 | $this->setDataHelperName('adminhtml/dashboard_order'); 24 | $this->getDataHelper()->setParam('store', $this->getRequest()->getParam('store')); 25 | $this->getDataHelper()->setParam('website', $this->getRequest()->getParam('website')); 26 | $this->getDataHelper()->setParam('group', $this->getRequest()->getParam('group')); 27 | 28 | $this->setDataRows('quantity'); 29 | $this->_axisMaps = array( 30 | 'x' => 'range', 31 | 'y' => 'quantity' 32 | ); 33 | 34 | parent::_prepareData(); 35 | } 36 | 37 | public function getTitle() 38 | { 39 | return $this->__('Orders'); 40 | } 41 | } -------------------------------------------------------------------------------- /app/code/community/Onilab/GoogleCharts/etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 0.0.3 6 | 7 | 8 | 9 | 10 | 11 | Onilab_GoogleCharts_Helper 12 | 13 | 14 | 15 | 16 | 17 | Onilab_GoogleCharts_Block_Adminhtml_Dashboard_Graph 18 | Onilab_GoogleCharts_Block_Adminhtml_Dashboard_Tab_Orders 19 | Onilab_GoogleCharts_Block_Adminhtml_Dashboard_Tab_Amounts 20 | 21 | 22 | 23 | Onilab_GoogleCharts_Block 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | onilab/google_charts.xml 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/code/community/Onilab/GoogleCharts/Block/Adminhtml/Dashboard/Graph.php: -------------------------------------------------------------------------------- 1 | setTemplate($this->_getTabTemplate()); 12 | } 13 | 14 | /** 15 | * Get tab template 16 | * 17 | * @return string 18 | */ 19 | protected function _getTabTemplate() 20 | { 21 | return 'onilab/google_charts/dashboard/graph.phtml'; 22 | } 23 | 24 | public function getChartData() 25 | { 26 | $this->_allSeries = $this->getRowsData($this->_dataRows); 27 | 28 | foreach ($this->_axisMaps as $axis => $attr) { 29 | $this->setAxisLabels($axis, $this->getRowsData($attr, true)); 30 | } 31 | 32 | $timezoneLocal = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE); 33 | 34 | list ($dateStart, $dateEnd) = Mage::getResourceModel('reports/order_collection') 35 | ->getDateRange($this->getDataHelper()->getParam('period'), '', '', true); 36 | 37 | $dateStart->setTimezone($timezoneLocal); 38 | $dateEnd->setTimezone($timezoneLocal); 39 | 40 | $dates = array(); 41 | $datas = array(); 42 | 43 | while ($dateStart->compare($dateEnd) < 0) { 44 | switch ($this->getDataHelper()->getParam('period')) { 45 | case '24h': 46 | $d = $dateStart->toString('yyyy-MM-dd HH:00'); 47 | $dateStart->addHour(1); 48 | break; 49 | case '7d': 50 | case '1m': 51 | $d = $dateStart->toString('yyyy-MM-dd'); 52 | $dateStart->addDay(1); 53 | break; 54 | case '1y': 55 | case '2y': 56 | $d = $dateStart->toString('yyyy-MM'); 57 | $dateStart->addMonth(1); 58 | break; 59 | } 60 | foreach ($this->getAllSeries() as $index => $serie) { 61 | if (in_array($d, $this->_axisLabels['x'])) { 62 | $datas[$index][] = (float)array_shift($this->_allSeries[$index]); 63 | } else { 64 | $datas[$index][] = 0; 65 | } 66 | } 67 | $dates[] = strtotime($d); 68 | } 69 | 70 | return [$datas, $dates]; 71 | } 72 | } -------------------------------------------------------------------------------- /app/design/adminhtml/default/default/template/onilab/google_charts/scripts.phtml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/design/adminhtml/default/default/template/onilab/google_charts/dashboard/graph.phtml: -------------------------------------------------------------------------------- 1 | 27 |
28 |

__('Select Range') ?>: 29 |

35 |
36 | getWidth()}px;height:{$this->getHeight()}px; margin:0 auto;"; 38 | ?> 39 | getCount()): ?> 40 | 41 |

42 | __('Check for updates at ') ?> GitHub 43 | 115 | 116 |

__('No Data Found') ?>

117 | 118 |
119 | --------------------------------------------------------------------------------