Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get data from rest service using D3

I have a working web service at http://localhost/RestService/GetTransactionByStatus/1. When I run that URL on my browser I'm getting the correct JSON-formatted response:

{
    "transactionConcil"      : "TRANSACTIONS OK",
    "numTransactionConcil"   : 0,
    "transactionNoConcil"    : "TRANSACTIONS NOT OK",
    "numTransactionNoConcil" : 0
}

How can I manage this REST service in order to present the correct data in my browser using a web service? The data is going to be managed dynamically so the information that is going to be displayed depends on the ID (last param in the URL).

like image 749
kennechu Avatar asked Aug 26 '15 21:08

kennechu


People also ask

What does d3 CSV return?

d3. csv() returns the data as an object. This object is an array of objects loaded from your csv file where each object represents one row of your csv file.

What does d3 JSON return?

The function d3. json() is an asynchronous function that directly returns (with an undefined value I assume). Only when the data is received from the backend, the callback function you passed to it will be called.

Is the syntax to read JSON data in d3?

Syntax: d3. json(input[, init]);


1 Answers

Look at the documentation. Here is an example:

d3.json('http://localhost/RestService/GetTransactionByStatus/' + id, function(data) {
    console.log(data.transactionConcil);
});
like image 56
schrieveslaach Avatar answered Sep 20 '22 12:09

schrieveslaach