fix: special trend should show most recent data, order desc then reverse for chart display

This commit is contained in:
2026-04-22 00:15:46 +08:00
parent 79f1a1dc80
commit bd881f239e
+6 -3
View File
@@ -370,12 +370,15 @@ class History extends Model
*/
public function getSpecialTrend($periods = 30)
{
$history = $this->field('expect,num7')->order('openTime', 'asc')->limit($periods)->select();
if (empty($history)) return ['expects' => [], 'specials' => [], 'colors' => []];
$num_model = new Num();
$colorMap = $num_model->column('color', 'num');
// 先取最近 $periods 条数据
$history = $this->field('expect,num7,openTime')->order('openTime', 'desc')->limit($periods)->select();
if (empty($history)) return ['expects' => [], 'specials' => [], 'colors' => []];
// 反转,使数据从左到右为从远到近
$history = array_reverse($history);
$expects = []; $specials = []; $colors = [];
foreach ($history as $row) {
$expects[] = (string)$row['expect'];