0

我正在使用 angularjs-nvd3-directives 创建堆积面积图。现在我的问题是我正在从服务器轮询数百个数据,我需要在 N 个最新数据上显示。我将如何做到这一点?

这是HTML文件

<div ng-controller="GraphController as viewAll">    
<nvd3-stacked-area-chart    data="viewAll.data"     
id="graph"  showXAxis="true"    showYAxis="true"    
showLegend="true"   interactive="true"  
tooltips="true"     forcex="[xFunction()]">         
<svg></svg>     </nvd3-stacked-area-chart> </div>
4

1 回答 1

0

Try to define a second array that holds only the last N values and pass that as the 'data' parameter instead of the full data array.

  $scope.viewAll.visData = $scope.viewAll.data.slice(Math.max($scope.viewAll.data.length - N, 1))

In your html:

<nvd3-stacked-area-chart 
  data="viewAll.visData" 
  ...
>
于 2015-03-23T08:32:38.890 回答