javascript - converting json data in angularjs module into array and plot using c3 chart -


i generate x-y plot based on json data feed using angularjs. json data shown in code below (eq magnitude vs time). how can convert data array format , plot in c3 chart (such 1 in link http://c3js.org/samples/data_json.html)?

thank help.

var array1 = [];      var app = angular.module('myapp',[]);  app.controller('eqfeed',function($scope,$http){      $http.get("https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_day.geojson").then(function(response) {          $scope.eq=response.data.features;          });  });
<!doctype html>  <html>  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>        <body>  <div ng-app="myapp" ng-controller="eqfeed">  <table>      <tr ng-repeat="x in eq">          <td>{{x.properties.time | date:'yyyy-mm-dd hh:mm:ss'}}</td>          <td>{{x.properties.mag}}</td>      </tr>  </table>      </div>             </body>      </html>

this seems duplicate. have data , define x-axis timeseries.

var chart = c3.generate({         data: {             x: "time",             json: {                 time: eq.properties.time,                 data: eq.properties.mag             }         },         axis:{             x:{                 type: "timeseries",                 tick:{                     format:"%y-%m-%d %h:%m:%s"                 }             }         }     }); 

and in html have chart.

<div id="chart"></div> 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -