0

I'm using angularjs-nvd3-directives to create stacked area chart. Now my problem is I'm polling hundreds of data from server and I need to display on the the N latest data. How will I do that?

Here's the HTML file

<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>
user3714598
  • 1,733
  • 5
  • 28
  • 45

1 Answers1

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" 
  ...
>
burtelli
  • 153
  • 9