how to plot multiline real time chart with ajax data using D3 js

Viewed 27

i want to plot multiline real time chart with data [{"channel":"activeCalls.g.5180077","avg_time":"120"},{"channel":"activeCalls.g.4604820","avg_time":"119.1"},{"channel":"activeCalls.g.201-hhealth","avg_time":"54.81578947368421"},{"channel":"activeCalls.g.205-hhealth","avg_time":"14.851851851851851"},{"channel":"activeCalls.g.4604792","avg_time":"115.33333333333333"},{"channel":"activeCalls.g.202-hhealth","avg_time":0},{"channel":"activeCalls.g.208-hhealth","avg_time":"9.75"},{"channel":"activeCalls.g.203-hhealth","avg_time":"43.266666666666666"},{"channel":"activeCalls.g.302-hhealth","avg_time":"81.35714285714286"},{"channel":"activeCalls.g.217-hhealth","avg_time":276},{"channel":"activeCalls.g.211-hhealth","avg_time":0},{"channel":"activeCalls.g.304-hhealth","avg_time":"246"},{"channel":"rsfdr23q2342q","avg_time":345},{"channel":"activeCalls.g.204-hhealth","avg_time":0},{"channel":"activeCalls.g.214-hhealth","avg_time":213},{"channel":"dsdfdfsdf","avg_time":65,{"channel":"gfgfgfdgdf","avg_time":0},{"channel":"activeCalls.g.206-hhealth","avg_time":0},{"channel":"activeCalls.g.009-hhealth","avg_time":0},{"channel":"activeCalls.g.007-hhealth","avg_time":0},{"channel":"activeCalls.g.300-hhealth","avg_time":0},]

I got this data from ajax and I want to call this ajax for every 5 min to plot this chart.

can anybody help me in plotting this graph?

thanks in advance for help.

1 Answers

You can do something like this :

    getData();
    d3.interval(getData, 300000);

    function getData() {
      d3.json("https://randomuser.me/api/").then(function(data) {
        console.log(JSON.stringify(data.results[0].name));
    })
    }

Related