'use strict';

angular.module('NodePackageComperatorApp')
  .controller('StatisticsCtrl', function ($scope, NodePackage) {
    var statisticSerie = {
      name: 'Keyword Distribution',
      data: [],
      dataLabels: {
        enabled: true,
        color: '#FFFFFF',
        style: {
          fontSize: '13px'
        }
      }
    };
    var navigator = {
      enabled: true,
      adaptToUpdatedData: false,
      series: {
        data: [],
        dataGrouping: {
          enabled: true
        }
      }
    };

    var xAxis = {
      type: 'linear',
      min: 1,
      allowDecimals: false,
      title: {
        text: 'Listed in packages'
      }
    };

    $scope.highchart = {
      options: {
        title: {
          text: 'Distribution of keywords in packages'
        },
        chart: {
          type: 'areaspline'
        },
        xAxis: xAxis,
        yAxis: {
          title: {
            text: 'Keywords'
          },
          type: 'logarithmic',
          minorTickInterval: 0
        },
        navigator: navigator
      },
      series: [statisticSerie],
      loading: true
    };
    NodePackage.statistics().$promise.then(function (statistics) {
      $scope.stats = statistics;
      var chartData = [];
      angular.forEach(statistics.distribution, function (item) {
        chartData.push([item._id, item.total]);
      });
      $scope.highchart.loading = false;
      statisticSerie.data = chartData;
      navigator.series.data = chartData;
      xAxis.max = chartData[chartData.length - 1][0];
    });

  });
@@ -191,24 +191,78 @@
   data: %5B%5D,%0A
+      dataGrouping: %7B%0A        smoothed: true%0A      %7D,%0A
       dataLa
@@ -382,24 +382,172 @@
     %7D%0A    %7D;
+%0A%0A    var xAxis = %7B%0A      type: 'linear',%0A      min: 1,%0A      allowDecimals: false,%0A      title: %7B%0A        text: 'Listed in packages'%0A      %7D%0A    %7D;
 %0A    var nav
@@ -684,27 +684,28 @@
    enabled: 
-tru
+fals
 e%0A        %7D%0A
@@ -715,163 +715,36 @@
    %7D
+,
 %0A    
-%7D;%0A%0A    var xAxis = %7B%0A      type: 'linear',%0A      min: 1,%0A      allowDecimals: false,%0A      title: %7B%0A        text: 'Listed in packages'%0A      %7D%0A    %7D;
+  xAxis: xAxis%0A    %7D;%0A
 %0A%0A  
@@ -779,24 +779,25 @@
  options: %7B%0A
+%0A
         titl
@@ -880,24 +880,49 @@
    chart: %7B%0A
+          zoomType: 'x',%0A
           ty

Improve statistics view.