Chuyển đến nội dung
Skillpedia
Phân tích và bảng tính41k · #6903

formatting-insight-axes

Skill này làm gì

Skill này đặt định dạng trục cho một insight PostHog để các con số hiển thị đơn vị rõ ràng, chẳng hạn giây, phút hoặc phần trăm. Nó dành cho nhà phân tích xây dựng biểu đồ có giá trị thời gian hoặc tỷ lệ.

Khi nào nên dùng

  • ✓Khi bạn chuẩn bị chia một giá trị chỉ để nó hiển thị theo phút hoặc dưới dạng phần trăm.
  • ✓Khi bạn muốn trục biểu đồ hiển thị giá trị thời gian bằng đơn vị dễ hiểu.
  • ✓Khi bạn muốn một cột insight SQL hiển thị đơn vị mà không thay đổi các con số.

Liên kết skill

https://github.com/PostHog/posthog/blob/master/products/product_analytics/skills/formatting-insight-axes/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/PostHog/posthog/blob/master/products/product_analytics/skills/formatting-insight-axes/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Hiển thị thời gian phản hồi trung bình trên biểu đồ của tôi theo phút, mà không thay đổi các con số.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill đặt định dạng trục có sẵn thay vì thêm phép chia hoặc hậu tố văn bản cố định. Bộ định dạng sau đó chọn một đơn vị dễ đọc cho từng giá trị, và các con số bên dưới vẫn chính xác.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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-column settings.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" with aggregationAxisPostfix: " mins" — manual seconds -> minutes
  • formula: "A / 1000" with aggregationAxisPostfix: " s" — manual ms -> seconds
  • formula: "A * 100" with aggregationAxisPostfix: "%" — manual ratio -> percent
  • aggregationAxisPostfix: "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 settings
  • aggregationAxisPostfix — 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 renders 50%%
  • 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 duration formatter which auto-picks seconds / minutes / hours per value — 90s renders as 1m 30s and 5400s as 1h 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
Câu hỏi thường gặp

Vì sao không thêm công thức để đổi đơn vị?

Một phép đổi cố định khóa đơn vị vào một thang đo, còn định dạng có sẵn tự điều chỉnh theo từng giá trị và giữ dữ liệu dùng được cho các phép tính khác.

Điều này có dùng được cho insight SQL không?

Có. Insight SQL đặt định dạng cho từng cột trong cài đặt biểu đồ.

Các con số của tôi có thay đổi không?

Không. Chỉ phần hiển thị thay đổi, nên các giá trị vẫn đúng về mặt số học.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
41k
Vị trí xếp hạng
#6903
Giấy phép
—
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự