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.

fix(notebooks): make SQL chart adapt to notebook node height (#57555)

Alex Liderf06afdbfaade
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.tsx
index 8c2f07f7b749..2bcd0a8d0714 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/LineGraph.tsx
@@ -34,7 +34,6 @@ import { InsightLabel } from 'lib/components/InsightLabel'
import { createXAxisTickCallback } from 'lib/hog-charts'
import { useChart } from 'lib/hooks/useChart'
import { useKeyHeld } from 'lib/hooks/useKeyHeld'
-import { useResizeObserver } from 'lib/hooks/useResizeObserver'
import { hexToRGBA, uuid } from 'lib/utils'
import { unpinTooltip, useInsightTooltip } from 'scenes/insights/useInsightTooltip'
import { teamLogic } from 'scenes/teamLogic'
@@ -151,8 +150,6 @@ export const LineGraph = ({
isPinnable: true,
})
- const { ref: containerRef, height } = useResizeObserver()
-
const logicKey = useMemo(() => uuid(), [])
const { hoveredDatasetIndex } = useValues(lineGraphLogic({ key: logicKey }))
const { setHoveredDatasetIndex } = useActions(lineGraphLogic({ key: logicKey }))
@@ -724,21 +721,12 @@ export const LineGraph = ({
return (
<div
- className={clsx(className, 'rounded bg-surface-primary relative flex flex-1 flex-col', {
+ className={clsx(className, 'rounded bg-surface-primary w-full grow relative overflow-hidden', {
'h-[60vh]': presetChartHeight,
'h-full': !presetChartHeight,
})}
- ref={containerRef}
>
- <div
- className={clsx('flex flex-1 w-full overflow-hidden', {
- 'h-full': !presetChartHeight,
- })}
- // eslint-disable-next-line react/forbid-dom-props
- style={height ? { height: `${height}px` } : {}}
- >
- <canvas ref={canvasRef} />
- </div>
+ <canvas ref={canvasRef} />
</div>
)
}
diff --git a/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx b/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
index a24b8853a353..15216feb610d 100644
--- a/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/DataVisualization.tsx
@@ -270,6 +270,10 @@ function InternalDataTableVisualization(props: DataTableVisualizationProps): JSX
component = <HogQLBoldNumber />
}
+ if (props.embedded) {
+ return <div className="DataVisualization InsightCard__viz">{component}</div>
+ }
+
return (
<div
className={clsx('DataVisualization flex flex-1 gap-2', {
diff --git a/frontend/src/queries/nodes/SavedInsight/SavedInsight.tsx b/frontend/src/queries/nodes/SavedInsight/SavedInsight.tsx
index 2790225afedf..0a2b1b3deb43 100644
--- a/frontend/src/queries/nodes/SavedInsight/SavedInsight.tsx
+++ b/frontend/src/queries/nodes/SavedInsight/SavedInsight.tsx
@@ -37,7 +37,7 @@ export function SavedInsight({
if (insightLoading) {
return (
- <div className="text-center">
+ <div className="flex flex-col flex-1 justify-center items-center w-full h-full">
<LoadingBar />
</div>
)
diff --git a/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx b/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx
index d4a831b35a9c..8e4f5f4c1b77 100644
--- a/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx
@@ -743,6 +743,7 @@ export function OutputPane({ tabId, showToolbar = true, onShareTab }: OutputPane
setProgress,
progress: queryId ? progressCache[queryId] : undefined,
showVisualizationSettings: showToolbar && isChartSettingsPanelOpen,
+ isEmbeddedMode,
}
const sharedActionsProps = {
response,
@@ -921,6 +922,10 @@ function InternalDataTableVisualization(
component = <HogQLBoldNumber />
}
+ if (props.embedded && !props.showSettingsPanel) {
+ return <div className="DataVisualization InsightCard__viz">{component}</div>
+ }
+
return (
<div className="DataVisualization h-full hide-scrollbar flex flex-1 gap-2">
<div className="relative w-full flex flex-col gap-4 flex-1">
@@ -983,6 +988,7 @@ const Content = ({
progress,
insightLoading,
showVisualizationSettings,
+ isEmbeddedMode,
}: any): JSX.Element | null => {
const [sortColumns, setSortColumns] = useState<SortColumn[]>([])
@@ -1050,6 +1056,7 @@ const Content = ({
cachedResults={undefined}
exportContext={exportContext}
editMode
+ embedded={isEmbeddedMode}
showSettingsPanel={showVisualizationSettings}
/>
</div>