Visualizing change over time

From PostHog/posthog · View interactive version

Visualizing change over time is an AI agent skill from the GitHub repository PostHog/posthog. Helps PostHog engineers and agents pick the right chart when a request is about visualizing change over time, before/after comparisons, or period-over-period movement while building UI with @posthog/quill-charts (dashboards, reports, the mcp_analytics frontend, custom visualizations). Use when a use

How to use this skill

Skill file

Visualizing change over time

When a request is about how something changed, the default reach is a line/area

trend — and that is usually right for a continuous series with many x points. But for

some change-over-time shapes a different chart reads far better. This skill is the

menu to offer, including the slope graph, when building visualizations with

CODE0.

Present the fitting option(s) and let the user choose — none of these is mandatory.

Pick by the shape of the change

| The change is… | Reach for | Why |

| ------------------------------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |

| A continuous series over many time points (a trend) | TimeSeriesLineChart / LineChart (area fill for emphasis) | The standard trend; the slope between every pair of points is visible. |

| Two points only (before → after) across several series/categories | SlopeChart | One line per entity from a left "before" to a right "after" — direction and magnitude of each entity's change, and rank flips, read at a glance. |

| Magnitude comparison at points in time (not the path between them) | BarChart / TimeSeriesBarChart | Bars compare discrete values; group/stack for sub-series. |

| A single headline number plus its change vs a prior period | Metric (@posthog/quill-components/metric) | Big number + sparkline + change pill. |

If the user is comparing exactly two snapshots (this week vs last, control vs

treatment, Q1 vs Q2) and especially when there are many categories whose

_relative_ movement matters, offer the slope graph as the cleaner alternative to a

grouped bar or a 2-point line chart.

Using the SlopeChart

import { SlopeChart } from '@posthog/quill-charts'
import type { Series } from '@posthog/quill-charts'
import type { SlopeSeriesMeta } from '@posthog/quill-charts'

// One series per entity; `data` is exactly [start, end].
const series: Series<SlopeSeriesMeta>[] = [
    { key: 'us', label: 'US', data: [120, 185] },
    { key: 'eu', label: 'EU', data: [200, 150] },
]

<SlopeChart
    series={series}
    labels={['Before', 'After']}
    theme={theme}
    config={{
        showSeriesLabels: true, // name beside each end point; steepest line always keeps its label
        legend: { show: true }, // each row shows the color, label, and the formatted change
        deltaFormatter: (d) => `${d >= 0 ? '+' : ''}${d}`,
    }}
/>

Key options (full list in the charts

docs/chart-types.md "SlopeChart" section):

override per series with meta.showStartLabel / meta.showEndLabel.

change** (|end − start|) always keeps its label.

The theme comes from useChartTheme(); give the wrapper a real height. See the

charts AGENTS.md for theme wiring and sizing.

Scope note

There are two ways to render a slope graph; which you reach for depends on the surface:

directly: dashboards, reports, the mcp_analytics frontend, custom visualizations.

It backs the Slope view toggle on Max's inline trends result card

(services/mcp/src/ui-apps/components/TrendsVisualizer.tsx).

'SlopeGraph' in frontend/src/types.ts), rendered by the backend

SlopeGraphTrendsQueryRunner

(products/product_analytics/backend/hogql_queries/trends/slope_graph_trends_query_runner.py). It

takes a TrendsQuery and keeps the first and last bucket of the date range as

the two slope points (the last segment is dashed when it's the current,

still-accumulating period). Set it via trendsFilter.display: "SlopeGraph"

(trends-only).

trendsFilter.display: "SlopeGraph". To frame a clean before-and-after, choose

the date range and interval so the first bucket is your baseline and the last is

"now" (e.g. monthly buckets starting from the baseline month).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.