<?php
namespace App\Model\model;
use DB;
class modelData{
public function change($type, $data) {
$dataSets = [
["X_data" => ["TK5-01","TK5-02","TK5-03","TK5-04","TK5-05"]],
["X_data" => ["TK5-06","TK5-07","TK5-08","TK5-09","TK5-10"]],
["X_data" => ["TK5-11","TK5-12","TK5-13","TK5-14"]],
["X_data" => ["TK5-15","TK5-16"]],
["X_data" => ["TK5-17","TK5-18"]],
["X_data" => ["TK5-19"]]
]; //X轴数据
$Y_data = [];
foreach ($dataSets as $key => $dataSet) {
$X_data[] = $dataSet["X_data"];
foreach ($dataSets as $k => $value) {
$result = DB::table('instruments_tuokong')->select('cumulative')->orderBy('create_time', 'desc')->where('code', $value)->first();
$Y_data[$key][] = $result->cumulative;
}
}
//var_dump($X_data,$Y_data);
return [$X_data,$Y_data];
$instruments = ['TK5-01', 'TK5-02', 'TK5-03', 'TK5-04', 'TK5-05', 'TK5-06', 'TK5-07', 'TK5-08', 'TK5-09', 'TK5-10', 'TK5-11', 'TK5-12', 'TK5-13', 'TK5-14', 'TK5-15', 'TK5-16', 'TK5-17', 'TK5-18', 'TK5-19'];
$numbers = [1, 2, 3, 4, 5, 6];
$data = [];
foreach ($instruments as $instrument) {
$instrumentData = [];
foreach ($numbers as $number) {
$result = DB::table('instruments_tuokong')->select('variation')->where('code', '=', $instrument)->whereIn('number', [$number])->get();
$instrumentData[] = $result[0]->variation;
}
$data[] = $instrumentData;
}
return [$data];
}
}