2017-10-13 73 views
0

當我加載圖形時第一次縮放時,數據在角度dygraph中丟失。以下是截圖第一次在角度dygraph中丟失縮放數據

enter image description here

變焦

enter image description here

後,這裏是我的代碼

function getPopUpGraph() { 
     $scope.currentZoom = 1; 
     $scope.popUpGraph = {}; 
     $scope.popUpGraph = { 
      data: [], 
      options: { 
       labels: ["Date", $scope.selectedDataPoint.LegendName, "TrendLine"], 
       showPopover: false, 
       //customBars: true, 
       legend: "onmouseover", 
       highlightSeriesOpts: { 
        strokeWidth: 2, 
        strokeBorderWidth: 1 
       }, 
       animatedZooms: true, 
       interactionModel: Dygraph.defaultInteractionModel, 
       showRangeSelector: true, 
       rangeSelectorPlotLineWidth: 1, 
       rangeSelectorPlotStrokeColor: 'gray', 
       rangeSelectorPlotFillColor: 'gray', 
       highlightCircleSize: 4, 
       rangeSelectorAlpha: 0.9, 
       rangeSelectorForegroundLineWidth: 1.25, 
       rangeSelectorForegroundStrokeColor: 'dark gray', 
       visibility: [true, false], 
       series: { 
        'TrendLine': { 
         strokePattern: [3, 2, 3, 2] 
        }, 
       }, 
       //xlabel: 'Date', 
       ylabel: $scope.selectedDataPoint.Unit, 
       title: $scope.selectedDataPoint.LegendName, 
       legendEnabled: false, 
       colors: ["#ff0000"], 
       valueRange: null, 
       height: 300, 
       resizeEnabled: true, 
       strokeWidth: 2, 
       axes: { 
        x: { 
         axisLabelFormatter: function (d, gran) { 
          if ($scope.currentZoomLevel.name == '12h') { 
           return $filter('date')(d, 'h:mm a'); 
          } 
          else 
           return $filter('date')(d, 'MMM dd h:mm'); 
         }, 
         valueFormatter: function (ms) { 
          return $filter('date')(ms, 'M/d/yy h:mm a'); 
         } 
        } 
       }, 
       drawCallback: function (g, is_initial) { 
        if (g.dateWindow_) 
         myPopUpRange(g.dateWindow_) 
       } 
      } 
     } 
     $scope.getPopGraphData($scope.currentZoom, 0); 
    } 

數據從$ scope.getPopGraphData功能獲取。

Iam在這個主函數中調用一些其他函數。我認爲這不是問題。在角度dygraph的演示中,縮放後,範圍選擇器也在變化。所以數據顯示正確。在我的情況下,範圍選擇器在第一次縮放時不會改變。 任何解決方案?在此先感謝...

回答

0

我找到了解決方案。在getPopUpGraph()函數中,有一個缺點函數正在調用。在禁用myPopUpRange()函數時,它現在可以正常工作。 myPopUpRange()用於重置x軸值。但是沒有必要,因爲dygraph會自動分配x軸範圍。