Ejemplo n.º 1
0
 public function freshChart()
 {
     $db = new MoboDB();
     $c = $db->selectOpenBug();
     //包含所有数据的array
     //得到categories
     $version = array();
     foreach ($c as $key => $val) {
         if (in_array($val['version'], $version) == 0) {
             array_push($version, $val['version']);
         }
     }
     //得到series 1级bug
     $p = array();
     foreach ($c as $key => $val) {
         if ((int) $val['p'] == 1) {
             for ($i = 0; $i < count($version); $i++) {
                 if ($version[$i] == $val['version']) {
                     $p[$i] = (double) $val['num'];
                 }
             }
         }
     }
     $p1 = array();
     for ($i = 0; $i < count($version); $i++) {
         if (array_key_exists($i, $p)) {
             array_push($p1, (double) $p[$i]);
         } else {
             array_push($p1, 0);
         }
     }
     //得到series 2级bug
     $p = array();
     foreach ($c as $key => $val) {
         if ((int) $val['p'] == 2) {
             for ($i = 0; $i < count($version); $i++) {
                 if ($version[$i] == $val['version']) {
                     $p[$i] = (double) $val['num'];
                 }
             }
         }
     }
     $p2 = array();
     for ($i = 0; $i < count($version); $i++) {
         if (array_key_exists($i, $p)) {
             array_push($p2, (double) $p[$i]);
         } else {
             array_push($p2, 0);
         }
     }
     //得到series 3级bug
     $p = array();
     foreach ($c as $key => $val) {
         if ((int) $val['p'] == 3) {
             for ($i = 0; $i < count($version); $i++) {
                 if ($version[$i] == $val['version']) {
                     $p[$i] = (double) $val['num'];
                 }
             }
         }
     }
     $p3 = array();
     for ($i = 0; $i < count($version); $i++) {
         if (array_key_exists($i, $p)) {
             array_push($p3, (double) $p[$i]);
         } else {
             array_push($p3, 0);
         }
     }
     //得到series 4级bug
     $p = array();
     foreach ($c as $key => $val) {
         if ((int) $val['p'] == 4) {
             for ($i = 0; $i < count($version); $i++) {
                 if ($version[$i] == $val['version']) {
                     $p[$i] = (double) $val['num'];
                 }
             }
         }
     }
     $p4 = array();
     for ($i = 0; $i < count($version); $i++) {
         if (array_key_exists($i, $p)) {
             array_push($p4, (double) $p[$i]);
         } else {
             array_push($p4, 0);
         }
     }
     $chart["xAxis"] = array("categories" => $version);
     $chart["series"] = array(array("name" => "1级bug", "type" => "column", "yAxis" => 1, "data" => $p1), array("name" => "2级bug", "type" => "column", "yAxis" => 1, "data" => $p2), array("name" => "3级bug", "type" => "column", "yAxis" => 1, "data" => $p3), array("name" => "4级bug", "type" => "column", "yAxis" => 1, "data" => $p4));
     return $chart;
 }
Ejemplo n.º 2
0
 /**
  * 从其他数据源获取数据
  */
 public function freshChart()
 {
     $db = new MoboDB();
     $c = $db->selectOpenBug();
     //包含所有数据的array
     //得到categories
     $version = array();
     foreach ($c as $key => $val) {
         if (in_array($val['version'], $version) == 0) {
             array_push($version, $val['version']);
         }
     }
     //得到series 1级bug
     $p = array();
     foreach ($c as $key => $val) {
         if ((int) $val['p'] == 1) {
             for ($i = 0; $i < count($version); $i++) {
                 if ($version[$i] == $val['version']) {
                     $p[$i] = (double) $val['num'];
                 }
             }
         }
     }
     $p1 = array();
     for ($i = 0; $i < count($version); $i++) {
         if (array_key_exists($i, $p)) {
             array_push($p1, (double) $p[$i]);
         } else {
             array_push($p1, 0);
         }
     }
     //得到series 2级bug
     $p = array();
     foreach ($c as $key => $val) {
         if ((int) $val['p'] == 2) {
             for ($i = 0; $i < count($version); $i++) {
                 if ($version[$i] == $val['version']) {
                     $p[$i] = (double) $val['num'];
                 }
             }
         }
     }
     $p2 = array();
     for ($i = 0; $i < count($version); $i++) {
         if (array_key_exists($i, $p)) {
             array_push($p2, (double) $p[$i]);
         } else {
             array_push($p2, 0);
         }
     }
     //得到series 3级bug
     $p = array();
     foreach ($c as $key => $val) {
         if ((int) $val['p'] == 3) {
             for ($i = 0; $i < count($version); $i++) {
                 if ($version[$i] == $val['version']) {
                     $p[$i] = (double) $val['num'];
                 }
             }
         }
     }
     $p3 = array();
     for ($i = 0; $i < count($version); $i++) {
         if (array_key_exists($i, $p)) {
             array_push($p3, (double) $p[$i]);
         } else {
             array_push($p3, 0);
         }
     }
     //得到series 4级bug
     $p = array();
     foreach ($c as $key => $val) {
         if ((int) $val['p'] == 4) {
             for ($i = 0; $i < count($version); $i++) {
                 if ($version[$i] == $val['version']) {
                     $p[$i] = (double) $val['num'];
                 }
             }
         }
     }
     $p4 = array();
     for ($i = 0; $i < count($version); $i++) {
         if (array_key_exists($i, $p)) {
             array_push($p4, (double) $p[$i]);
         } else {
             array_push($p4, 0);
         }
     }
     //得到series DI值
     $DI = array();
     for ($i = 0; $i < count($version); $i++) {
         $val = $p1[$i] * 10 + $p2[$i] * 3 + $p3[$i] * 1 + $p4[$i] * 0.1;
         array_push($DI, (double) $val);
     }
     //将bug个数四舍五入
     for ($i = 0; $i < count($p1); $i++) {
         $p1[$i] = round($p1[$i]);
         $p2[$i] = round($p2[$i]);
         $p3[$i] = round($p3[$i]);
         $p4[$i] = round($p4[$i]);
     }
     $this->chart->data["xAxis"] = array("categories" => $version);
     $this->chart->data["series"] = array(array("name" => "1级bug", "type" => "column", "yAxis" => 1, "data" => $p1), array("name" => "2级bug", "type" => "column", "yAxis" => 1, "data" => $p2), array("name" => "3级bug", "type" => "column", "yAxis" => 1, "data" => $p3), array("name" => "4级bug", "type" => "column", "yAxis" => 1, "data" => $p4), array("name" => "未关闭bugDI值", "color" => "#89A54E", "type" => "spline", "data" => $DI));
     return $this->chart->getChartJson();
 }