0

I'm trying to build a graph for example of a code taken from the documentation:

Highcharts::widget([
   'options'=>'{
      "title": { "text": "Fruit Consumption" },
      "xAxis": {
         "categories": ["Apples", "Bananas", "Oranges"]
      },
      "yAxis": {
         "title": { "text": "Fruit eaten" }
      },
      "series": [
         { "name": "Jane", "data": [1, 0, 4] },
         { "name": "John", "data": [5, 7,3] }
      ]
   }'
]);

I form an array for series like this:

public function collectDataFromQuery($array) {

    $resultData = [];

    foreach ($array as $arrayItem) {

        $resultData[$arrayItem['idinvite']]['name'] = $arrayItem['address'];
        $resultData[$arrayItem['idinvite']]['data'][] = $arrayItem['fromwhere'];
    }
    return $resultData;
}

And in the end I get this json

{
    "series": {
        "217": {
            "name": "https://zen.yandex.ru/example.ru",
            "data": ["35", "27425"]
        },
        "233": {
            "name": "https://news.google.com/publications/example",
            "data": ["6", "19817"]
        },
        "106": {
            "name": "https://www.facebook.com/example/",
            "data": ["9", "6848"]
        },
        "232": {
            "name": "https://news.yandex.ru/index.html?from=rubric&favid=example",
            "data": ["3", "4748"]
        },
        "118": {
            "name": "http://instagram.com/example",
            "data": ["7", "16439"]
        },
        "45": {
            "name": "https://chat.whatsapp.com/example",
            "data": ["10", "22222"]
        },
        "158": {
            "name": "https://chat.whatsapp.com/example",
            "data": ["3", "2272"]
        },
        "1": {
            "name": "http://t-do.ru/example",
            "data": ["268"]
        },
        "117": {
            "name": "https://twitter.com/example",
            "data": ["190"]
        },
        "115": {
            "name": "https://vk.com/example",
            "data": ["223"]
        },
        "116": {
            "name": "https://ok.ru/example",
            "data": ["2743"]
        },
        "119": {
            "name": "http://chats.viber.com/example",
            "data": ["345"]
        },
        "188": {
            "name": "https://tamtam.chat/example",
            "data": ["209"]
        },
        "156": {
            "name": "http://t-do.ru/example",
            "data": ["8"]
        },
        "157": {
            "name": "http://t-do.ru/example",
            "data": ["118"]
        },
        "0": {
            "name": "",
            "data": ["7"]
        },
        "231": {
            "name": "https://news.yandex.ru/example",
            "data": ["1"]
        }
    }
}

In xAxis: categories I insert following data:

{
    "xAxis": {
        "categories": {
            "0": "2018-10-01",
            "7": "2018-09-01"
        }
    }
}

But according to this data the schedule is not built. I assume that the problem may be due to the indexes, but I do not know how to get rid of them and whether they really matter. Please give me advice what I'm doing wrong

0 Answers0