Joomla query for monthly result in a graph

by Adeola Adeoti   Last Updated February 27, 2017 14:10 PM

I have this query below and it gives me the result attached as result.jpg but I want to generate the report on a monthly basis. I have attached the expected result as monthly.jpgResultMonthly


                
                
                

                
                Body system
                
                
                Number of cases
                

                
                -->

                
                getQuery(true);

                        // Select all records from the user profile table where key begins with "custom.".
                        // Order it by the ordering field.
                        $query->select($db->quoteName('condition'));
                        $query->from($db->quoteName('#__consultations'));
                            $query->where('(state = 1)');
                            if ($date_from) 
                            $query->where($db->quoteName('date_issue') . ' >= "'.$date_from.'"');
                        if ($date_to) 
                            $query->where($db->quoteName('date_issue') . ' setQuery($query);

                        // Load the results as a list of stdClass objects (see later for more options on retrieving data).
                        $results = $db->loadColumn();
                        $incident_level = "";
                        foreach ($results as $condition) {
                            if ($condition) {
                                $injuries = json_decode($condition);
                                $incident_level.= implode(",",$injuries).",";
                            }
                            //var_dump($injuries);
                            //echo "
"; //$incident_level = array_merge($incident_level, $injuries); } //$incident_level = explode (",",$incident_level); $incident_level = array_map('intval', explode(',',$incident_level)); //var_dump($incident_level); $counts = array_count_values($incident_level); ?> getQuery(true); // Select all records from the user profile table where key begins with "custom.". // Order it by the ordering field. $query->select('*'); $query->from($db->quoteName('#__conditions')); $query->where($db->quoteName('state') . ' = 1'); $query->order('ordering ASC'); // Reset the query using our newly populated query object. $db->setQuery($query); // Load the results as a list of stdClass objects (see later for more options on retrieving data). $health_condition = $db->loadObjectList(); foreach ($health_condition as $i => $item) : ?> id] "> escape($item->name); ?> id]; ?> google.charts.load("current", {packages:["corechart"]}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Task', 'Hours per Month'], $item) { if ($counts[$item->id] > 0) { ?> ['name; ?>', id]; ?>], ]); var options = { title: 'Health conditions' }; var chart = new google.visualization.ColumnChart(document.getElementById('columnchart_values')); chart.draw(data, options); } id]; ?>


Related Questions



passing an array from view to controller to model

Updated March 11, 2018 17:10 PM