title: matching data from sql and assigned them to echarts
body: <p><strong>This is my sql query</strong></p>
  
  <pre><code>SELECT WEEKDAY(C.created_date) as date_label, COUNT(C.consignment_id) as deliveries, C.service_id, CS.display_name
  FROM (`consignments` as C)
  LEFT JOIN `courier_service` as CS ON `CS`.`id`=`C`.`service_id`
  WHERE `C`.`org_id` =  165
  AND (created_date &gt;= '2017-06-25' AND created_date &lt;= '2017-12-13')
  AND `C`.`is_deleted` =  0
  AND `C`.`is_service_assigned` =  1
  GROUP BY `date_label`, `C`.`service_id`
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/cu6LW.png" rel="nofollow noreferrer">This is my query results.</a></p>
  
  <p>I am creating a line chart with echarts. What should i do in order to match the data in my php controller so that [0] which is monday have 3 deliveries ? </p>
  
  <p>My php code</p>
  
  <pre><code>$label = array();
  $weektrendlist = array();
  foreach($services as $service) {
      $listname = array("0" =&gt; 0, "1" =&gt; 0, "2" =&gt; 0, "3" =&gt; 0, "4" =&gt; 0, "5" =&gt; 0, "6" =&gt; 0);
  
      $weektrendinfobyservice = $this-&gt;overall_reports_model-&gt; overall_performance_week_trend_per_service($service-&gt;service_id, $start_date, $end_date, $org_id);
  
      foreach($weektrendinfobyservice as $row) {
          $listname[$row-&gt;date_label] = $row-&gt;deliveries;
      }
      $dataset = array();
      $dataset['name'] = $service-&gt;display_name;
      $hash = md5($service-&gt;service_id.$service-&gt;service_name);
  
      $dataset['data'] = array_values($listname);
      $weektrendlist[] = $dataset;
  }
  $result['weektrend'] = array(
      "label" =&gt; array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"),
      "datasets" =&gt; $weektrendlist
  );
  </code></pre>