API for coders REST API
JavaScript
How to use PlotAPI with JavaScript.
In this demonstration, we'll use some sample data to create an interactive PlotAPI Chord diagram with JavaScript.
params = {
matrix: [
[0, 5, 6, 4, 7, 4],
[5, 0, 5, 4, 6, 5],
[6, 5, 0, 4, 5, 5],
[4, 4, 4, 0, 5, 5],
[7, 6, 5, 5, 0, 4],
[4, 5, 5, 5, 4, 0]
],
names: ["Action", "Adventure", "Comedy", "Drama", "Fantasy", "Thriller"]
}
var authorizationBasic = window.btoa("api_key:" + your_api_key);
var request = new XMLHttpRequest();
request.open('POST', "https://plotapi.com/chord", true);
request.setRequestHeader('Content-Type', "application/json;charset=UTF-8");
request.setRequestHeader('Authorization', 'Basic ' + authorizationBasic);
request.setRequestHeader('Accept', 'application/json');
request.send(JSON.stringify(params));
request.onreadystatechange = function () {
if (request.readyState === 4) {
console.log(request.responseText);
}
};