趨勢小工具
目前的讀數,並將近期歷史繪製成迷你折線圖。最適合延遲、吞吐量、價格,以及任何值得放在脈絡中檢視的數字。
將在 app 版本 1.6 中推出
本節介紹的功能來自一個正在等待 App Store 審核的 app 更新。更新上線後,此處會自動解鎖。
Fields
| Field | Type | Notes |
|---|---|---|
template | string | Required. Must be "trend" |
value | float | Required. The current reading, rendered large above the chart. Must be finite |
points | number[] | Required. The sparkline history, oldest first. Between 2 and 48 entries, each finite. Replaced wholesale on PATCH — re-send the whole window, not one new point (why) |
unit | string | Unit rendered after the value (e.g. "ms", "%", "req/s"). Max 32 characters |
min_value | float | Fixed lower bound of the chart. Must be less than max_value when both are sent |
max_value | float | Fixed upper bound of the chart. With either bound missing the widget auto-scales to the posted points |
trend | string | up / down / flat. Renders an inline arrow next to the value; it is your annotation, not derived from points |
label, subtitle, icon, accent_color, background_color, text_color | string | Shared content fields — see the API reference |
Example: p95 latency
PATCH /widgets/api-latency
{
"content": {
"template": "trend",
"value": 371,
"unit": "ms",
"points": [312, 305, 298, 310, 322, 331, 340, 336, 329, 348, 355, 362, 371],
"label": "p95 latency",
"subtitle": "api-gateway · last hour",
"icon": "waveform.path.ecg",
"accent_color": "teal",
"trend": "up"
}
}Behavior
Points are plotted left to right in the order you send them, so the last entry sits under the
current reading — keep value and the final point in agreement or the chart appears to
lag the number above it. Without min_value and max_value the chart scales
to whatever range the posted points span, which makes a flat series look dramatic; set both bounds
when you want consecutive updates to stay visually comparable (an SLO ceiling, a 0 – 100 percentage).