2017-10-13 72 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轴范围。