formatting-insight-axes
它能做什么
本技能为 PostHog 洞察设置坐标轴格式,使数字显示清晰的单位,例如秒、分钟或百分比。适合用时间或比率数值制作图表的分析师。
适用场景
- ✓当你正打算仅为了显示为分钟或百分比而去做除法的时候。
- ✓当你想让图表坐标轴以易读的单位显示时间值时。
- ✓当你想让 SQL 洞察的某一列显示单位,但不改变数字时。
技能链接
https://github.com/PostHog/posthog/blob/master/products/product_analytics/skills/formatting-insight-axes/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请在图表中以分钟显示平均响应时间,但不要改变数字。”
每周 5 个新技能,1 分钟读完。
工作原理
它会设置内置的坐标轴格式,而不是添加除法运算或固定的文字后缀。格式化工具会为每个数值选择易读的单位,而底层数字保持正确。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Formatting insight axes
PostHog renders insights with a built-in axis formatter. Use it instead of contorting the query or a literal prefix/postfix to fake units.
The two insight kinds configure it in different places:
- TrendsQuery —
trendsFilter.aggregationAxisFormat(this page, below) - SQL insights (
DataVisualizationNode) — per-columnsettings.formatting(see SQL insights)
The anti-pattern
If you are reaching for any of these, stop and pick a format below first:
formula: "A / 60"withaggregationAxisPostfix: " mins"— manual seconds -> minutesformula: "A / 1000"withaggregationAxisPostfix: " s"— manual ms -> secondsformula: "A * 100"withaggregationAxisPostfix: "%"— manual ratio -> percentaggregationAxisPostfix: "ms"/"s"/"min"/"hr"on raw values
These freeze the unit at one scale. The built-in formatter picks a friendly unit per value (1.5s, 2m 12s, 1h 4m) and keeps the underlying series numerically correct for further math, breakdowns, and alerts.
Available formats
Set trendsFilter.aggregationAxisFormat on the TrendsQuery:
| Value | Use when the series is... | Renders as |
|---|---|---|
numeric (default) |
a plain count | 1,234 |
duration |
seconds (any scale) | 45s, 2m 12s, 1h 4m |
duration_ms |
milliseconds | 850ms, 1.5s, 1m 4s |
percentage |
already 0-100 | 47.3% |
percentage_scaled |
a ratio 0-1 | 47.3% |
currency |
money in the project's base currency | $1,234.56 (or local code) |
short |
large counts you want compacted | 1.2K, 3.4M |
Companion fields on trendsFilter:
aggregationAxisPrefix— literal prefix (e.g."$") when you need a symbol pinned to a specific currency or unit, regardless of project settingsaggregationAxisPostfix— literal suffix; reserve for genuine units the format can't express (e.g." req"," events"), never for"mins"/"s"/"%"— the percentage formats already append the%sign, so a"%"postfix renders50%%decimalPlaces— cap decimals (1 or 2 is usually right for currency / ratios)
Currency — pick format or prefix carefully
aggregationAxisFormat: "currency" renders with the project's base currency
(set in project settings, defaults to USD). Use it when the underlying values
are in that same currency — e.g. revenue events that PostHog auto-converts to
the project's base currency.
If the values are pinned to a specific currency regardless of project (e.g.
$ai_total_cost_usd is always USD, even on a EUR-base project), use
aggregationAxisPrefix: "$" + decimalPlaces: 2 so the symbol matches the
data. Using format: "currency" here would render USD values with € on a
EUR project.
When the series is in seconds
If the series is in seconds (latency, session length, time-to-first-event,
processing time, page load, etc.), silently default to
aggregationAxisFormat: "duration". Do not stop to ask — the formatter is
non-destructive (the underlying values stay in seconds either way, only the
labels change), so picking it is always at least as good as raw seconds.
Only confirm with the user when they have explicitly named a fixed unit they want pinned ("show this in minutes", "graph the average in hours"):
"I can pin the y-axis to minutes by dividing the series by 60, or use PostHog's
durationformatter which auto-picks seconds / minutes / hours per value —90srenders as1m 30sand5400sas1h 30m. Which would you prefer?"
In one-shot MCP contexts where no user is in the loop, just pick duration
and move on.
Examples
Latency — duration in milliseconds
{
"kind": "TrendsQuery",
"series": [
{
"kind": "EventsNode",
"event": "$pageview",
"math": "p95",
"math_property": "$performance_page_loaded"
}
],
"trendsFilter": {
"aggregationAxisFormat": "duration_ms"
}
}
Average session length — duration in seconds
{
"kind": "TrendsQuery",
"series": [
{
"kind": "E
常见问题
为什么不添加公式来转换单位?
固定换算会把单位锁定在一种刻度上,而内置格式会根据每个数值自动调整,并保证数据仍可用于其他计算。
这适用于 SQL 洞察吗?
适用。SQL 洞察可以在其图表设置中为每一列设置格式。
它会改变我的数字吗?
不会。只改变显示方式,数值在计算上仍然正确。
详情
作者的原始描述
Pick the right y-axis unit when creating or updating an insight via `posthog:insight-create` or `posthog:insight-update` — both TrendsQuery (`trendsFilter.aggregationAxisFormat`) and SQL insights (`DataVisualizationNode`, `chartSettings.yAxis[].settings.formatting`). Use when the agent is about to add a `formula` purely to convert units (e.g. dividing seconds by 60 to display minutes), when a `math_property` or SQL column is a duration, currency, ratio, or large count, or whenever the user mentions "format the y-axis", "duration", "seconds", "minutes", "hours", "milliseconds", "ms", "percentag
repo: PostHog/posthog
热度
- GitHub 星标
- 41k
- 排名
- #6903
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
depot-ci
41k帮你的智能体设置并运行 Depot CI 工作流(GitHub Actions 的替代方案),包括迁移现有工作流和读取运行日志。
depot-container-builds
41k帮你的智能体在 Depot 的远程构建器上构建 Docker 镜像,包括多平台镜像、推送到镜像仓库,以及修复构建失败。
depot-github-runners
41k帮你的智能体把 GitHub Actions 任务迁移到 Depot 托管的运行器上,选择运行器规格和标签,并排查运行器设置问题。
editing-agents-md
41k帮你的智能体判断某条规则应写入 AGENTS.md 还是 CLAUDE.md,并以不会让文件臃肿的方式写下,确保规则真正生效。