public function actionSearchclose() { if (\Yii::$app->request->post()) { $brand = $_POST['brand'] == ' ' ? '%%' : $_POST['brand']; $brand1 = $_POST['brand1'] == ' ' ? '%%' : $_POST['brand1']; $tabain = $_POST['tabain'] == ' ' ? '%%' : $_POST['tabain']; // $model = Vcarclose::find()->where(['like','brand',$brand])->all(); $modelcount = Vcarclose::find()->where(['LIKE', 'brand', $brand])->andWhere(['LIKE', 'o1', $brand1])->andWhere(['LIKE', 'tabain', $tabain])->count(); $model = Vcarclose::find()->where(['LIKE', 'brand', $brand])->andWhere(['LIKE', 'o1', $brand1])->andWhere(['LIKE', 'tabain', $tabain])->all(); $searchModel = new DashboardSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); // if($modelcount>0){ return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'carclose' => $model, 'modelcount' => $modelcount]); // }else{ // } } }
// { // array_push($xdata, (int)$val->close); // }else{ // array_push($xdata, 0); // } // } // $dataamt[] = $xdata; // var_dump($dataamt); } $seri = []; $len = count($titlename); for ($a = 0; $a <= $len - 1; $a++) { $xdata = []; for ($c = 1; $c <= 12; $c++) { $xcount = Vcarclose::find()->where(['month' => $c, 'tabain' => $titlename[$a]])->count(); $val = Vcarclose::find()->where(['month' => $c, 'tabain' => $titlename[$a]])->one(); if ($xcount > 0) { array_push($xdata, (int) $val->close); } else { array_push($xdata, 0); } } //[] = $xdata; array_push($seri, ['name' => $titlename[$a], 'data' => $xdata]); // array_push($seri, ['name'=>$titlename[$a],'data'=>[(int)$dataamt[$a],0,0,0,0,0,0,0,0,0,0,0]]); } // $titlename = $model->brand; echo Highcharts::widget(['options' => ['title' => ['text' => ''], 'xAxis' => ['title' => ['text' => ''], 'categories' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']], 'yAxis' => ['title' => ['text' => 'ราคาจบ'], 'gridLineColor' => '#cccccc', 'type' => 'linear'], 'series' => $seri, 'credits' => ['enabled' => false], 'chart' => ['type' => 'scatter']]]); ?> </div><!-- /.box-body --> </div><!-- /.box -->