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.

chore(insights): remove quill-sql-charts flag and legacy chart.js path (#70675)

Sam Penningtona782ea8bd74b
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 6f170e9dc211..80f65a199e9d 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6343,13 +6343,13 @@ snapshots:
scenes-app-insights-sqllinechart--sql-bar-chart-value-labels-quill--light:
hash: v1.k794b7964.aa182b1b0930b4ebbf00c19deed3c119a0bbcce5124066dd62064b68688117fd.UPRv3nvOQNUGhGHyLW6JP9hlE64ZT6Dw1ua4fCePyYY
scenes-app-insights-sqllinechart--sql-line-chart--dark:
- hash: v1.k794b7964.de80c9b4dac120fbbaca7e49026f65cdb77e19c4a53f734a3840c53a5573218c.CWJMQGhmxj5sAShfvws2pIRo9cBU8K7GILzcPsmkXhI
+ hash: v1.k794b7964.f5f6a853f6f34b9f813d059edfb0741c535a82bb67c6d297780558284674b56a.CAAgnMZ0-yQKylpCryQaGgDTmbfMIKxTpa-LWEqjae4
scenes-app-insights-sqllinechart--sql-line-chart--light:
- hash: v1.k794b7964.c8a8f8649d8cc3cc21285c9c381d55e95fb577485efd01c95ef4e903b474fb34.LDuSFgXoR0TxwhUB3cxUAVBBXCfm5w3dXIUbXVK_cpc
+ hash: v1.k794b7964.6777dbe0cb6638bdb59930aad70830a8081e79de48d0c2bed3da43a35b2fc173.lyF1natHKHOYRZSoqoAzDF1uU2hr8OhZKVkrTXxSuYc
scenes-app-insights-sqllinechart--sql-line-chart-breakdown--dark:
- hash: v1.k794b7964.ed4959cc833880bfe8be6ef322ba439bce067d8a263d4558235a4c15f35c2b99.NscPLgmU9JrECeZMiyYDuVdpVWsIYT9g1qxtmCmy57Q
+ hash: v1.k794b7964.35c4bb3057126ef7c623b6fe68797edd5e0aa9976f49a0dd0d9d8c511a747943.XkTn7Pcya60r_qv2AksIAD5TSFOsH611FS-J17JOeX8
scenes-app-insights-sqllinechart--sql-line-chart-breakdown--light:
- hash: v1.k794b7964.83597d5deb29bf7fcd4b395c8e62b33a9dfad14a78d787fa509c21f721ca0cd4.nmY-_avvt847cy7UAb7GKlxrMetCd920ycbD9ACQhgw
+ hash: v1.k794b7964.b0ca68eb25ec0a525dcc15e93088d7e22ed3cf3147481343fdb8da56205b7921.WJZ79jdvM7gHOpcgNI5yaVSCG7UZZ4BNLqj76CtvUu0
scenes-app-insights-sqllinechart--sql-line-chart-trend-line-quill--dark:
hash: v1.k794b7964.04759583f43fc068b6da699ea41b3acb8be82bbffc295a7de27c47e6cacf823e.lXqLvz3GqGeNqFWPuYKAsxHAvEb-zSGz_v_WCrpTA-k
scenes-app-insights-sqllinechart--sql-line-chart-trend-line-quill--light:
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 52006c79bc38..79f7fd05d680 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -429,7 +429,6 @@ export const FEATURE_FLAGS = {
PRODUCT_ANALYTICS_PATHS_V2: 'paths-v2', // owner: @thmsobrmlr #team-product-analytics
PRODUCT_ANALYTICS_QUARTER_YEAR_INTERVALS: 'product-analytics-quarter-year-intervals', // owner: @sampennington #team-product-analytics, gates quarter/year interval selection on insights
PRODUCT_ANALYTICS_QUILL_DATE_FILTER: 'product-analytics-quill-date-filter', // owner: @sampennington #team-product-analytics, swaps the insight date filter for the chip-based quill date filter (lemon-skinned)
- PRODUCT_ANALYTICS_QUILL_SQL_CHARTS: 'product-analytics-quill-sql-charts', // owner: #team-data-tools, gates rendering DataVisualization line/area charts via @posthog/quill-charts
PRODUCT_ANALYTICS_RETENTION_AGGREGATION: 'retention-aggregation', // owner: @anirudhpillai #team-product-analytics
PRODUCT_ANALYTICS_RETENTION_DWH: 'retention-dwh', // owner: @thmsobrmlr #team-product-analytics
PRODUCT_AUTONOMY: 'product-autonomy', // owner: #team-self-driving
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.tsx
deleted file mode 100644
index 0b409b28642a..000000000000
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.tsx
+++ /dev/null
@@ -1,775 +0,0 @@
-// TODO: Move the below scss to somewhere more common
-import '../../../../../scenes/insights/InsightTooltip/InsightTooltip.scss'
-
-import annotationPlugin, { AnnotationPluginOptions, LineAnnotationOptions } from 'chartjs-plugin-annotation'
-import dataLabelsPlugin from 'chartjs-plugin-datalabels'
-import ChartjsPluginStacked100 from 'chartjs-plugin-stacked100'
-import chartTrendline from 'chartjs-plugin-trendline'
-import clsx from 'clsx'
-import { useActions, useValues } from 'kea'
-import { useEffect, useMemo } from 'react'
-
-import { IconX } from '@posthog/icons'
-import { LemonTable } from '@posthog/lemon-ui'
-import { createXAxisTickCallback } from '@posthog/quill-charts'
-
-import {
- ActiveElement,
- Chart,
- ChartData,
- ChartEvent,
- ChartOptions,
- ChartType,
- ChartTypeRegistry,
- Color,
- GridLineOptions,
- ScaleOptionsByType,
- TickOptions,
- TooltipModel,
-} from 'lib/Chart'
-import { resolveVariableColor } from 'lib/charts/utils/color'
-import { getGraphColors, getSeriesColor } from 'lib/colors'
-import { InsightLabel } from 'lib/components/InsightLabel'
-import { FEATURE_FLAGS } from 'lib/constants'
-import { useChart } from 'lib/hooks/useChart'
-import { useKeyHeld } from 'lib/hooks/useKeyHeld'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
-import { hexToRGBA } from 'lib/utils/colors'
-import { uuid } from 'lib/utils/dom'
-import { unpinTooltip, useInsightTooltip } from 'scenes/insights/useInsightTooltip'
-import { teamLogic } from 'scenes/teamLogic'
-
-import { ChartSettings, GoalLine, YAxisSettings } from '~/queries/schema/schema-general'
-import { ChartDisplayType, GraphType } from '~/types'
-
-import { AxisSeries, AxisSeriesSettings, formatDataWithSettings } from '../../dataVisualizationLogic'
-import { AxisBreakdownSeries } from '../seriesBreakdownLogic'
-import { lineGraphLogic } from './lineGraphLogic'
-import { SqlBarGraph } from './SqlBarGraph'
-import { SqlComboGraph } from './SqlComboGraph'
-import { SqlLineGraph } from './SqlLineGraph'
-import {
- AREA_FILL_OPACITY,
- canRenderSqlBarGraph,
- canRenderSqlComboGraph,
- capYSeriesData,
- exceedsMaxSeries,
- isAreaSeries,
- warnTooManySeries,
-} from './sqlLineGraphAdapter'
-
-Chart.register(annotationPlugin)
-Chart.register(ChartjsPluginStacked100)
-Chart.register(chartTrendline)
-
-const getGraphType = (chartType: ChartDisplayType, settings: AxisSeriesSettings | undefined): GraphType => {
- if (!settings || !settings.display || !settings.display.displayType || settings.display?.displayType === 'auto') {
- return chartType === ChartDisplayType.ActionsBar || chartType === ChartDisplayType.ActionsStackedBar
- ? GraphType.Bar
- : GraphType.Line
- }
-
- if (settings.display?.displayType === 'bar') {
- return GraphType.Bar
- }
-
- return GraphType.Line
-}
-
-const axisLabelFont = {
- family: '"Emoji Flags Polyfill", -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Roboto", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
- size: 12,
- weight: 'normal' as const,
-}
-
-const getYAxisSettings = (
- chartSettings: ChartSettings,
- settings: YAxisSettings | undefined,
- stacked: boolean,
- position: 'left' | 'right',
- axisLabelColor: string | null,
- tickOptions: Partial<TickOptions>,
- gridOptions: Partial<GridLineOptions>
-): ScaleOptionsByType<ChartTypeRegistry['line']['scales']> => {
- const mixedGridOptions = {
- ...gridOptions,
- display: settings?.showGridLines ?? true,
- }
-
- const commonOptions = {
- display: true,
- stacked: stacked,
- grid: mixedGridOptions,
- position,
- title: {
- display: !!settings?.label,
- text: settings?.label ?? '',
- color: axisLabelColor ?? undefined,
- font: axisLabelFont,
- },
- border: {
- display: chartSettings.showYAxisBorder ?? true,
- },
- }
-
- if (settings?.scale === 'logarithmic') {
- // @ts-expect-error - needless complaining from chart.js types
- return {
- ...commonOptions,
- type: 'logarithmic',
- }
- }
-
- return {
- ...commonOptions,
- beginAtZero: settings?.startAtZero ?? chartSettings.yAxisAtZero ?? true,
- type: 'linear',
- // @ts-expect-error - needless complaining from chart.js types
- ticks: {
- display: settings?.showTicks ?? true,
- ...tickOptions,
- precision: 1,
- },
- }
-}
-
-export type LineGraphProps = {
- xData: AxisSeries<string> | null
- yData: AxisSeries<number | null>[] | AxisBreakdownSeries<number | null>[]
- visualizationType: ChartDisplayType
- chartSettings: ChartSettings
- presetChartHeight?: boolean
- dashboardId?: string
- goalLines?: GoalLine[]
- className?: string
- /** Called when the user clicks a data point. Receives the series key, x-axis index, and label.
- * When provided, the SQL chart shows a "click to inspect" hint in the tooltip. */
- onPointClick?: (seriesKey: string, dataIndex: number, label: string) => void
-}
-
-const LegacyLineGraph = ({
- xData,
- yData,
- presetChartHeight,
- visualizationType,
- chartSettings,
- dashboardId,
- goalLines = [],
- className,
-}: LineGraphProps): JSX.Element => {
- const { tooltipId, getTooltip, showTooltip, hideTooltip, positionTooltip, pinTooltip } = useInsightTooltip({
- isPinnable: true,
- })
-
- const logicKey = useMemo(() => uuid(), [])
- const { hoveredDatasetIndex } = useValues(lineGraphLogic({ key: logicKey }))
- const { setHoveredDatasetIndex } = useActions(lineGraphLogic({ key: logicKey }))
- const { timezone } = useValues(teamLogic)
- const isShiftPressed = useKeyHeld('Shift')
-
- useEffect(() => {
- if (!isShiftPressed) {
- setHoveredDatasetIndex(null)
- }
- }, [isShiftPressed, setHoveredDatasetIndex])
-
- const isBarChart =
- visualizationType === ChartDisplayType.ActionsBar || visualizationType === ChartDisplayType.ActionsStackedBar
- const isStackedBarChart = visualizationType === ChartDisplayType.ActionsStackedBar
- const isAreaChart = visualizationType === ChartDisplayType.ActionsAreaGraph
- const isHighlightBarMode = isBarChart && isStackedBarChart && isShiftPressed
-
- useEffect(() => {
- if (exceedsMaxSeries(yData, dashboardId)) {
- warnTooManySeries(yData!.length)
- }
- }, [yData, dashboardId])
-
- const ySeriesData = useMemo(() => capYSeriesData(yData), [yData])
-
- const datasets = useMemo(() => {
- if (!ySeriesData) {
- return null
- }
-
- return ySeriesData.map(({ data: seriesData, settings, ...rest }, index) => {
- const seriesColor = settings?.display?.color ?? getSeriesColor(index)
- const hasAreaFill = isAreaSeries(visualizationType, settings)
- let backgroundColor = hasAreaFill ? hexToRGBA(seriesColor, AREA_FILL_OPACITY) : seriesColor
-
- // Dim non-hovered bars in stacked bar charts when shift is pressed
- if (isHighlightBarMode && hoveredDatasetIndex !== null && index !== hoveredDatasetIndex) {
- backgroundColor = hexToRGBA(seriesColor, 0.2)
- }
-
- const graphType = getGraphType(visualizationType, settings)
-
- let yAxisID = 'yLeft'
- if (chartSettings.stackBars100) {
- yAxisID = 'y'
- } else if (settings?.display?.yAxisPosition === 'right') {
- yAxisID = 'yRight'
- }
-
- const getLabel = (): string => {
- if ('name' in rest) {
- return rest.name
- }
-
- return rest.column.name
- }
-
- return {
- data: seriesData,
- label: getLabel(),
- borderColor: seriesColor,
- backgroundColor: backgroundColor,
- borderWidth: graphType === GraphType.Bar ? 0 : 2,
- pointRadius: 0,
- hitRadius: 0,
- order: 1,
- hoverBorderWidth: graphType === GraphType.Bar ? 0 : 2,
- hoverBorderRadius: graphType === GraphType.Bar ? 0 : 2,
- type: graphType,
- fill: hasAreaFill ? 'origin' : false,
- yAxisID,
- ...(settings?.display?.trendLine && xData && yData && xData.data.length > 0 && seriesData.length > 0
- ? {
- trendlineLinear: {
- colorMin: hexToRGBA(seriesColor, 0.6),
- colorMax: hexToRGBA(seriesColor, 0.6),
- lineStyle: 'dotted',
- width: 3,
- },
- }
- : {}),
- } as ChartData['datasets'][0]
- })
- }, [
- ySeriesData,
- xData,
- yData,
- isHighlightBarMode,
- hoveredDatasetIndex,
- visualizationType,
- chartSettings.stackBars100,
- ])
-
- const { canvasRef } = useChart({
- getConfig: () => {
- const colors = getGraphColors()
-
- let xSeriesData: AxisSeries<string>
- let hasRightYAxis = false
- let hasLeftYAxis = false
- if (xData && ySeriesData && datasets) {
- xSeriesData = xData
- hasRightYAxis = !!ySeriesData.find((n) => n.settings?.display?.yAxisPosition === 'right')
- hasLeftYAxis =
- !chartSettings.stackBars100 &&
- (!hasRightYAxis || !!ySeriesData.find((n) => n.settings?.display?.yAxisPosition === 'left'))
- } else {
- return null
- }
-
- const data: ChartData = {
- labels: xSeriesData.data,
- datasets,
- }
-
- const annotations = goalLines.reduce<{
- annotations: Record<string, LineAnnotationOptions & { type: 'line' }>
- }>(
- (acc, cur, curIndex) => {
- const line: LineAnnotationOptions = {
- borderWidth: 2,
- borderDash: [6, 6],
- borderColor: resolveVariableColor(cur.borderColor),
- label: {
- display: cur.displayLabel ?? true,
- content: cur.label,
- position: cur.position ?? 'end',
- },
- scaleID: hasLeftYAxis ? 'yLeft' : 'yRight',
- value: cur.value,
- enter: (ctx) => {
- if (ctx.chart.options.plugins?.annotation?.annotations) {
- const annotationsList = ctx.chart.options.plugins.annotation.annotations as Record<
- string,
- any
- >
- if (annotationsList[`line${curIndex}`]) {
- annotationsList[`line${curIndex}`].label.content = `${
- cur.label
- }: ${cur.value.toLocaleString()}`
- const tooltipEl = document.getElementById('InsightTooltipWrapper-hover')
-
- if (tooltipEl) {
- tooltipEl.classList.add('opacity-0', 'invisible')
- }
-
- ctx.chart.update()
- }
- }
- },
- leave: (ctx) => {
- if (ctx.chart.options.plugins?.annotation?.annotations) {
- const annotationsList = ctx.chart.options.plugins.annotation.annotations as Record<
- string,
- any
- >
- if (annotationsList[`line${curIndex}`]) {
- annotationsList[`line${curIndex}`].label.content = cur.label
-
- const tooltipEl = document.getElementById('InsightTooltipWrapper-hover')
- if (tooltipEl) {
- tooltipEl.classList.remove('opacity-0', 'invisible')
- }
-
- ctx.chart.update()
- }
- }
- },
- }
-
- acc.annotations[`line${curIndex}`] = {
- type: 'line' as const,
- ...line,
- }
-
- return acc
- },
- { annotations: {} }
- ) as AnnotationPluginOptions
-
- const tickOptions: Partial<TickOptions> = {
- color: colors.axisLabel as Color,
- font: {
- family: '"Emoji Flags Polyfill", -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Roboto", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
- size: 12,
- weight: 'normal',
- },
- }
-
- const gridOptions: Partial<GridLineOptions> = {
- color: colors.axisLine as Color,
- tickColor: colors.axisLine as Color,
- tickBorderDash: [4, 2],
- }
-
- const isDateAxis = xSeriesData.column.type.name === 'DATE' || xSeriesData.column.type.name === 'DATETIME'
- const xAxisTickCallback = isDateAxis
- ? createXAxisTickCallback({
- allDays: xSeriesData.data,
- timezone,
- })
- : undefined
-
- const options: ChartOptions = {
- responsive: true,
- maintainAspectRatio: false,
- elements: {
- line: {
- tension: 0,
- },
- },
- plugins: {
- stacked100: { enable: isStackedBarChart && chartSettings.stackBars100, precision: 1 },
- datalabels: {
- color: 'white',
- anchor: (context) => {
- const datum = context.dataset.data[context.dataIndex]
- return typeof datum !== 'number' ? 'end' : datum > 0 ? 'end' : 'start'
- },
- backgroundColor: (context) => {
- return (context.dataset.borderColor as string) || 'black'
- },
- // Read the raw value from ySeriesData rather than the (possibly percent-scaled in
- // stacked-100 mode) dataset value, so labels match the tooltip and hide on nulls.
- display: (context) => {
- if (!chartSettings.showValuesOnSeries) {
- return false
- }
- return ySeriesData?.[context.datasetIndex]?.data[context.dataIndex] != null
- },
- formatter: (_value, context) => {
- const series = ySeriesData?.[context.datasetIndex]
- const formatted = formatDataWithSettings(
- series?.data[context.dataIndex] ?? null,
- series?.settings
- )
- return typeof formatted === 'object' ? null : formatted
- },
- borderWidth: 2,
- borderRadius: 4,
- borderColor: 'white',
- },
- legend: {
- display: chartSettings.showLegend ?? false,
- },
- annotation: annotations,
- ...(isBarChart
- ? { crosshair: false }
- : {
- crosshair: {
- snap: {
- enabled: true,
- },
- sync: {
- enabled: false,
- },
- zoom: {
- enabled: false,
- },
- line: {
- color: colors.crosshair ?? undefined,
- width: 1,
- },
- },
- }),
- tooltip: {
- enabled: false,
- mode: isHighlightBarMode ? 'point' : 'index',
- intersect: isHighlightBarMode,
- external({ chart, tooltip }: { chart: Chart; tooltip: TooltipModel<ChartType> }) {
- const canvas = chart.canvas
- if (!canvas) {
- return
- }
-
- const [tooltipRoot, tooltipEl] = getTooltip()
- if (tooltip.opacity === 0) {
- hideTooltip()
- return
- }
-
- tooltipEl.classList.remove('above', 'below', 'no-transform')
- tooltipEl.classList.add(tooltip.yAlign || 'no-transform')
- showTooltip()
-
- if (tooltip.body) {
- const { dataIndex, datasetIndex } = tooltip.dataPoints[0]
-
- const stackedSeriesTotalAtIndex =
- isStackedBarChart && chartSettings.stackBars100
- ? ySeriesData.reduce((acc, series) => acc + (series.data[dataIndex] ?? 0), 0)
- : null
-
- // Iterate ySeriesData directly so seriesIndex stays as the original index —
- // bar colors are derived from it, so the tooltip ribbon must match.
- const tooltipData: {
- series: string
- data: ReturnType<typeof formatDataWithSettings>
- rawData: number
- dataIndex: number
- seriesIndex: number
- stackedSeriesTotalAtIndex: number | null
- }[] = []
-
- for (let seriesIndex = 0; seriesIndex < ySeriesData.length; seriesIndex++) {
- if (isHighlightBarMode && seriesIndex !== datasetIndex) {
- continue
- }
-
- const series = ySeriesData[seriesIndex]
- const rawData = series.data[dataIndex]
- if (rawData == null) {
- continue
- }
-
- const settings = series.settings
- const seriesName =
- settings?.display?.label ||
- ('column' in series ? series.column.name : series.name)
-
- tooltipData.push({
- series: seriesName,
- data: formatDataWithSettings(rawData, settings),
- rawData,
- dataIndex,
- seriesIndex,
- stackedSeriesTotalAtIndex,
- })
- }
-
- if (tooltipData.length > 1 && !isHighlightBarMode) {
- tooltipData.sort((a, b) => b.rawData - a.rawData)
- }
-
- let totalLabel: string | null = null
- const tooltipTotalData = ySeriesData.filter(
- (n) => n.settings?.formatting?.style !== 'percent' && n.data[dataIndex] !== null
- )
- if (
- tooltipTotalData.length > 1 &&
- chartSettings.showTotalRow !== false &&
- !isHighlightBarMode
- ) {
- const totalRawData = tooltipTotalData.reduce((acc, cur) => {
- acc += cur.data[dataIndex] ?? 0
- return acc
- }, 0)
- const firstSeriesSettings = tooltipTotalData[0]?.settings
- totalLabel = String(
- formatDataWithSettings(totalRawData, firstSeriesSettings) ?? totalRawData
- )
- }
-
- tooltipRoot.render(
- <div className="InsightTooltip">
- <div className="flex items-center justify-between pl-5 pr-2 py-2 text-xs font-semibold border-b border-primary">
- <span>{xSeriesData.data[dataIndex]}</span>
- {pinTooltip && (
- <button
- type="button"
- className="InsightTooltip__close ml-5 p-0.5 rounded hover:bg-fill-button-tertiary-hover cursor-pointer"
- onClick={() => unpinTooltip(tooltipId)}
- >
- <IconX className="w-3 h-3" />
- </button>
- )}
- </div>
- <div className="max-h-64 overflow-y-auto">
- <LemonTable
- showHeader={false}
- dataSource={tooltipData}
- columns={[
- {
- dataIndex: 'series',
- render: (value) => {
- return (
- <div className="datum-label-column">
- <InsightLabel
- fallbackName={value?.toString()}
- hideBreakdown
- showSingleName
- hideCompare
- hideIcon
- allowWrap
- />
- </div>
- )
- },
- },
- {
- dataIndex: 'data',
- render: (value, record) => {
- if (isStackedBarChart && chartSettings.stackBars100) {
- const total = record.stackedSeriesTotalAtIndex
- if (!total) {
- return (
- <div className="series-data-cell text-right">
- {String(value)}
- </div>
- )
- }
- const rawData = record.rawData ?? 0
- const percentageLabel: number = parseFloat(
- ((rawData / total) * 100).toFixed(1)
- )
-
- return (
- <div className="series-data-cell text-right">
- {String(value)} ({percentageLabel}%)
- </div>
- )
- }
-
- return (
- <div className="series-data-cell text-right">
- {String(value)}
- </div>
- )
- },
- },
- ]}
- uppercaseHeader={false}
- rowRibbonColor={(_datum) => {
- return (
- ySeriesData[_datum.seriesIndex]?.settings?.display?.color ??
- getSeriesColor(_datum.seriesIndex)
- )
- }}
- />
- </div>
- {totalLabel && (
- <div className="flex justify-between px-5 py-2 text-xs font-bold border-t border-primary">
- <span className="flex-1">Total</span>
- <span className="text-right">{totalLabel}</span>
- </div>
- )}
- {isBarChart && isStackedBarChart && !isHighlightBarMode && (
- <div className="text-xs text-muted p-2 border-t">
- Hold Shift (⇧) to highlight individual bars
- </div>
- )}
- </div>
- )
- }
-
- const bounds = canvas.getBoundingClientRect()
- const centerVertically = isHighlightBarMode
- const caretY = centerVertically ? tooltip.caretY : 0
- positionTooltip(tooltipEl, bounds, tooltip.caretX, caretY, centerVertically)
- },
- },
- },
- hover: {
- mode: isBarChart ? 'point' : 'nearest',
- axis: 'x',
- intersect: false,
- },
- onHover: (_event: ChartEvent, elements: ActiveElement[]) => {
- // For stacked bar charts when shift is pressed, track hovered dataset to highlight only that bar
- if (isHighlightBarMode) {
- const hoveredIndex = elements.length > 0 ? elements[0].datasetIndex : null
- if (hoveredDatasetIndex !== hoveredIndex) {
- setHoveredDatasetIndex(hoveredIndex)
- }
- }
- },
- onClick: (_event: ChartEvent, _elements: ActiveElement[], chart: Chart) => {
- if (!pinTooltip) {
- return
- }
-
- // Show the crosshair on click if it was enabled initially
- if ((chart as any).crosshair) {
- ;(chart as any).crosshair.enabled = true
- }
-
- const events = [...(chart.options.events ?? [])]
- chart.options.events = []
- chart.update('none')
- showTooltip()
-
- pinTooltip(() => {
- if (!chart.canvas?.isConnected) {
- return
- }
-
- // Hide crosshair on tooltip unpin
- if ((chart as any).crosshair) {
- ;(chart as any).crosshair.enabled = false
- }
-
- // Reset chart back to initial events
- chart.options.events = events
- chart.setActiveElements([])
- chart.update('none')
- })
- },
- scales: {
- x: {
- display: true,
- beginAtZero: true,
- stacked: isStackedBarChart,
- ticks: {
- ...tickOptions,
- display: chartSettings.showXAxisTicks ?? true,
- ...(xAxisTickCallback
- ? { callback: xAxisTickCallback, maxRotation: 0, autoSkipPadding: 20 }
- : {}),
- },
- grid: {
- ...gridOptions,
- drawOnChartArea: false,
- tickLength: 12,
- display: chartSettings.showXAxisTicks ?? true,
- },
- border: {
- display: chartSettings.showXAxisBorder ?? true,
- },
- title: {
- display: !!chartSettings.xAxisLabel,
- text: chartSettings.xAxisLabel ?? '',
- color: colors.axisLabel ?? undefined,
- font: axisLabelFont,
- },
- },
- ...(hasLeftYAxis
- ? {
- yLeft: getYAxisSettings(
- chartSettings,
- chartSettings.leftYAxisSettings,
- isAreaChart || isStackedBarChart,
- 'left',
- colors.axisLabel,
- tickOptions,
- gridOptions
- ),
- }
- : {}),
- ...(hasRightYAxis
- ? {
- yRight: getYAxisSettings(
- chartSettings,
- chartSettings.rightYAxisSettings,
- isAreaChart || isStackedBarChart,
- 'right',
- colors.axisLabel,
- tickOptions,
- gridOptions
- ),
- }
- : {}),
- },
- }
-
- return {
- type: isBarChart ? GraphType.Bar : GraphType.Line,
- data,
- options,
- plugins: [dataLabelsPlugin],
- }
- },
- deps: [
- xData,
- yData,
- visualizationType,
- goalLines,
- chartSettings,
- dashboardId,
- getTooltip,
- pinTooltip,
- isHighlightBarMode,
- hoveredDatasetIndex,
- timezone,
- ],
- })
-
- return (
- <div
- className={clsx(className, 'rounded bg-surface-primary w-full grow relative overflow-hidden', {
- 'h-[60vh]': presetChartHeight,
- 'h-full': !presetChartHeight,
- })}
- >
- <canvas ref={canvasRef} />
- </div>
- )
-}
-
-export function sqlChartComponentFor(
- props: LineGraphProps,
- newChartsEnabled: boolean
-): (props: LineGraphProps) => JSX.Element {
- if (!newChartsEnabled) {
- return LegacyLineGraph
- }
- if (canRenderSqlComboGraph(props)) {
- return SqlComboGraph
- }
- if (canRenderSqlBarGraph(props)) {
- return SqlBarGraph
- }
- return SqlLineGraph
-}
-
-export const LineGraph = (props: LineGraphProps): JSX.Element => {
- const { featureFlags } = useValues(featureFlagLogic)
- const newChartsEnabled = !!featureFlags[FEATURE_FLAGS.PRODUCT_ANALYTICS_QUILL_SQL_CHARTS]
-
- const Component = sqlChartComponentFor(props, newChartsEnabled)
- return <Component {...props} />
-}
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/PieChart.test.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/PieChart.test.tsx
index 1964f89636ad..3b41ad479445 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/PieChart.test.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/PieChart.test.tsx
@@ -4,9 +4,6 @@ import { cleanup, render, screen } from '@testing-library/react'
import { setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
-import { FEATURE_FLAGS } from 'lib/constants'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
-
import { initKeaTests } from '~/test/init'
import { AxisSeries } from '../../dataVisualizationLogic'
@@ -28,7 +25,6 @@ afterEach(() => {
})
const props: PieChartProps = {
- uniqueKey: 'pie-wrapper-test',
xData: {
column: { name: 'category', type: { name: 'STRING', isNumerical: false }, label: 'category', dataIndex: 0 },
data: ['alpha', 'beta'],
@@ -44,15 +40,10 @@ const props: PieChartProps = {
}
describe('PieChart wrapper', () => {
- it('routes to the quill SqlPieGraph when the quill-sql-charts flag is on', async () => {
- featureFlagLogic.mount()
- featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.PRODUCT_ANALYTICS_QUILL_SQL_CHARTS], {
- [FEATURE_FLAGS.PRODUCT_ANALYTICS_QUILL_SQL_CHARTS]: true,
- })
-
+ it('renders the quill SqlPieGraph', async () => {
render(<PieChart {...props} />)
- // The quill PieChart canvas carries this accessible name; the legacy chart.js path does not.
+ // The quill PieChart canvas carries this accessible name.
expect(await screen.findByLabelText(/pie chart with/i, {}, { timeout: 5000 })).toBeInTheDocument()
})
})
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/PieChart.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/PieChart.tsx
index 5ad17d545184..4793b86662a1 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/PieChart.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/PieChart.tsx
@@ -1,22 +1,10 @@
-import clsx from 'clsx'
-import { BindLogic, useValues } from 'kea'
-import { useMemo } from 'react'
-
-import { LemonColorGlyph } from '@posthog/lemon-ui'
-
-import { FEATURE_FLAGS } from 'lib/constants'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
-import { insightLogic } from 'scenes/insights/insightLogic'
-import { PieChart as InsightPieChart } from 'scenes/insights/views/LineGraph/PieChart'
-
import { ChartSettings } from '~/queries/schema/schema-general'
-import { ChartDisplayType, GraphType, InsightLogicProps } from '~/types'
+import { ChartDisplayType } from '~/types'
-import { AxisSeries, formatDataWithSettings } from '../../dataVisualizationLogic'
+import { AxisSeries } from '../../dataVisualizationLogic'
import { AxisBreakdownSeries } from '../seriesBreakdownLogic'
-import { LineGraphProps } from './LineGraph'
+import { SqlChartProps } from './SqlChart'
import { SqlPieGraph } from './SqlPieGraph'
-import { buildPieSlices, canRenderSqlPieGraph, formatPieSliceCount } from './sqlPieGraphAdapter'
export interface PieChartProps {
xData: AxisSeries<string> | null
@@ -24,14 +12,10 @@ export interface PieChartProps {
chartSettings: ChartSettings
presetChartHeight?: boolean
className?: string
- uniqueKey: string
}
export function PieChart(props: PieChartProps): JSX.Element {
- const { featureFlags } = useValues(featureFlagLogic)
- const newChartsEnabled = !!featureFlags[FEATURE_FLAGS.PRODUCT_ANALYTICS_QUILL_SQL_CHARTS]
-
- const sqlPieProps: LineGraphProps = {
+ const sqlPieProps: SqlChartProps = {
xData: props.xData,
yData: props.yData,
visualizationType: ChartDisplayType.ActionsPie,
@@ -40,154 +24,5 @@ export function PieChart(props: PieChartProps): JSX.Element {
className: props.className,
}
- if (newChartsEnabled && canRenderSqlPieGraph(sqlPieProps)) {
- return <SqlPieGraph {...sqlPieProps} />
- }
-
- return <LegacyPieChart {...props} />
-}
-
-function LegacyPieChart({
- xData,
- yData,
- chartSettings,
- presetChartHeight,
- className,
- uniqueKey,
-}: PieChartProps): JSX.Element {
- const insightProps = useMemo<InsightLogicProps>(
- () => ({
- dashboardItemId: `new-sql-pie-chart-${uniqueKey}`,
- }),
- [uniqueKey]
- )
-
- const slices = useMemo(() => buildPieSlices(xData, yData), [xData, yData])
- const formattingSettings = yData[0]?.settings
- const total = slices.reduce((sum, slice) => sum + slice.value, 0)
- const showLegend = chartSettings.showLegend ?? false
- // Unset means an existing chart from before the labels option — keep showing values. New pies
- // are stamped with 'labels' when the type is picked (see dataVisualizationLogic).
- const sliceContent = chartSettings.pie?.sliceContent ?? 'values'
- // The total is a sum-of-values readout, so default it on only when slices show values.
- // `showPieTotal` is the legacy top-level toggle — honor it for charts saved before `pie`.
- const showPieTotal = chartSettings.pie?.showTotal ?? chartSettings.showPieTotal ?? sliceContent === 'values'
- const asPercent = (chartSettings.pie?.valueDisplay ?? 'absolute') === 'percentage'
-
- const absoluteFormatter = (value: number): string =>
- String(formatDataWithSettings(value, formattingSettings) ?? value)
- const sliceFormatter = (value: number): string =>
- asPercent ? (total > 0 ? `${parseFloat(((value / total) * 100).toFixed(1))}%` : '0%') : absoluteFormatter(value)
-
- // The legacy chart.js instance only rebuilds when its `useChart` deps change, and those exclude
- // the value formatter — so remount it when the slice content or absolute/percentage mode changes,
- // otherwise toggling them leaves the on-slice labels stale (only the React legend updates).
- const chartKey = `${JSON.stringify(formattingSettings?.formatting ?? {})}-${sliceContent}-${asPercent}`
-
- if (!slices.length) {
- return (
- <div className={clsx(className, 'rounded bg-surface-primary flex flex-1 items-center justify-center p-6')}>
- <span className="text-secondary text-sm">Pie charts require at least one positive value.</span>
- </div>
- )
- }
-
- const chart = (
- <BindLogic logic={insightLogic} props={insightProps}>
- <InsightPieChart
- key={chartKey}
- data-attr="sql-pie-chart"
- type={GraphType.Pie}
- labelGroupType="none"
- formula="-"
- showPersonsModal={false}
- tooltip={{
- showHeader: false,
- hideColorCol: true,
- renderCount: (value: number) => formatPieSliceCount(value, total, formattingSettings, asPercent),
- }}
- datasets={[
- {
- id: 0,
- data: slices.map((slice) => slice.value),
- labels: slices.map((slice) => slice.label),
- backgroundColor: slices.map((slice) => slice.color),
- borderColor: slices.map((slice) => slice.color),
- },
- ]}
- labels={slices.map((slice) => slice.label)}
- showValuesOnSeries={sliceContent === 'values'}
- showLabelOnSeries={sliceContent === 'labels'}
- valueFormatter={sliceFormatter}
- />
- </BindLogic>
- )
-
- const totalDisplay = showPieTotal ? (
- <div className="pt-4 text-center shrink-0">
- <div className="text-5xl font-bold">{absoluteFormatter(total)}</div>
- </div>
- ) : null
-
- const legend = showLegend ? (
- <div className="w-full xl:w-80 shrink-0 border border-border rounded bg-surface-secondary overflow-visible xl:overflow-auto">
- <div className="divide-y divide-border">
- {slices.map((slice) => {
- const percent = total > 0 ? ((slice.value / total) * 100).toFixed(1) : '0.0'
-
- return (
- <div key={slice.label} className="flex items-center justify-between gap-3 px-3 py-2 text-sm">
- <div className="flex items-center gap-2 min-w-0">
- <LemonColorGlyph color={slice.color} className="shrink-0" />
- <span className="truncate">{slice.label}</span>
- </div>
- <div className="text-right shrink-0">
- <div className="font-semibold">
- {asPercent ? `${percent}%` : absoluteFormatter(slice.value)}
- </div>
- <div className="text-xs text-secondary">
- {asPercent ? absoluteFormatter(slice.value) : `${percent}%`}
- </div>
- </div>
- </div>
- )
- })}
- </div>
- </div>
- ) : null
-
- return (
- <div
- className={clsx(className, 'rounded bg-surface-primary flex flex-1 p-4 gap-4', {
- 'h-[60vh]': presetChartHeight,
- 'h-full': !presetChartHeight,
- })}
- >
- {!showLegend ? (
- <div className="flex flex-1 min-h-0">
- <div className="flex flex-1 flex-col min-h-0">
- <div className="relative flex-1 min-h-[18rem]">{chart}</div>
- {totalDisplay}
- </div>
- </div>
- ) : (
- <>
- <div className="flex flex-col gap-4 w-full xl:hidden">
- <div className="flex flex-col">
- <div className="relative h-[18rem]">{chart}</div>
- {totalDisplay}
- </div>
- {legend}
- </div>
- <div className="hidden xl:flex flex-1 gap-4 min-h-0">
- <div className="flex flex-1 flex-col min-h-0">
- <div className="relative flex-1 min-h-[18rem]">{chart}</div>
- {totalDisplay}
- </div>
- {legend}
- </div>
- </>
- )}
- </div>
- )
+ return <SqlPieGraph {...sqlPieProps} />
}
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.stories.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.stories.tsx
index 3fdbd3753fd2..841e06c1e45f 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.stories.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.stories.tsx
@@ -5,8 +5,8 @@ import { ChartSettings } from '~/queries/schema/schema-general'
import { ChartDisplayType } from '~/types'
import { AxisSeries } from '../../dataVisualizationLogic'
-import { LineGraphProps } from './LineGraph'
import { SqlBarGraph } from './SqlBarGraph'
+import { SqlChartProps } from './SqlChart'
const meta: Meta<typeof SqlBarGraph> = {
title: 'Insights/SqlBarGraph',
@@ -50,7 +50,7 @@ function Stage({ children }: { children: ReactNode }): JSX.Element {
return <div style={{ height: 420, width: 760, display: 'flex', flexDirection: 'column' }}>{children}</div>
}
-const render = (props: LineGraphProps): JSX.Element => (
+const render = (props: SqlChartProps): JSX.Element => (
<Stage>
<SqlBarGraph {...props} />
</Stage>
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.tsx
index ada8defe3bc6..9cca7ac329c9 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.tsx
@@ -5,13 +5,13 @@ import { TimeSeriesBarChart, type PointClickData } from '@posthog/quill-charts'
import { makeChartErrorHandler } from 'products/product_analytics/frontend/insights/trends/shared/chartErrorHandler'
-import { LineGraphProps } from './LineGraph'
+import { type SqlChartProps } from './SqlChart'
import { type SqlLineSeriesMeta, buildBarChartConfig } from './sqlLineGraphAdapter'
import { useSqlChartModel } from './useSqlChartModel'
const handleChartError = makeChartErrorHandler('sql-bar-chart')
-export const SqlBarGraph = (props: LineGraphProps): JSX.Element => {
+export const SqlBarGraph = (props: SqlChartProps): JSX.Element => {
const { onPointClick: onPointClickProp } = props
const model = useSqlChartModel(props, buildBarChartConfig)
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.test.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlChart.test.ts
similarity index 61%
rename from frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.test.ts
rename to frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlChart.test.ts
index 0ac4d730e63a..c2d96c2443ad 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.test.ts
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlChart.test.ts
@@ -1,9 +1,9 @@
import { ChartDisplayType } from '~/types'
import { AxisSeries, AxisSeriesSettings } from '../../dataVisualizationLogic'
-import { LineGraphProps, sqlChartComponentFor } from './LineGraph'
+import { SqlChartProps, sqlChartComponentFor } from './SqlChart'
-const baseProps = (visualizationType: ChartDisplayType): LineGraphProps => ({
+const baseProps = (visualizationType: ChartDisplayType): SqlChartProps => ({
xData: null,
yData: [],
visualizationType,
@@ -24,27 +24,18 @@ const mixedYData: AxisSeries<number | null>[] = [
describe('sqlChartComponentFor', () => {
it.each([
- ['line', ChartDisplayType.ActionsLineGraph, true, 'SqlLineGraph'],
- ['bar', ChartDisplayType.ActionsBar, true, 'SqlBarGraph'],
- ['line with the flag off', ChartDisplayType.ActionsLineGraph, false, 'LegacyLineGraph'],
+ ['line', ChartDisplayType.ActionsLineGraph, 'SqlLineGraph'],
+ ['bar', ChartDisplayType.ActionsBar, 'SqlBarGraph'],
// Pie is not routed here — it has its own wrapper (see PieChart.test.tsx).
- ['pie (handled by the PieChart wrapper, not here)', ChartDisplayType.ActionsPie, true, 'SqlLineGraph'],
- ])('routes %s to the right component', (_name, visualizationType, newChartsEnabled, expected) => {
- expect(sqlChartComponentFor(baseProps(visualizationType), newChartsEnabled).name).toBe(expected)
+ ['pie (handled by the PieChart wrapper, not here)', ChartDisplayType.ActionsPie, 'SqlLineGraph'],
+ ])('routes %s to the right component', (_name, visualizationType, expected) => {
+ expect(sqlChartComponentFor(baseProps(visualizationType)).name).toBe(expected)
})
it.each([
['a bar-base chart', ChartDisplayType.ActionsBar],
['a line-base chart', ChartDisplayType.ActionsLineGraph],
])('routes mixed bar + line series on %s to SqlComboGraph', (_name, visualizationType) => {
- expect(sqlChartComponentFor({ ...baseProps(visualizationType), yData: mixedYData }, true).name).toBe(
- 'SqlComboGraph'
- )
- })
-
- it('keeps mixed series on the legacy path when the flag is off', () => {
- expect(sqlChartComponentFor({ ...baseProps(ChartDisplayType.ActionsBar), yData: mixedYData }, false).name).toBe(
- 'LegacyLineGraph'
- )
+ expect(sqlChartComponentFor({ ...baseProps(visualizationType), yData: mixedYData }).name).toBe('SqlComboGraph')
})
})
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlChart.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlChart.tsx
new file mode 100644
index 000000000000..4dd76211272a
--- /dev/null
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlChart.tsx
@@ -0,0 +1,44 @@
+import { ChartSettings, GoalLine } from '~/queries/schema/schema-general'
+import { ChartDisplayType } from '~/types'
+
+import { AxisSeries } from '../../dataVisualizationLogic'
+import { AxisBreakdownSeries } from '../seriesBreakdownLogic'
+import { SqlBarGraph } from './SqlBarGraph'
+import { SqlComboGraph } from './SqlComboGraph'
+import { SqlLineGraph } from './SqlLineGraph'
+import { canRenderSqlBarGraph, canRenderSqlComboGraph } from './sqlLineGraphAdapter'
+
+export type SqlChartProps = {
+ xData: AxisSeries<string> | null
+ yData: AxisSeries<number | null>[] | AxisBreakdownSeries<number | null>[]
+ visualizationType: ChartDisplayType
+ chartSettings: ChartSettings
+ presetChartHeight?: boolean
+ dashboardId?: string
+ goalLines?: GoalLine[]
+ className?: string
+ /** Called when the user clicks a data point. Receives the series key, x-axis index, and label.
+ * When provided, the SQL chart shows a "click to inspect" hint in the tooltip. */
+ onPointClick?: (seriesKey: string, dataIndex: number, label: string) => void
+}
+
+/**
+ * Picks the @posthog/quill-charts renderer for a SQL insight: combo for mixed bar + line/area
+ * series, bar for bar-only, line/area otherwise. (Pie has its own wrapper — see PieChart.)
+ */
+export function sqlChartComponentFor(props: SqlChartProps): (props: SqlChartProps) => JSX.Element {
+ if (canRenderSqlComboGraph(props)) {
+ return SqlComboGraph
+ }
+ if (canRenderSqlBarGraph(props)) {
+ return SqlBarGraph
+ }
+ return SqlLineGraph
+}
+
+/** Entry point for rendering a non-pie SQL (DataVisualization) chart: dispatches line, area, bar,
+ * stacked-bar, and combo series to the matching @posthog/quill-charts renderer. */
+export const SqlChart = (props: SqlChartProps): JSX.Element => {
+ const Component = sqlChartComponentFor(props)
+ return <Component {...props} />
+}
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlComboGraph.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlComboGraph.tsx
index 3e69e38c26f3..d090f627136d 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlComboGraph.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlComboGraph.tsx
@@ -4,19 +4,19 @@ import { TimeSeriesComboChart } from '@posthog/quill-charts'
import { makeChartErrorHandler } from 'products/product_analytics/frontend/insights/trends/shared/chartErrorHandler'
-import { LineGraphProps } from './LineGraph'
+import { type SqlChartProps } from './SqlChart'
import { SqlLineSeriesMeta, buildComboChartConfig } from './sqlLineGraphAdapter'
import { useSqlChartModel } from './useSqlChartModel'
const handleChartError = makeChartErrorHandler('sql-combo-chart')
/**
- * SQL mixed bar + line/area graph rendered via @posthog/quill-charts' {@link TimeSeriesComboChart},
- * gated behind the `product-analytics-quill-sql-charts` flag (see {@link LineGraph}). Handles the
- * mixed-type case the line-only and bar-only paths can't. Tooltip content (per-column formatting,
- * total row) is configured in {@link buildComboChartConfig}.
+ * SQL mixed bar + line/area graph rendered via @posthog/quill-charts' {@link TimeSeriesComboChart}
+ * (see {@link sqlChartComponentFor}). Handles the mixed-type case the line-only and bar-only paths
+ * can't. Tooltip content (per-column formatting, total row) is configured in
+ * {@link buildComboChartConfig}.
*/
-export const SqlComboGraph = (props: LineGraphProps): JSX.Element => {
+export const SqlComboGraph = (props: SqlChartProps): JSX.Element => {
const model = useSqlChartModel(props, buildComboChartConfig)
return (
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.test.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.test.tsx
index f521794db5c0..ebafa81fe384 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.test.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.test.tsx
@@ -18,7 +18,7 @@ import {
import { ChartDisplayType } from '~/types'
import { AxisSeries } from '../../dataVisualizationLogic'
-import { LineGraphProps } from './LineGraph'
+import { SqlChartProps } from './SqlChart'
import { SqlLineGraph } from './SqlLineGraph'
// Some blocks below mount the full DataVisualization tree (~7 logics). Neither timeout is set
@@ -68,7 +68,7 @@ const ySeries = (name: string, data: (number | null)[], settings: YSettings = {}
settings,
})
-const props = (overrides: Partial<LineGraphProps>): LineGraphProps => ({
+const props = (overrides: Partial<SqlChartProps>): SqlChartProps => ({
xData: xData(['Mon', 'Tue', 'Wed']),
yData: [],
visualizationType: ChartDisplayType.ActionsLineGraph,
@@ -76,7 +76,7 @@ const props = (overrides: Partial<LineGraphProps>): LineGraphProps => ({
...overrides,
})
-const renderChart = async (overrides: Partial<LineGraphProps>): Promise<void> => {
+const renderChart = async (overrides: Partial<SqlChartProps>): Promise<void> => {
renderWithInsights({ component: <SqlLineGraph {...props(overrides)} /> })
await screen.findByLabelText(/chart with/i)
}
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.tsx
index 9c1a8672bc28..c2ee8e3d6d72 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.tsx
@@ -5,19 +5,19 @@ import { DefaultTooltip, TimeSeriesLineChart, type PointClickData, type TooltipC
import { makeChartErrorHandler } from 'products/product_analytics/frontend/insights/trends/shared/chartErrorHandler'
-import { LineGraphProps } from './LineGraph'
+import { type SqlChartProps } from './SqlChart'
import { SqlLineSeriesMeta, buildLineChartConfig, formatSqlSeriesValue } from './sqlLineGraphAdapter'
import { useSqlChartModel } from './useSqlChartModel'
const handleChartError = makeChartErrorHandler('sql-line-chart')
/**
- * SQL line/area graph rendered via @posthog/quill-charts, gated behind the
- * `product-analytics-quill-sql-charts` flag (see {@link LineGraph}). Handles line, area, goal
- * lines, and trend lines; everything else falls back to the legacy chart.js path. Tooltip content
- * (per-column formatting, total row) is configured in {@link buildLineChartConfig}.
+ * SQL line/area graph rendered via @posthog/quill-charts. The default SQL chart renderer (see
+ * {@link sqlChartComponentFor}); bar-only and mixed series route to their own components. Handles
+ * line, area, goal lines, and trend lines. Tooltip content (per-column formatting, total row) is
+ * configured in {@link buildLineChartConfig}.
*/
-export const SqlLineGraph = (props: LineGraphProps): JSX.Element => {
+export const SqlLineGraph = (props: SqlChartProps): JSX.Element => {
const { onPointClick: onPointClickProp } = props
const model = useSqlChartModel(props, buildLineChartConfig)
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.stories.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.stories.tsx
index 11ce9f6a83c9..d2eda91d72b3 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.stories.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.stories.tsx
@@ -6,7 +6,7 @@ import { ChartDisplayType } from '~/types'
import { AxisSeries } from '../../dataVisualizationLogic'
import { AxisBreakdownSeries } from '../seriesBreakdownLogic'
-import { LineGraphProps } from './LineGraph'
+import { SqlChartProps } from './SqlChart'
import { SqlPieGraph } from './SqlPieGraph'
const meta: Meta<typeof SqlPieGraph> = {
@@ -48,7 +48,7 @@ function Stage({ children }: { children: ReactNode }): JSX.Element {
return <div style={{ height: 420, width: 760, display: 'flex', flexDirection: 'column' }}>{children}</div>
}
-const render = (props: LineGraphProps): JSX.Element => (
+const render = (props: SqlChartProps): JSX.Element => (
<Stage>
<SqlPieGraph {...props} />
</Stage>
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.test.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.test.tsx
index 6709a7aa4a98..f221667149dc 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.test.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.test.tsx
@@ -10,7 +10,7 @@ import { ChartDisplayType } from '~/types'
import { AxisSeries } from '../../dataVisualizationLogic'
import { AxisBreakdownSeries } from '../seriesBreakdownLogic'
-import { LineGraphProps } from './LineGraph'
+import { SqlChartProps } from './SqlChart'
import { SqlPieGraph } from './SqlPieGraph'
let cleanupJsdom: () => void
@@ -41,7 +41,7 @@ const yData = (data: (number | null)[]): AxisSeries<number | null>[] => [
},
]
-const baseProps = (chartSettings: ChartSettings, data: (number | null)[]): LineGraphProps => ({
+const baseProps = (chartSettings: ChartSettings, data: (number | null)[]): SqlChartProps => ({
xData,
yData: yData(data),
visualizationType: ChartDisplayType.ActionsPie,
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.tsx
index 4ee8c9a868ad..b97152a0994f 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.tsx
@@ -9,16 +9,15 @@ import { useChartTheme } from 'lib/charts/hooks'
import { makeChartErrorHandler } from 'products/product_analytics/frontend/insights/trends/shared/chartErrorHandler'
-import { LineGraphProps } from './LineGraph'
+import { SqlChartProps } from './SqlChart'
import { formatSqlSeriesValue } from './sqlLineGraphAdapter'
import { buildPieSeries, buildPieSlices, formatPieSliceCount } from './sqlPieGraphAdapter'
const handleChartError = makeChartErrorHandler('sql-pie-chart')
/**
- * SQL pie graph on @posthog/quill-charts' {@link PieChart}, gated behind the
- * `product-analytics-quill-sql-charts` flag (see {@link sqlChartComponentFor}). The chart core lives
- * in quill; the aggregation total and side legend stay here as chrome, matching the legacy wrapper.
+ * SQL pie graph on @posthog/quill-charts' {@link PieChart}. The chart core lives in quill; the
+ * aggregation total and side legend stay here as chrome.
*/
export const SqlPieGraph = ({
xData,
@@ -26,7 +25,7 @@ export const SqlPieGraph = ({
chartSettings,
presetChartHeight,
className,
-}: LineGraphProps): JSX.Element => {
+}: SqlChartProps): JSX.Element => {
const theme = useChartTheme()
const slices = useMemo(() => buildPieSlices(xData, yData), [xData, yData])
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/lineGraphLogic.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/lineGraphLogic.ts
deleted file mode 100644
index 685d9cfac866..000000000000
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/lineGraphLogic.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import { MakeLogicType, actions, kea, key, path, props, reducers } from 'kea'
-
-export interface LineGraphLogicProps {
- key: string
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface lineGraphLogicValues {
- hoveredDatasetIndex: number | null
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface lineGraphLogicActions {
- setHoveredDatasetIndex: (hoveredDatasetIndex: number | null) => {
- hoveredDatasetIndex: number | null
- }
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface lineGraphLogicMeta {
- key: string
-}
-
-export type lineGraphLogicType = MakeLogicType<
- lineGraphLogicValues,
- lineGraphLogicActions,
- LineGraphLogicProps,
- lineGraphLogicMeta
->
-
-export const lineGraphLogic = kea<lineGraphLogicType>([
- path(['queries', 'nodes', 'DataVisualization', 'Components', 'Charts', 'lineGraphLogic']),
- props({ key: '' } as LineGraphLogicProps),
- key((props) => props.key),
- actions({
- setHoveredDatasetIndex: (hoveredDatasetIndex: number | null) => ({ hoveredDatasetIndex }),
- }),
- reducers({
- hoveredDatasetIndex: [
- null as number | null,
- {
- setHoveredDatasetIndex: (_, { hoveredDatasetIndex }) => hoveredDatasetIndex,
- },
- ],
- }),
-])
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.test.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.test.ts
index de2657446785..282a731261eb 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.test.ts
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.test.ts
@@ -13,7 +13,7 @@ import { ChartDisplayType } from '~/types'
import { AxisSeries, AxisSeriesSettings } from '../../dataVisualizationLogic'
import { AxisBreakdownSeries } from '../seriesBreakdownLogic'
-import { LineGraphProps } from './LineGraph'
+import { SqlChartProps } from './SqlChart'
import {
AREA_FILL_OPACITY,
MAX_SERIES,
@@ -56,7 +56,7 @@ const breakdownSeries = (
settings: AxisBreakdownSeries<number | null>['settings'] = {}
): AxisBreakdownSeries<number | null> => ({ name: breakdownValue, breakdownValue, data, settings })
-const baseProps = (overrides: Partial<LineGraphProps>): LineGraphProps => ({
+const baseProps = (overrides: Partial<SqlChartProps>): SqlChartProps => ({
xData: null,
yData: [],
visualizationType: ChartDisplayType.ActionsLineGraph,
@@ -309,7 +309,7 @@ describe('sqlLineGraphAdapter', () => {
describe('capYSeriesData', () => {
it('returns null for missing data', () => {
- expect(capYSeriesData(undefined as unknown as LineGraphProps['yData'])).toBeNull()
+ expect(capYSeriesData(undefined as unknown as SqlChartProps['yData'])).toBeNull()
})
it('returns the data unchanged at or below the cap', () => {
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.ts
index bace41b7144a..179f41f76423 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.ts
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.ts
@@ -26,7 +26,7 @@ import { schemaGoalLinesToConfigs } from 'products/product_analytics/frontend/in
import { AxisSeries, AxisSeriesSettings, formatDataWithSettings } from '../../dataVisualizationLogic'
import { AxisBreakdownSeries } from '../seriesBreakdownLogic'
-import { LineGraphProps } from './LineGraph'
+import { type SqlChartProps } from './SqlChart'
export const MAX_SERIES = 200
@@ -65,7 +65,7 @@ export function seriesDisplayType(
/** True when the series resolve to a mix of bar and line/area — the case neither the line-only nor
* the bar-only quill path can render, so it routes to {@link SqlComboGraph}. */
export function hasMixedSeriesTypes(
- yData: NonNullable<LineGraphProps['yData']>,
+ yData: NonNullable<SqlChartProps['yData']>,
visualizationType: ChartDisplayType
): boolean {
let hasBar = false
@@ -109,7 +109,7 @@ export function buildTrendLineConfigs(ySeriesData: SqlLineYSeries[] | null | und
* Series that mix a bar with a line/area route to {@link canRenderSqlComboGraph}; other mixes fall
* back to the legacy chart.js path.
*/
-export function canRenderSqlLineGraph(props: LineGraphProps): boolean {
+export function canRenderSqlLineGraph(props: SqlChartProps): boolean {
const { visualizationType, yData } = props
if (
@@ -124,7 +124,7 @@ export function canRenderSqlLineGraph(props: LineGraphProps): boolean {
return true
}
-export function canRenderSqlBarGraph(props: LineGraphProps): boolean {
+export function canRenderSqlBarGraph(props: SqlChartProps): boolean {
const { visualizationType, yData } = props
if (visualizationType !== ChartDisplayType.ActionsBar && visualizationType !== ChartDisplayType.ActionsStackedBar) {
@@ -146,7 +146,7 @@ export function canRenderSqlBarGraph(props: LineGraphProps): boolean {
* bars are supported as long as every line/area series is routed to the right axis — one sharing
* the bars' axis can't be reconciled with the bars' [0, 1] percent scale, so that case falls back.
*/
-export function canRenderSqlComboGraph(props: LineGraphProps): boolean {
+export function canRenderSqlComboGraph(props: SqlChartProps): boolean {
const { visualizationType, yData, chartSettings } = props
if (
@@ -197,7 +197,7 @@ export function comboBarLayoutForDisplay(
}
/** Returns true when {@link MAX_SERIES} is exceeded and the user should be warned (not on dashboards). */
-export function exceedsMaxSeries(yData: LineGraphProps['yData'], dashboardId: LineGraphProps['dashboardId']): boolean {
+export function exceedsMaxSeries(yData: SqlChartProps['yData'], dashboardId: SqlChartProps['dashboardId']): boolean {
return !!yData && yData.length > MAX_SERIES && !dashboardId
}
@@ -208,7 +208,7 @@ export function warnTooManySeries(count: number): void {
}
/** Pure cap to {@link MAX_SERIES}; warn separately via {@link exceedsMaxSeries}/{@link warnTooManySeries}. */
-export function capYSeriesData(yData: LineGraphProps['yData']): SqlLineYSeries[] | null {
+export function capYSeriesData(yData: SqlChartProps['yData']): SqlLineYSeries[] | null {
if (!yData) {
return null
}
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlPieGraphAdapter.test.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlPieGraphAdapter.test.ts
index 60627dbddd57..edc42fa5adea 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlPieGraphAdapter.test.ts
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlPieGraphAdapter.test.ts
@@ -1,18 +1,8 @@
import { getSeriesColor } from 'lib/colors'
-import { ChartDisplayType } from '~/types'
-
import { AxisSeries } from '../../dataVisualizationLogic'
import { AxisBreakdownSeries } from '../seriesBreakdownLogic'
-import { LineGraphProps } from './LineGraph'
-import { buildPieSeries, buildPieSlices, canRenderSqlPieGraph, formatPieSliceCount } from './sqlPieGraphAdapter'
-
-const baseProps = (visualizationType: ChartDisplayType): LineGraphProps => ({
- xData: null,
- yData: [],
- visualizationType,
- chartSettings: {},
-})
+import { buildPieSeries, buildPieSlices, formatPieSliceCount } from './sqlPieGraphAdapter'
describe('sqlPieGraphAdapter', () => {
describe('formatPieSliceCount', () => {
@@ -169,16 +159,4 @@ describe('sqlPieGraphAdapter', () => {
expect(buildPieSeries([])).toEqual([])
})
})
-
- describe('canRenderSqlPieGraph', () => {
- it.each([
- [ChartDisplayType.ActionsPie, true],
- [ChartDisplayType.ActionsLineGraph, false],
- [ChartDisplayType.ActionsBar, false],
- [ChartDisplayType.ActionsStackedBar, false],
- [ChartDisplayType.ActionsAreaGraph, false],
- ])('returns %s -> %s', (visualizationType, expected) => {
- expect(canRenderSqlPieGraph(baseProps(visualizationType))).toBe(expected)
- })
- })
})
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlPieGraphAdapter.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlPieGraphAdapter.ts
index 62f4cf16f291..053f0663a156 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlPieGraphAdapter.ts
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlPieGraphAdapter.ts
@@ -2,11 +2,8 @@ import { type Series } from '@posthog/quill-charts'
import { getSeriesColor } from 'lib/colors'
-import { ChartDisplayType } from '~/types'
-
import { AxisSeries, AxisSeriesSettings } from '../../dataVisualizationLogic'
import { AxisBreakdownSeries } from '../seriesBreakdownLogic'
-import { LineGraphProps } from './LineGraph'
import { formatSqlSeriesValue } from './sqlLineGraphAdapter'
export interface PieSlice {
@@ -113,7 +110,3 @@ export const formatPieSliceCount = (
}
return `${formatted} (${shareOfTotal}%)`
}
-
-export function canRenderSqlPieGraph(props: LineGraphProps): boolean {
- return props.visualizationType === ChartDisplayType.ActionsPie
-}
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts
index bbc8b69e08a4..ef2e593f87f8 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts
@@ -6,7 +6,7 @@ import { type ChartTheme, type Series } from '@posthog/quill-charts'
import { useChartTheme, useChartConfig } from 'lib/charts/hooks'
import { teamLogic } from 'scenes/teamLogic'
-import { LineGraphProps } from './LineGraph'
+import { SqlChartProps } from './SqlChart'
import {
type BuildBarConfigArgs,
type SqlLineSeriesMeta,
@@ -24,7 +24,7 @@ export interface SqlChartModel<TConfig> {
}
export function useSqlChartModel<TConfig extends object>(
- { xData, yData, visualizationType, chartSettings, dashboardId, goalLines }: LineGraphProps,
+ { xData, yData, visualizationType, chartSettings, dashboardId, goalLines }: SqlChartProps,
buildConfig: (args: BuildBarConfigArgs) => TConfig
): SqlChartModel<TConfig> | null {
const { timezone } = useValues(teamLogic)
diff --git a/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx b/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
index aa4f3aaddec8..33dfa347c4af 100644
--- a/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
@@ -34,8 +34,8 @@ import { DateRange } from '../DataNode/DateRange'
import { ElapsedTime } from '../DataNode/ElapsedTime'
import { Reload } from '../DataNode/Reload'
import { QueryFeature } from '../DataTable/queryFeatures'
-import { LineGraph } from './Components/Charts/LineGraph'
import { PieChart } from './Components/Charts/PieChart'
+import { SqlChart } from './Components/Charts/SqlChart'
import { TwoDimensionalHeatmap } from './Components/Heatmap/TwoDimensionalHeatmap'
import { seriesBreakdownLogic } from './Components/seriesBreakdownLogic'
import { SideBar } from './Components/SideBar'
@@ -260,7 +260,7 @@ function InternalDataTableVisualization(props: DataTableVisualizationProps): JSX
const _xData = seriesBreakdownData.xData.data.length ? seriesBreakdownData.xData : xData
const _yData = seriesBreakdownData.xData.data.length ? seriesBreakdownData.seriesData : yData
component = (
- <LineGraph
+ <SqlChart
className="p-3"
xData={_xData}
yData={_yData}
@@ -280,7 +280,6 @@ function InternalDataTableVisualization(props: DataTableVisualizationProps): JSX
component = (
<PieChart
className="p-3"
- uniqueKey={props.uniqueKey?.toString() ?? dataVisualizationProps.key}
xData={_xData}
yData={_yData}
chartSettings={chartSettings}
diff --git a/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx b/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx
index 1db5ca3322da..7fc043c40d62 100644
--- a/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx
@@ -44,8 +44,8 @@ import { ElapsedTime } from '~/queries/nodes/DataNode/ElapsedTime'
import { LoadPreviewText } from '~/queries/nodes/DataNode/LoadNext'
import { QueryExecutionDetails } from '~/queries/nodes/DataNode/QueryExecutionDetails'
import { DataTableRow } from '~/queries/nodes/DataTable/dataTableLogic'
-import { LineGraph } from '~/queries/nodes/DataVisualization/Components/Charts/LineGraph'
import { PieChart } from '~/queries/nodes/DataVisualization/Components/Charts/PieChart'
+import { SqlChart } from '~/queries/nodes/DataVisualization/Components/Charts/SqlChart'
import { TwoDimensionalHeatmap } from '~/queries/nodes/DataVisualization/Components/Heatmap/TwoDimensionalHeatmap'
import { seriesBreakdownLogic } from '~/queries/nodes/DataVisualization/Components/seriesBreakdownLogic'
import { SideBar } from '~/queries/nodes/DataVisualization/Components/SideBar'
@@ -940,7 +940,7 @@ function InternalDataTableVisualization(
const _xData = seriesBreakdownData.xData.data.length ? seriesBreakdownData.xData : xData
const _yData = seriesBreakdownData.xData.data.length ? seriesBreakdownData.seriesData : yData
component = (
- <LineGraph
+ <SqlChart
className="p-2"
xData={_xData}
yData={_yData}
@@ -958,7 +958,6 @@ function InternalDataTableVisualization(
component = (
<PieChart
className="p-2"
- uniqueKey={props.uniqueKey?.toString() ?? dataVisualizationProps.key}
xData={_xData}
yData={_yData}
chartSettings={chartSettings}
diff --git a/frontend/src/scenes/insights/stories/SQLLineChart.stories.tsx b/frontend/src/scenes/insights/stories/SQLLineChart.stories.tsx
index 1bb851058552..60ac3c44f416 100644
--- a/frontend/src/scenes/insights/stories/SQLLineChart.stories.tsx
+++ b/frontend/src/scenes/insights/stories/SQLLineChart.stories.tsx
@@ -2,7 +2,6 @@ import { samplePersonProperties, sampleRetentionPeopleResponse } from 'scenes/in
import { Meta, StoryObj } from '@storybook/react'
-import { FEATURE_FLAGS } from 'lib/constants'
import { createInsightStory } from 'scenes/insights/__mocks__/createInsightScene'
import { mswDecorator } from '~/mocks/browser'
@@ -66,19 +65,15 @@ SQLLineChartBreakdown.parameters = {
export const SQLLineChartTrendLineQuill: Story = createInsightStory(__sqlLineChartTrendLine as any)
SQLLineChartTrendLineQuill.parameters = {
...meta.parameters,
- featureFlags: [FEATURE_FLAGS.PRODUCT_ANALYTICS_QUILL_SQL_CHARTS],
testOptions: {
...meta.parameters?.testOptions,
waitForSelector: '.DataVisualization canvas',
},
}
-// The legacy chart.js SQL renderer does not paint in the visual-regression harness (a pre-existing gap
-// that also affects the SQL line stories above), so this story targets the quill renderer, which does.
export const SQLBarChartValueLabelsQuill: Story = createInsightStory(__sqlBarChartValueLabels as any)
SQLBarChartValueLabelsQuill.parameters = {
...meta.parameters,
- featureFlags: [FEATURE_FLAGS.PRODUCT_ANALYTICS_QUILL_SQL_CHARTS],
testOptions: {
...meta.parameters?.testOptions,
waitForSelector: '.DataVisualization canvas',
diff --git a/frontend/src/test/insight-testing/render-data-visualization.tsx b/frontend/src/test/insight-testing/render-data-visualization.tsx
index b08327a4c114..017dbaf4322b 100644
--- a/frontend/src/test/insight-testing/render-data-visualization.tsx
+++ b/frontend/src/test/insight-testing/render-data-visualization.tsx
@@ -1,6 +1,5 @@
import { render } from '@testing-library/react'
-import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { actionsModel } from '~/models/actionsModel'
@@ -51,7 +50,6 @@ export interface RenderDataVisualizationProps {
query?: DataVisualizationNode
/** Row-major fixture, fed in via `cachedResults` to skip the network. */
response: DataVizFixture
- /** Defaults to `{ 'product-analytics-quill-sql-charts': true }`; merge in more or override. */
featureFlags?: Record<string, string | boolean>
readOnly?: boolean
embedded?: boolean
@@ -59,10 +57,10 @@ export interface RenderDataVisualizationProps {
}
/** Mount a SQL insight (`DataVisualizationNode`) the way the real scene does — through
- * `DataTableVisualization` → `dataVisualizationLogic` → `LineGraph` → the flag-gated quill
- * chart — with the query result injected via `cachedResults` so nothing hits the network. */
+ * `DataTableVisualization` → `dataVisualizationLogic` → `SqlChart` → the quill chart — with
+ * the query result injected via `cachedResults` so nothing hits the network. */
export function renderDataVisualization(props: RenderDataVisualizationProps): ReturnType<typeof render> {
- const featureFlags = { [FEATURE_FLAGS.PRODUCT_ANALYTICS_QUILL_SQL_CHARTS]: true, ...props.featureFlags }
+ const featureFlags = props.featureFlags ?? {}
initKeaTests()
actionsModel.mount()
diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
index 84d739d79d9c..e5a2fd2fb8b5 100644
--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md
+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
@@ -89,7 +89,7 @@ The Users tab reads its loaded data straight off `accountRelatedUsersLogic`, so
The Usage and Spend tabs render existing saved billing insights — **point users to them, don't rebuild billing as new insights.**
-**Customer analytics owns the billing chart render.** Each billing chart is multi-series on one shared axis, so a small-magnitude series (e.g. feature flag requests) is a flat sliver against large ones (events/enhanced persons) and can't be read. To offer per-series show/hide **without touching shared data-viz code**, `AccountBillingChart` renders the saved insight's SQL chart directly via `@posthog/quill-charts` instead of an embedded `<Query>`/DataVisualization. It reuses `dataVisualizationLogic` read-only for fetch + SQL-results→series parsing, and renders via `sqlLineGraphAdapter.ts`'s pure builders — the same series building, render dispatch, and line/bar/combo config building (per-column formatting, area fills, right-axis routing, goal and trend lines, percent stacks, plus the 200-series render cap applied locally) the SQL insight chart uses — while staying off that chart's React layer (`LineGraph`/`useSqlChartModel`). Chart-semantics changes belong in the adapter (covered by `sqlLineGraphAdapter.test.ts`), not here. Hidden series are injected into quill's controlled `legend.hiddenKeys` (excluded from drawing and scales; the rest rescale into the freed space). `AccountBillingSeriesToggle` is the control: a compact chip row under each chart, one chip per series colored to match its line/bar (items come from `legendItemsFromSeries` over the same `buildSeries` output the chart draws, so keys and colors can't drift). The hidden-keys state lives in `accountBillingLogic` (`ephemeralHiddenSeriesKeysByShortId`, keyed per insight because the spend tab renders two) — per-view only: never written to the saved insight, reset on date change, gone on row collapse. Queries whose shape `AccountBillingChart` can't render (non-DataViz, table/number/pie displays, series breakdowns — see `canRenderBillingChart`) fall back to the embedded `<Query>` with no chips.
+**Customer analytics owns the billing chart render.** Each billing chart is multi-series on one shared axis, so a small-magnitude series (e.g. feature flag requests) is a flat sliver against large ones (events/enhanced persons) and can't be read. To offer per-series show/hide **without touching shared data-viz code**, `AccountBillingChart` renders the saved insight's SQL chart directly via `@posthog/quill-charts` instead of an embedded `<Query>`/DataVisualization. It reuses `dataVisualizationLogic` read-only for fetch + SQL-results→series parsing, and renders via `sqlLineGraphAdapter.ts`'s pure builders — the same series building, render dispatch, and line/bar/combo config building (per-column formatting, area fills, right-axis routing, goal and trend lines, percent stacks, plus the 200-series render cap applied locally) the SQL insight chart uses — while staying off that chart's React layer (`SqlChart`/`useSqlChartModel`). Chart-semantics changes belong in the adapter (covered by `sqlLineGraphAdapter.test.ts`), not here. Hidden series are injected into quill's controlled `legend.hiddenKeys` (excluded from drawing and scales; the rest rescale into the freed space). `AccountBillingSeriesToggle` is the control: a compact chip row under each chart, one chip per series colored to match its line/bar (items come from `legendItemsFromSeries` over the same `buildSeries` output the chart draws, so keys and colors can't drift). The hidden-keys state lives in `accountBillingLogic` (`ephemeralHiddenSeriesKeysByShortId`, keyed per insight because the spend tab renders two) — per-view only: never written to the saved insight, reset on date change, gone on row collapse. Queries whose shape `AccountBillingChart` can't render (non-DataViz, table/number/pie displays, series breakdowns — see `canRenderBillingChart`) fall back to the embedded `<Query>` with no chips.
The Opportunities tab lists the account's Salesforce opportunities from the data-warehouse `salesforce.opportunity` table (joined by the account's `sfdc_id`). The query runs in `accountOpportunitiesLogic` rather than via a bare `<Query>` so the tab owns every state: a missing `sfdc_id` shows a "not linked to Salesforce" empty state, and because `salesforce.opportunity` is **access-gated and production-only**, a failed query degrades to a pretty hog empty state instead of a red error box. The expected denied/absent-table `QueryError` (`You don't have access to table …` / `Unknown table …`) is **not** captured to PostHog — it's the normal empty state, not a bug — while genuine, unexpected query failures are still reported (`isExpectedMissingTableError` in `accountOpportunitiesLogic`). Each opportunity name links to its Salesforce record (`SALESFORCE_ORIGIN/<id>` in `constants.ts`, the same origin the Useful links sidebar uses).
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountBillingChart.tsx b/products/customer_analytics/frontend/components/Accounts/AccountBillingChart.tsx
index 2021006b192c..8b7461f5c0cd 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountBillingChart.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountBillingChart.tsx
@@ -201,7 +201,7 @@ function BillingComboChart({
* embedded DataVisualization, so Customer analytics owns the per-series show/hide chips without
* touching shared data-viz code. `dataVisualizationLogic` is still reused read-only for fetch +
* SQL-results→series parsing, and the series/config builders come from `sqlLineGraphAdapter`'s
- * pure functions — but not the SQL chart's React layer (`LineGraph`, `useSqlChartModel`), so this
+ * pure functions — but not the SQL chart's React layer (`SqlChart`, `useSqlChartModel`), so this
* stays clear of the legacy paths being cleaned up there. Hidden series go into quill's controlled
* `legend.hiddenKeys`: excluded from drawing and scales, the rest rescale into the freed space.
*/