[增添]增添了Metric的inline chart显示

This commit is contained in:
makotocc0107
2024-09-04 15:41:38 +08:00
committed by Coding
parent a0122ba345
commit 9740869781

View File

@@ -14,10 +14,11 @@ class MetricWidgetChart extends InlineChartWidget
protected static ?string $maxHeight = '65px'; protected static ?string $maxHeight = '65px';
// public int $maxWidth = 1000; // public int $maxWidth = 1000;
protected function getData(): array protected function getData(): array
{ {
$prometheus = new PrometheusService(); $prometheus = new PrometheusService();
date_default_timezone_set('Asia/Shanghai');
$query1 = $this->record->name . '{data="real"}'; $query1 = $this->record->name . '{data="real"}';
@@ -52,6 +53,10 @@ class MetricWidgetChart extends InlineChartWidget
} }
} }
// 将数据格式化为 InlineChartWidget 所需的格式
// $formattedRealData = $this->formatData($realdata, 'Real Data');
return [ return [
'labels' => $labels, 'labels' => $labels,
'datasets' => [ 'datasets' => [