Просмотр исходного кода

Ticket #4933 - Analytics: Stopped working with JS errors.

AntonLV 1 год назад
Родитель
Сommit
86b7c95a47

+ 7 - 9
modules/boonex/analytics/classes/BxAnalyticsModule.php

@@ -473,17 +473,15 @@ class BxAnalyticsModule extends BxDolModule
                     )
                 ),
                 'scales' => array(
-                    'yAxes' => array(
-                        array(
-                            'ticks' => array(
-                                'max' => $iMaxValueY, 
-                                'min' => $iMinValueY, 
-                                'stepSize' => $this->getStep($iMinValueY, $iMaxValueY), 
-                                'autoSkip' => true
-                            )
+                    'y' => array(
+                        'ticks' => array(
+                            'max' => $iMaxValueY, 
+                            'min' => $iMinValueY, 
+                            'stepSize' => $this->getStep($iMinValueY, $iMaxValueY), 
+                            'autoSkip' => true
                         )
                     ),
-                    'xAxes' => array($aDataForChartXAxes)
+                    'x' => $aDataForChartXAxes
                 )
             ),
             'links' => $aValues['links'],

+ 5 - 2
modules/boonex/analytics/js/analytics.js

@@ -62,6 +62,9 @@ BxAnalytics.prototype.reloadData = function () {
     $sUrl = $this._sActionsUri + 'GetReportsData/' + $($this._sModuleSelector).val() + '/' + $($this._sReportSelector).val() + '/' + $($this._sDatePickerSelector).data('daterangepicker').startDate.format('YYYY-MM-DD') + '/' + $($this._sDatePickerSelector).data('daterangepicker').endDate.format('YYYY-MM-DD') + '/';
     $($this._sExportUrlSelector).attr('href', $sUrl + 'csv/');
     $.getJSON($sUrl, function (oData) {
+        if(Chart.defaults.global == undefined)
+            Chart.defaults.global = {};
+
         Chart.defaults.global.layout = {
             padding: {
                 left: 0,
@@ -110,7 +113,7 @@ BxAnalytics.prototype.dataToTable = function (oDataIn) {
     
     oData.datasets[0].data.forEach(function (oItemData, iDx) {
         var sTxt = "";
-        if (oDataIn.options.scales.xAxes[0].type == 'time')
+        if (oDataIn.options.scales.x.type == 'time')
             sTxt = oData.datasets[0].data[iDx].x;
         else{
             sTxt = oData.labels[iDx];
@@ -139,7 +142,7 @@ BxAnalytics.prototype.dataToTable = function (oDataIn) {
     $('.bx_analytics_table').html(sHtml);
 
     var $aOrder = [];
-    if (oDataIn.options.scales.xAxes[0].type == 'time') {
+    if (oDataIn.options.scales.x.type == 'time') {
         $aOrder = [[0, 'desc']];
     }
     $this._oTable = $('.bx_analytics_table').DataTable({ "stripeClasses": ['bx-def-color-bg-hl', ''], dom: '<"top"i>rt<"bottom"flp><"clear">', paging: true, searching: false, ordering: true, order: $aOrder });