0

I am trying to display customer registration info. I am wrapping the data and passing inside the highchart, but the data what I am passing is not getting displayed. Any help/advice greatly appreciated.

Angularjs:

.controller('ctrl',['$scope','$http',function($scope,$http){            
  $http({
    url: '//customerinformation',
    method: 'GET'
  })
  .then(
    function successCallback(response){
        $scope.users = response.data.customers;
        loadChartData(response.data.customers);
    },
    function errorCallback(response){
        console.log('Error:' + response.data);
  });


  function loadChartData(data) {
      $scope.chartOptions =  {
        chart: { type: 'column' },
        title: { text: 'Customer Information' },
        xAxis: { categories: ['Jan', 'Feb', 'Mar','Apr','May','June','July','Aug','Sep','Oct','Nov','Dec'] },
        yAxis: { title: { text: 'No.of customer' } },
        series: [{ 
         name: 'customer', 
         data: data 
        }]
      };
  }    
}])
5
  • Could you show your response.data.customers details? Maybe format is wrong? It should be array of points, where values are numbers. Commented Mar 29, 2018 at 13:24
  • You can simpally push your response data into a new array and use that array in your data . Commented Mar 29, 2018 at 13:51
  • plnkr.co/edit/IXozG3jHOfr88zzapPhe?p=preview @PawełFus Commented Mar 29, 2018 at 14:05
  • I tried pushing through array, but it din't worked @sahil0021 Commented Mar 29, 2018 at 14:11
  • 1
    You have to close your callback method after the loadChartData method. maybe this link help link Commented Mar 29, 2018 at 14:19

1 Answer 1

1

You need to provide format supported by Highcharts. customers and months means nothing :)

Use x, y, name etc. properties (details: https://api.highcharts.com/highcharts/series.column.data ).

You can simply map your data: data: data.map(point => [point.month, point.customers]) or data: data.map(point => { name: point.month, y: point.customers })

Now you can remove categories from xAxis and set type: xAxis: { type: 'category' }

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.