How to arrange array to display on chart (chart)

0

This chart is intended to list the total number of monthly accesses per user type for the current year.

It is divided into 3 series, each series represents a type of user, within it has the total of hits of that type per month:

labels: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
series: [
    [100, 200, 120, 280, 150, 300, 350, 200, 180, 350, 420, 500], // Total Access Users
    [80, 150, 100, 180, 80, 250, 150, 280, 360, 450, 520, 650], // Total artists
    [30, 80, 40, 90, 50, 100, 70, 160, 220, 240, 280, 350], // total studios
]

I tried the following:

    public function get_monthly_accesses() {

        $current_year = date('Y');
        $responseseries = array();
        for ($j = 1; $j <= 3; $j++) {

            for ($i = 1; $i <= 12; $i++) {
                $query = "select count(date_login) as accesses from user_access as ua
inner join user_details as ud on ud.user = ua.user
inner join user as u on ua.user = u.id
where type = {$j} AND YEAR(date_login) = {$current_year} AND MONTH(date_login) = {$i}";

                $total = $this->db->query($query)->result()[0]->accesses;
                $responseseries[] = $total;
            }

        }

        echo '<pre>';
        var_dump(json_encode($responseseries));
        echo '</pre>';
        die;

        return json_encode($responseseries);
    }

The return is this:

string(147) "["0","0","0","0","0","0","0","0","0","0","7","0","0","0","0","0","0","0","0","0","0","1","13","0","0","0","0","0","0","0","0","0","0","2","10","0"]"

I'm not able to split this array to 3 to display on the chart.

    
asked by anonymous 23.11.2017 / 17:20

0 answers