Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(annotations): add annotations toggle to insight visualizations (#59708)

Mike Warreneb06b2ecc30f
diff --git a/frontend/src/lib/components/Cards/InsightCard/DashboardInsightActions.tsx b/frontend/src/lib/components/Cards/InsightCard/DashboardInsightActions.tsx
index 67ae5f8f7955..de2cee7d235f 100644
--- a/frontend/src/lib/components/Cards/InsightCard/DashboardInsightActions.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/DashboardInsightActions.tsx
@@ -8,6 +8,7 @@ import { insightLogic } from 'scenes/insights/insightLogic'
import { insightsModel } from '~/models/insightsModel'
import { InsightLogicProps, QueryBasedInsightModel } from '~/types'
+import { toggleAnnotationsInInsightQuery } from './annotationsToggle'
import { toggleDisplayLabelsInInsightQuery } from './displayLabelsToggle'
import { toggleLegendInInsightQuery } from './legendToggle'
@@ -17,6 +18,7 @@ type DashboardInsightActionsProps = {
dashboardId: number | undefined
canToggleDisplayLabels: boolean
canToggleLegend: boolean
+ canToggleAnnotations: boolean
}
/** Quick visualization toggles in the insight card ⋯ menu on dashboard (and similar placements). */
@@ -26,17 +28,22 @@ export function DashboardInsightActions({
dashboardId,
canToggleDisplayLabels,
canToggleLegend,
+ canToggleAnnotations,
}: DashboardInsightActionsProps): JSX.Element | null {
const {
displayLabelsToggleTextForInsight,
legendToggleTextForInsight,
+ annotationsToggleTextForInsight,
query: activeQuery,
} = useValues(insightLogic(insightLogicProps))
const { updateInsightDirect } = useActions(insightsModel)
- const { reportDashboardInsightValuesOnSeriesToggled, reportDashboardInsightLegendToggled } =
- useActions(eventUsageLogic)
+ const {
+ reportDashboardInsightValuesOnSeriesToggled,
+ reportDashboardInsightLegendToggled,
+ reportDashboardInsightAnnotationsToggled,
+ } = useActions(eventUsageLogic)
- if (!canToggleDisplayLabels && !canToggleLegend) {
+ if (!canToggleDisplayLabels && !canToggleLegend && !canToggleAnnotations) {
return null
}
@@ -81,6 +88,25 @@ export function DashboardInsightActions({
{legendToggleTextForInsight}
</LemonButton>
)}
+ {canToggleAnnotations && (
+ <LemonButton
+ onClick={() => {
+ const currentQuery = activeQuery ?? insight.query
+ const query = toggleAnnotationsInInsightQuery(currentQuery)
+ if (query !== currentQuery) {
+ updateInsightDirect(insight, { query })
+ reportDashboardInsightAnnotationsToggled(
+ dashboardId,
+ insight.id,
+ DashboardEventSource.MoreDropdown
+ )
+ }
+ }}
+ fullWidth
+ >
+ {annotationsToggleTextForInsight}
+ </LemonButton>
+ )}
<LemonDivider />
</>
)
diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx
index b71576e11eaf..28348659f3b1 100644
--- a/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx
@@ -133,9 +133,12 @@ export function InsightMeta({
variablesOverride: variablesOverride ?? null,
tileFiltersOverride: tileFiltersOverride ?? null,
}
- const { insightFeedback, canToggleDisplayLabelsForInsight, canToggleLegendForInsight } = useValues(
- insightLogic(insightLogicProps)
- )
+ const {
+ insightFeedback,
+ canToggleDisplayLabelsForInsight,
+ canToggleLegendForInsight,
+ canToggleAnnotationsForInsight,
+ } = useValues(insightLogic(insightLogicProps))
const { setInsightFeedback } = useActions(insightLogic(insightLogicProps))
const { exportContext, insightData, query } = useValues(insightDataLogic(insightLogicProps))
const [isManageAlertsModalOpen, setIsManageAlertsModalOpen] = useState(false)
@@ -199,6 +202,7 @@ export function InsightMeta({
const canToggleDisplayLabels = isUsedAsDashboardTile && canEditInsight && canToggleDisplayLabelsForInsight
const canToggleLegend = isUsedAsDashboardTile && canEditInsight && canToggleLegendForInsight
+ const canToggleAnnotations = isUsedAsDashboardTile && canEditInsight && canToggleAnnotationsForInsight
const hasTileStyleActions = !!(showCompactTile && toggleShowDescription && insight.description) || !!updateColor
const canShowCopyToDashboardTile = showCompactTile && !!copyToDashboard && canViewInsight
@@ -439,11 +443,14 @@ export function InsightMeta({
dashboardId={dashboardId}
canToggleDisplayLabels={canToggleDisplayLabels}
canToggleLegend={canToggleLegend}
+ canToggleAnnotations={canToggleAnnotations}
/>
{canShowCopyToDashboardTile && !canEditDashboard && (
<>
- {!canToggleDisplayLabels && <LemonDivider />}
+ {!canToggleDisplayLabels && !canToggleLegend && !canToggleAnnotations && (
+ <LemonDivider />
+ )}
<h5 className="mx-2 my-1">Dashboard</h5>
<DashboardWidgetPlacementMenus
placementDestinations={copyToDestinations}
@@ -455,7 +462,9 @@ export function InsightMeta({
{/* Dashboard related */}
{canEditDashboard && (
<>
- {!canToggleDisplayLabels && !canToggleLegend && <LemonDivider />}
+ {!canToggleDisplayLabels && !canToggleLegend && !canToggleAnnotations && (
+ <LemonDivider />
+ )}
{showCompactTile && toggleShowDescription && !!insight.description && (
<LemonButton onClick={toggleShowDescription} fullWidth>
{tile?.show_description === false ? 'Show description' : 'Hide description'}
diff --git a/frontend/src/lib/components/Cards/InsightCard/annotationsToggle.ts b/frontend/src/lib/components/Cards/InsightCard/annotationsToggle.ts
new file mode 100644
index 000000000000..53af6dfc8593
--- /dev/null
+++ b/frontend/src/lib/components/Cards/InsightCard/annotationsToggle.ts
@@ -0,0 +1,76 @@
+import { NON_TIME_SERIES_DISPLAY_TYPES } from 'lib/constants'
+
+import { InsightVizNode } from '~/queries/schema/schema-general'
+import { getShowAnnotations, isFunnelsQuery, isInsightVizNode, isTrendsQuery } from '~/queries/utils'
+import { ChartDisplayType, FunnelVizType, QueryBasedInsightModel } from '~/types'
+
+// Annotations only render for trends time-series charts and funnels with the historical-trends viz type.
+export function canToggleAnnotationsInInsightQuery(query: QueryBasedInsightModel['query']): boolean {
+ if (!isInsightVizNode(query)) {
+ return false
+ }
+
+ const source = query.source
+ if (isTrendsQuery(source)) {
+ const display = source.trendsFilter?.display || ChartDisplayType.ActionsLineGraph
+ return !NON_TIME_SERIES_DISPLAY_TYPES.includes(display)
+ }
+
+ if (isFunnelsQuery(source)) {
+ return source.funnelsFilter?.funnelVizType === FunnelVizType.Trends
+ }
+
+ return false
+}
+
+export function isAnnotationsEnabledInInsightQuery(query: QueryBasedInsightModel['query']): boolean {
+ if (!canToggleAnnotationsInInsightQuery(query) || !isInsightVizNode(query)) {
+ return false
+ }
+ // Default true — treat undefined as enabled.
+ return getShowAnnotations(query.source) !== false
+}
+
+export function getAnnotationsToggleText(query: QueryBasedInsightModel['query']): string {
+ return isAnnotationsEnabledInInsightQuery(query) ? 'Hide annotations' : 'Show annotations'
+}
+
+export function toggleAnnotationsInInsightQuery(
+ query: QueryBasedInsightModel['query']
+): QueryBasedInsightModel['query'] {
+ if (!isInsightVizNode(query)) {
+ return query
+ }
+
+ const viz: InsightVizNode = query
+ const source = viz.source
+ const nextShowAnnotations = getShowAnnotations(source) === false
+
+ if (isTrendsQuery(source)) {
+ return {
+ ...viz,
+ source: {
+ ...source,
+ trendsFilter: {
+ ...source.trendsFilter,
+ showAnnotations: nextShowAnnotations,
+ },
+ },
+ } as QueryBasedInsightModel['query']
+ }
+
+ if (isFunnelsQuery(source)) {
+ return {
+ ...viz,
+ source: {
+ ...source,
+ funnelsFilter: {
+ ...source.funnelsFilter,
+ showAnnotations: nextShowAnnotations,
+ },
+ },
+ } as QueryBasedInsightModel['query']
+ }
+
+ return query
+}
diff --git a/frontend/src/lib/utils/eventUsageLogic.ts b/frontend/src/lib/utils/eventUsageLogic.ts
index fb78c61e07e8..5cb405bc6912 100644
--- a/frontend/src/lib/utils/eventUsageLogic.ts
+++ b/frontend/src/lib/utils/eventUsageLogic.ts
@@ -537,6 +537,11 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
insightId: number,
source: DashboardEventSource
) => ({ dashboardId, insightId, source }),
+ reportDashboardInsightAnnotationsToggled: (
+ dashboardId: number | undefined,
+ insightId: number,
+ source: DashboardEventSource
+ ) => ({ dashboardId, insightId, source }),
/** Empty-state AI prompt chips (ai-first empty dashboard only). */
reportDashboardEmptyAiPromptClicked: (promptLabel: string, dashboardId: number | undefined) => ({
promptLabel,
@@ -1440,6 +1445,13 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
source,
})
},
+ reportDashboardInsightAnnotationsToggled: async ({ dashboardId, insightId, source }) => {
+ posthog.capture('dashboard insight annotations toggled', {
+ dashboard_id: dashboardId,
+ insight_id: insightId,
+ source,
+ })
+ },
reportDashboardEmptyAiPromptClicked: async ({ promptLabel, dashboardId }) => {
posthog.capture('dashboard empty ai prompt clicked', {
prompt_label: promptLabel,
diff --git a/frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.tsx b/frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.tsx
index f3d9013e9b35..99a1943c675b 100644
--- a/frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.tsx
+++ b/frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.tsx
@@ -27,6 +27,7 @@ import { ResultCustomizationByPicker } from 'scenes/insights/EditorFilters/Resul
import { ScalePicker } from 'scenes/insights/EditorFilters/ScalePicker'
import { ShowAlertAnomalyPointsFilter } from 'scenes/insights/EditorFilters/ShowAlertAnomalyPointsFilter'
import { ShowAlertThresholdLinesFilter } from 'scenes/insights/EditorFilters/ShowAlertThresholdLinesFilter'
+import { ShowAnnotationsFilter } from 'scenes/insights/EditorFilters/ShowAnnotationsFilter'
import { ShowLegendFilter } from 'scenes/insights/EditorFilters/ShowLegendFilter'
import { ShowMultipleYAxesFilter } from 'scenes/insights/EditorFilters/ShowMultipleYAxesFilter'
import { ShowPieTotalFilter } from 'scenes/insights/EditorFilters/ShowPieTotalFilter'
@@ -98,6 +99,7 @@ export function InsightDisplayConfig(): JSX.Element {
supportsResultCustomizationBy,
yAxisScaleType,
showMultipleYAxes,
+ showAnnotations,
isNonTimeSeriesDisplay,
compareFilter,
supportsCompare,
@@ -129,6 +131,7 @@ export function InsightDisplayConfig(): JSX.Element {
(smoothingOptions[interval]?.length ?? 0) > 0
const showMultipleYAxesConfig = (isTrends || isStickiness) && !isNonTimeSeriesDisplay
const showAlertThresholdLinesConfig = isTrends && !isNonTimeSeriesDisplay
+ const showAnnotationsConfig = (isTrends && !isNonTimeSeriesDisplay) || isTrendsFunnel
const isLineDisplay = isDefaultTrendsLineDisplay(display, querySource) || displayMatches(display, LINE_DISPLAYS)
const isBarDisplay = displayMatches(display, BAR_DISPLAYS)
const isCumulativeLineDisplay = display === ChartDisplayType.ActionsLineGraphCumulative
@@ -224,6 +227,7 @@ export function InsightDisplayConfig(): JSX.Element {
...(isTrends && !isNonTimeSeriesDisplay && hideWeekendsEnabled
? [{ label: () => <HideWeekendsFilter /> }]
: []),
+ ...(showAnnotationsConfig ? [{ label: () => <ShowAnnotationsFilter /> }] : []),
],
},
]
@@ -389,7 +393,8 @@ export function InsightDisplayConfig(): JSX.Element {
(showAxisLabelsConfig && normalizeAxisLabel(trendsFilter?.xAxisLabel) ? 1 : 0) +
(showAxisLabelsConfig && normalizeAxisLabel(trendsFilter?.yAxisLabel) ? 1 : 0) +
(showMultipleYAxes ? 1 : 0) +
- (trendsFilter?.hideWeekends && hideWeekendsEnabled ? 1 : 0)
+ (trendsFilter?.hideWeekends && hideWeekendsEnabled ? 1 : 0) +
+ (showAnnotationsConfig && showAnnotations === false ? 1 : 0)
return (
<div
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 302a3e597c1a..434272283305 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -21143,6 +21143,11 @@
"description": "Customizations for the appearance of result datasets.",
"type": "object"
},
+ "showAnnotations": {
+ "default": true,
+ "description": "Whether to render annotations on the chart. Only applies to historical-trends funnels.",
+ "type": "boolean"
+ },
"showTrendLines": {
"description": "Display linear regression trend lines on the chart (only for historical trends viz)",
"type": "boolean"
@@ -41043,6 +41048,10 @@
"default": false,
"type": "boolean"
},
+ "showAnnotations": {
+ "default": true,
+ "type": "boolean"
+ },
"showConfidenceIntervals": {
"type": "boolean"
},
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index 7070311fba4e..ef9a4bc700ac 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -1479,6 +1479,8 @@ export type TrendsFilter = {
excludeBoxPlotOutliers?: boolean
/** @default false */
hideWeekends?: boolean
+ /** @default true */
+ showAnnotations?: boolean
}
export type CalendarHeatmapFilter = {
@@ -1510,6 +1512,7 @@ export const TRENDS_FILTER_PROPERTIES = new Set<keyof TrendsFilter>([
'hiddenLegendIndexes',
'excludeBoxPlotOutliers',
'hideWeekends',
+ 'showAnnotations',
])
export interface BoxPlotDatum {
@@ -1676,6 +1679,11 @@ export type FunnelsFilter = {
showValuesOnSeries?: boolean
/** Breakdown table sorting. Format: 'column_key' or '-column_key' (descending) */
breakdownSorting?: string
+ /**
+ * Whether to render annotations on the chart. Only applies to historical-trends funnels.
+ * @default true
+ */
+ showAnnotations?: boolean
}
export interface FunnelsQuery extends InsightsQueryBase<FunnelsQueryResponse> {
diff --git a/frontend/src/queries/utils.ts b/frontend/src/queries/utils.ts
index 4bb775d1a5b9..eba8cf071135 100644
--- a/frontend/src/queries/utils.ts
+++ b/frontend/src/queries/utils.ts
@@ -573,6 +573,15 @@ export const getShowAlertThresholdLines = (query: InsightQueryNode): boolean | u
return undefined
}
+export const getShowAnnotations = (query: InsightQueryNode): boolean | undefined => {
+ if (isTrendsQuery(query)) {
+ return query.trendsFilter?.showAnnotations
+ } else if (isFunnelsQuery(query)) {
+ return query.funnelsFilter?.showAnnotations
+ }
+ return undefined
+}
+
export const getShowLabelsOnSeries = (query: InsightQueryNode): boolean | undefined => {
if (isTrendsQuery(query)) {
return query.trendsFilter?.showLabelsOnSeries
diff --git a/frontend/src/scenes/funnels/FunnelLineGraph.tsx b/frontend/src/scenes/funnels/FunnelLineGraph.tsx
index 77ddd33f33f4..e157dba9ee47 100644
--- a/frontend/src/scenes/funnels/FunnelLineGraph.tsx
+++ b/frontend/src/scenes/funnels/FunnelLineGraph.tsx
@@ -133,7 +133,7 @@ export function FunnelLineGraph({
})
}
}
- hideAnnotations={inSharedMode}
+ hideAnnotations={inSharedMode || funnelsFilter?.showAnnotations === false}
/>
</LineGraphWrapper>
)
diff --git a/frontend/src/scenes/insights/EditorFilters/ShowAnnotationsFilter.tsx b/frontend/src/scenes/insights/EditorFilters/ShowAnnotationsFilter.tsx
new file mode 100644
index 000000000000..15ddb6a760a2
--- /dev/null
+++ b/frontend/src/scenes/insights/EditorFilters/ShowAnnotationsFilter.tsx
@@ -0,0 +1,25 @@
+import { useActions, useValues } from 'kea'
+
+import { LemonCheckbox } from '@posthog/lemon-ui'
+
+import { insightLogic } from 'scenes/insights/insightLogic'
+
+import { insightVizDataLogic } from '../insightVizDataLogic'
+
+export function ShowAnnotationsFilter(): JSX.Element | null {
+ const { insightProps } = useValues(insightLogic)
+ const { showAnnotations } = useValues(insightVizDataLogic(insightProps))
+ const { updateInsightFilter } = useActions(insightVizDataLogic(insightProps))
+
+ const checked = showAnnotations !== false
+
+ return (
+ <LemonCheckbox
+ className="p-1 px-2"
+ onChange={(value) => updateInsightFilter({ showAnnotations: value })}
+ checked={checked}
+ label={<span className="font-normal">Show annotations</span>}
+ size="small"
+ />
+ )
+}
diff --git a/frontend/src/scenes/insights/insightLogic.tsx b/frontend/src/scenes/insights/insightLogic.tsx
index ca6544a4dd0b..59b63bc7fd41 100644
--- a/frontend/src/scenes/insights/insightLogic.tsx
+++ b/frontend/src/scenes/insights/insightLogic.tsx
@@ -7,6 +7,10 @@ import { LemonDialog, LemonInput } from '@posthog/lemon-ui'
import { ApiError } from 'lib/api'
import { insightAlertsLogic } from 'lib/components/Alerts/insightAlertsLogic'
+import {
+ canToggleAnnotationsInInsightQuery,
+ getAnnotationsToggleText,
+} from 'lib/components/Cards/InsightCard/annotationsToggle'
import {
canToggleDisplayLabelsInInsightQuery,
getDisplayLabelsToggleText,
@@ -471,6 +475,10 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
(query) => !!query && canToggleDisplayLabelsInInsightQuery(query),
],
canToggleLegendForInsight: [(s) => [s.query], (query) => !!query && canToggleLegendInInsightQuery(query)],
+ canToggleAnnotationsForInsight: [
+ (s) => [s.query],
+ (query) => !!query && canToggleAnnotationsInInsightQuery(query),
+ ],
displayLabelsShownForInsight: [
(s) => [s.query],
(query) => !!query && isDisplayLabelsEnabledInInsightQuery(query),
@@ -480,6 +488,10 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
(query) => (query ? getDisplayLabelsToggleText(query) : 'Show values on series'),
],
legendToggleTextForInsight: [(s) => [s.query], (query) => (query ? getLegendToggleText(query) : 'Show legend')],
+ annotationsToggleTextForInsight: [
+ (s) => [s.query],
+ (query) => (query ? getAnnotationsToggleText(query) : 'Hide annotations'),
+ ],
insightChanged: [
(s) => [s.insight, s.savedInsight],
(insight, savedInsight): boolean => {
diff --git a/frontend/src/scenes/insights/insightVizDataLogic.ts b/frontend/src/scenes/insights/insightVizDataLogic.ts
index d74f6e66959f..5d1a82237338 100644
--- a/frontend/src/scenes/insights/insightVizDataLogic.ts
+++ b/frontend/src/scenes/insights/insightVizDataLogic.ts
@@ -70,6 +70,7 @@ import {
getResultCustomizationBy,
getSeries,
getShowAlertThresholdLines,
+ getShowAnnotations,
getShowLabelsOnSeries,
getShowLegend,
getShowMultipleYAxes,
@@ -265,6 +266,7 @@ export const insightVizDataLogic = kea<insightVizDataLogicType>([
properties: [(s) => [s.querySource], (q) => (q ? q.properties : null)],
samplingFactor: [(s) => [s.querySource], (q) => (q && 'samplingFactor' in q ? q.samplingFactor : null)],
showAlertThresholdLines: [(s) => [s.querySource], (q) => (q ? getShowAlertThresholdLines(q) : null)],
+ showAnnotations: [(s) => [s.querySource], (q) => (q ? getShowAnnotations(q) : null)],
showLegend: [(s) => [s.querySource], (q) => (q ? getShowLegend(q) : null)],
showValuesOnSeries: [(s) => [s.querySource], (q) => (q ? getShowValuesOnSeries(q) : null)],
showLabelOnSeries: [(s) => [s.querySource], (q) => (q ? getShowLabelsOnSeries(q) : null)],
diff --git a/frontend/src/scenes/insights/utils/queryUtils.ts b/frontend/src/scenes/insights/utils/queryUtils.ts
index d764eeb4db5c..c0451e9a6e91 100644
--- a/frontend/src/scenes/insights/utils/queryUtils.ts
+++ b/frontend/src/scenes/insights/utils/queryUtils.ts
@@ -255,6 +255,7 @@ export const cleanInsightQuery = (query: InsightQueryNode, opts?: CompareQueryOp
stacked: undefined,
detailedResultsAggregationType: undefined,
excludeBoxPlotOutliers: undefined,
+ showAnnotations: undefined,
showFullUrls: undefined,
selectedInterval: undefined,
funnelStepReference: undefined,
diff --git a/frontend/src/scenes/trends/trendsDataLogic.ts b/frontend/src/scenes/trends/trendsDataLogic.ts
index 562e717cdfde..9fa6e81c39e6 100644
--- a/frontend/src/scenes/trends/trendsDataLogic.ts
+++ b/frontend/src/scenes/trends/trendsDataLogic.ts
@@ -104,6 +104,7 @@ export const trendsDataLogic = kea<trendsDataLogicType>([
'isBreakdownSeries',
'hasLegend',
'showLegend',
+ 'showAnnotations',
'vizSpecificOptions',
'yAxisScaleType',
'showMultipleYAxes',
diff --git a/frontend/src/scenes/trends/viz/ActionsLineGraph.tsx b/frontend/src/scenes/trends/viz/ActionsLineGraph.tsx
index d14e8143c911..3d0c43e0301d 100644
--- a/frontend/src/scenes/trends/viz/ActionsLineGraph.tsx
+++ b/frontend/src/scenes/trends/viz/ActionsLineGraph.tsx
@@ -34,6 +34,7 @@ export function ActionsLineGraph({
showValuesOnSeries,
showPercentStackView,
supportsPercentStackView,
+ showAnnotations,
trendsFilter,
lifecycleFilter,
isLifecycle,
@@ -204,7 +205,7 @@ export function ActionsLineGraph({
isArea={display === ChartDisplayType.ActionsAreaGraph}
incompletenessOffsetFromEnd={incompletenessOffsetFromEnd}
legend={legend}
- hideAnnotations={inSharedMode}
+ hideAnnotations={inSharedMode || showAnnotations === false}
goalLines={[...alertThresholdLines, ...(goalLines || [])]}
anomalyPoints={alertAnomalyPoints}
onDateRangeZoom={context?.onDateRangeZoom}
diff --git a/posthog/schema.py b/posthog/schema.py
index de52b197b9b8..2e9b73377c81 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -9595,6 +9595,7 @@ class TrendsFilter(BaseModel):
)
)
showAlertThresholdLines: bool | None = False
+ showAnnotations: bool | None = True
showConfidenceIntervals: bool | None = None
showLabelsOnSeries: bool | None = None
showLegend: bool | None = False
@@ -22787,6 +22788,10 @@ class FunnelsFilter(BaseModel):
default=None,
description="Customizations for the appearance of result datasets.",
)
+ showAnnotations: bool | None = Field(
+ default=True,
+ description=("Whether to render annotations on the chart. Only applies to historical-trends funnels."),
+ )
showTrendLines: bool | None = Field(
default=None,
description=("Display linear regression trend lines on the chart (only for historical trends viz)"),
diff --git a/posthog/schema_helpers.py b/posthog/schema_helpers.py
index 98b1f3fce56c..5489ee404020 100644
--- a/posthog/schema_helpers.py
+++ b/posthog/schema_helpers.py
@@ -113,6 +113,7 @@ def to_dict(query: BaseModel) -> dict:
"stacked",
"detailedResultsAggregationType",
"excludeBoxPlotOutliers",
+ "showAnnotations",
"showFullUrls",
"selectedInterval",
"funnelStepReference",
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index 7d1c7adf7595..a9aab31785e6 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -1863,6 +1863,7 @@ export interface TrendsFilterApi {
/** Customizations for the appearance of result datasets. */
resultCustomizations?: TrendsFilterApiResultCustomizations
showAlertThresholdLines?: boolean | null
+ showAnnotations?: boolean | null
showConfidenceIntervals?: boolean | null
showLabelsOnSeries?: boolean | null
showLegend?: boolean | null
@@ -2189,6 +2190,8 @@ export interface FunnelsFilterApi {
layout?: FunnelLayoutApi | null
/** Customizations for the appearance of result datasets. */
resultCustomizations?: FunnelsFilterApiResultCustomizations
+ /** Whether to render annotations on the chart. Only applies to historical-trends funnels. */
+ showAnnotations?: boolean | null
/** Display linear regression trend lines on the chart (only for historical trends viz) */
showTrendLines?: boolean | null
showValuesOnSeries?: boolean | null
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index 7ebfe555052e..545ddcb4b89e 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -1556,6 +1556,7 @@ export interface TrendsFilterApi {
/** Customizations for the appearance of result datasets. */
resultCustomizations?: TrendsFilterApiResultCustomizations
showAlertThresholdLines?: boolean | null
+ showAnnotations?: boolean | null
showConfidenceIntervals?: boolean | null
showLabelsOnSeries?: boolean | null
showLegend?: boolean | null
@@ -1882,6 +1883,8 @@ export interface FunnelsFilterApi {
layout?: FunnelLayoutApi | null
/** Customizations for the appearance of result datasets. */
resultCustomizations?: FunnelsFilterApiResultCustomizations
+ /** Whether to render annotations on the chart. Only applies to historical-trends funnels. */
+ showAnnotations?: boolean | null
/** Display linear regression trend lines on the chart (only for historical trends viz) */
showTrendLines?: boolean | null
showValuesOnSeries?: boolean | null
diff --git a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.tsx b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.tsx
index 31605e553bdd..a90d3e266a44 100644
--- a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.tsx
+++ b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.tsx
@@ -403,7 +403,7 @@ export function TrendsBarChart({
// Annotations are date-anchored, so they only make sense for the time-series bar
// layouts (vertical bars). The horizontal aggregated layout has categorical labels.
- const showAnnotations = !inSharedMode
+ const showAnnotations = !inSharedMode && trendsFilter?.showAnnotations !== false
const annotationsDates = currentPeriodResult?.days ?? []
// In compare-against-previous grouped layouts each band holds two bars (previous, current).
// Anchor each period's annotations on its matching bar so they line up with what they describe.
diff --git a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.tsx b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.tsx
index de5e1493278a..ecd196679041 100644
--- a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.tsx
+++ b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.tsx
@@ -268,7 +268,7 @@ export function TrendsLineChart({ context, inSharedMode = false }: TrendsLineCha
return <InsightEmptyState heading={context?.emptyStateHeading} detail={context?.emptyStateDetail} />
}
- const showAnnotations = !inSharedMode
+ const showAnnotations = !inSharedMode && trendsFilter?.showAnnotations !== false
const annotationsDates = currentPeriodResult?.days ?? []
return (
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 7f96af8c14dc..86faea2fdc4b 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -2176,6 +2176,7 @@ export namespace Schemas {
/** Customizations for the appearance of result datasets. */
resultCustomizations?: TrendsFilterResultCustomizations;
showAlertThresholdLines?: boolean | null;
+ showAnnotations?: boolean | null;
showConfidenceIntervals?: boolean | null;
showLabelsOnSeries?: boolean | null;
showLegend?: boolean | null;
@@ -2373,6 +2374,8 @@ export namespace Schemas {
layout?: FunnelLayout | null;
/** Customizations for the appearance of result datasets. */
resultCustomizations?: FunnelsFilterResultCustomizations;
+ /** Whether to render annotations on the chart. Only applies to historical-trends funnels. */
+ showAnnotations?: boolean | null;
/** Display linear regression trend lines on the chart (only for historical trends viz) */
showTrendLines?: boolean | null;
showValuesOnSeries?: boolean | null;