: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(insights): add line style option to SQL insight display settings (#69741)
Sam Penningtone9de0ae1f9bb
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.tsindex e36a3667ec46..bace41b7144a 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.ts+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.ts@@ -21,6 +21,7 @@ import { dayjs } from 'lib/dayjs'import { ChartSettings, GoalLine, YAxisSettings } from '~/queries/schema/schema-general'import { ChartDisplayType } from '~/types'+import { chartStyleCurve } from 'products/product_analytics/frontend/insights/shared/chartStyleAdapter'import { schemaGoalLinesToConfigs } from 'products/product_analytics/frontend/insights/trends/shared/goalLinesAdapter'import { AxisSeries, AxisSeriesSettings, formatDataWithSettings } from '../../dataVisualizationLogic'@@ -447,6 +448,7 @@ export function buildLineChartConfig({trendLines: buildTrendLineConfigs(ySeriesData),legend: buildLegendConfig(chartSettings),valueLabels: buildValueLabelsConfig(chartSettings, ySeriesData),+ curve: chartStyleCurve(chartSettings.chartStyle),tooltip: {...buildSqlTooltipConfig(chartSettings, ySeriesData),...(labelFormatter ? { labelFormatter } : {}),@@ -547,6 +549,7 @@ export function buildComboChartConfig({// Percent bars scale against a [0, 1] domain; trend lines plot raw series values, so they'd// render off-scale and invisible.trendLines: isPercent ? [] : buildTrendLineConfigs(ySeriesData),+ curve: chartStyleCurve(chartSettings.chartStyle),legend: buildLegendConfig(chartSettings),valueLabels: buildValueLabelsConfig(chartSettings, ySeriesData),tooltip: {diff --git a/frontend/src/queries/nodes/DataVisualization/Components/DisplayTab.tsx b/frontend/src/queries/nodes/DataVisualization/Components/DisplayTab.tsxindex a52087bdf07c..8c8732ff003d 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/DisplayTab.tsx+++ b/frontend/src/queries/nodes/DataVisualization/Components/DisplayTab.tsx@@ -30,6 +30,11 @@ const PIE_VALUE_DISPLAY_OPTIONS: { value: 'absolute' | 'percentage'; label: stri{ value: 'percentage', label: 'Percentage' },]+const LINE_STYLE_OPTIONS: { value: 'smooth' | 'linear'; label: string }[] = [+ { value: 'smooth', label: 'Smooth' },+ { value: 'linear', label: 'Straight' },+]+export const DisplayTab = (): JSX.Element => {const { effectiveVisualizationType } = useValues(dataVisualizationLogic)const { goalLines, chartSettings } = useValues(displayLogic)@@ -37,6 +42,9 @@ export const DisplayTab = (): JSX.Element => {const isStackedBarChart = effectiveVisualizationType === ChartDisplayType.ActionsStackedBarconst isPieChart = effectiveVisualizationType === ChartDisplayType.ActionsPie+ const isLineChart =+ effectiveVisualizationType === ChartDisplayType.ActionsLineGraph ||+ effectiveVisualizationType === ChartDisplayType.ActionsAreaGraphconst renderYAxisSettings = (name: 'leftYAxisSettings' | 'rightYAxisSettings'): JSX.Element => {const labelPlaceholder = name === 'leftYAxisSettings' ? 'Left Y-axis label' : 'Right Y-axis label'@@ -182,6 +190,21 @@ export const DisplayTab = (): JSX.Element => {updateChartSettings({ showValuesOnSeries: value })}}/>+ {isLineChart && (+ <div className="flex flex-col gap-1">+ <LemonLabel>Line style</LemonLabel>+ <LemonSegmentedButton+ className="w-full"+ data-attr="data-visualization-line-style"+ value={chartSettings.chartStyle?.curve ?? 'smooth'}+ onChange={(value) =>+ updateChartSettings({ chartStyle: { curve: value } })+ }+ options={LINE_STYLE_OPTIONS}+ fullWidth+ />+ </div>+ )}<div className="flex flex-col gap-1"><LemonLabel>X-axis label</LemonLabel><LemonInputdiff --git a/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.ts b/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.tsindex 6f644213370b..3f65aabd01e1 100644--- a/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.ts+++ b/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.ts@@ -383,6 +383,13 @@ const mergeChartSettings = (state: ChartSettings, settings: ChartSettings): Char...settings.rightYAxisSettings,}: undefined,+ chartStyle:+ state.chartStyle || settings.chartStyle+ ? {+ ...state.chartStyle,+ ...settings.chartStyle,+ }+ : undefined,}}diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 192917c2833f..b6455eb8c19b 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -13819,6 +13819,10 @@"ChartSettings": {"additionalProperties": false,"properties": {+ "chartStyle": {+ "$ref": "#/definitions/ChartStyle",+ "description": "Chart rendering style overrides (line shape). Only applies to line and area charts."+ },"goalLines": {"items": {"$ref": "#/definitions/GoalLine"diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex f2f55eacfd11..f059f3ec2706 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -1266,6 +1266,8 @@ export interface ChartSettings {pie?: PieChartSettings/** Per-breakdown-value color customizations. Keyed by the raw breakdown column value. */resultCustomizations?: Record<string, ResultCustomizationByValue>+ /** Chart rendering style overrides (line shape). Only applies to line and area charts. */+ chartStyle?: ChartStyle}export interface ConditionalFormattingRule {diff --git a/posthog/schema.py b/posthog/schema.pyindex 46e44a6b16f9..f257382c2bc3 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -13586,6 +13586,10 @@ class ChartSettings(BaseModel):model_config = ConfigDict(extra="forbid",)+ chartStyle: ChartStyle | None = Field(+ default=None,+ description=("Chart rendering style overrides (line shape). Only applies to line and area charts."),+ )goalLines: list[GoalLine] | None = Noneheatmap: HeatmapSettings | None = NoneleftYAxisSettings: YAxisSettings | None = Nonediff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex 7678b2f300bf..42966d87b09c 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -7773,6 +7773,8 @@ export interface ChartAxisApi {export type ChartSettingsApiResultCustomizations = { [key: string]: ResultCustomizationByValueApi } | nullexport interface ChartSettingsApi {+ /** Chart rendering style overrides (line shape). Only applies to line and area charts. */+ chartStyle?: ChartStyleApi | nullgoalLines?: GoalLineApi[] | nullheatmap?: HeatmapSettingsApi | nullleftYAxisSettings?: YAxisSettingsApi | nulldiff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.tsindex 3e80e6c21362..6f490b4d0c22 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -7105,6 +7105,8 @@ export interface ChartAxisApi {export type ChartSettingsApiResultCustomizations = { [key: string]: ResultCustomizationByValueApi } | nullexport interface ChartSettingsApi {+ /** Chart rendering style overrides (line shape). Only applies to line and area charts. */+ chartStyle?: ChartStyleApi | nullgoalLines?: GoalLineApi[] | nullheatmap?: HeatmapSettingsApi | nullleftYAxisSettings?: YAxisSettingsApi | nulldiff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 0279d965b098..f8f2cdd0af5d 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -7412,6 +7412,8 @@ export namespace Schemas {export type ChartSettingsResultCustomizations = {[key: string]: ResultCustomizationByValue} | null;export interface ChartSettings {+ /** Chart rendering style overrides (line shape). Only applies to line and area charts. */+ chartStyle?: ChartStyle | null;goalLines?: GoalLine[] | null;heatmap?: HeatmapSettings | null;leftYAxisSettings?: YAxisSettings | null;