Create HighCharts-Column type from JSON

前端 未结 1 1777
Happy的楠姐
Happy的楠姐 2021-01-16 17:03

I am trying to create a column type highchart using data from json in the following format:

[{\"id\":7,\"dateV\":\"2015-11-16\",\"count\":10},{\"id\":6,\"dat         


        
1条回答
  •  不思量自难忘°
    2021-01-16 17:53

    You need to iterate over the json data and create category data and series by pushing values.

    var jsonData = [{"id":7,"dateV":"2015-11-16","count":10},{"id":6,"dateV":"2015-11-15","count":3},{"id":5,"dateV":"2015-11-14","count":15},{"id":4,"dateV":"2015-11-13","count":10},{"id":3,"dateV":"2015-11-12","count":6},{"id":2,"dateV":"2015-11-11","count":8},{"id":1,"dateV":"2015-11-10","count":5}]; 
    
     var categoryData= [];
     var seriesData= [];
    $.each(jsonData, function(i,item){
    seriesData.push(jsonData[i].count);
    categoryData.push(jsonData[i].dateV);
    console.log("seriesData"+JSON.stringify(seriesData));
    }); 
    

    See Working demo with your json here

    0 讨论(0)
提交回复
热议问题