I
I
Ilya Rodionov2017-07-12 00:58:32
API
Ilya Rodionov, 2017-07-12 00:58:32

How to enter values ​​from api into Highcharts?

Dear users.
Tell me, please, how can I enter and correctly process the data received from api in json format, namely the value of the string "online" and how to build a graph using this value?
If you can, please attach your solution. Thanks in advance!!
API value: https://mcapi.ca/query/play.minesuperior.com/info (exactly the online line)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EverOne, 2017-07-12
@EverOne

I can hint

var json = [{
    "key": "Apples",
    "value": "4"
}, {
    "key": "Pears",
    "value": "7"
}, {
    "key": "Bananas",
    "value": "9"
}];

var processed_json = new Array();
$.map(json, function(obj, i) {
    processed_json.push([obj.key, parseInt(obj.value)]);
});
if (processed_json.length != 0) {
   loadJson();
}

function loadJson() {
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        xAxis: {
            type: "category"
        },
        series: [{
            data: processed_json
        }]
    });
}

You understand that this is some kind of work. ($)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question