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(bi): reuse chart data and preserve scatter selections (#117857)

Marius Andra0fad4dd7cbac
diff --git a/docs/published/handbook/engineering/data-warehouse.md b/docs/published/handbook/engineering/data-warehouse.md
index 88c41ae91b27..2fa2229cd3b8 100644
--- a/docs/published/handbook/engineering/data-warehouse.md
+++ b/docs/published/handbook/engineering/data-warehouse.md
@@ -330,7 +330,7 @@ When groups preserve ungrouped values, named groups and original members retain
Repeated dimension pills use distinct result columns so their chart and table bindings stay unambiguous. Generated dimension aliases avoid source identifiers used by measures and filters. Expressions containing percent signs or matching reserved names use supported generated aliases while keeping their original calculation.
-BI chart settings preserve custom scatter axes and implicit count formatting. Numeric date parts can be used as scatter axes. Switching to a box plot initializes statistic mappings from matching result column names. Generated axis labels follow field renames, while custom axis labels remain unchanged.
+BI chart settings preserve custom scatter axes and implicit count formatting. Numeric date parts can be used as scatter axes and remain numeric in **Keep only** and drill-down filters. Scatter selection shows a highlighted count with **Keep only** and **Clear selection** buttons. Switching between chart types reuses results when only their presentation changes, including with auto-update off; pending data changes still require a run. Switching to a box plot initializes statistic mappings from matching result column names. Generated axis labels follow field renames, while custom axis labels remain unchanged.
## Connected fields in BI mode
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 19c37b87b325..9af22a4f8203 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6775,13 +6775,13 @@ snapshots:
products-business-intelligence-pivot-table--multiple-measures-and-hierarchies--light:
hash: v1.k794b7964.f3a5839e83ddc9921b021426487c0f0db66fe969bc1369dd799c98bd83c91c19.e4TqncN8iN7TmyLw5M8lgUEjfSjD2LgrVykUPu1Ws48
products-business-intelligence-scatter--detail-and-color--dark:
- hash: v1.k794b7964.ea7c48d10f05c3469c1532587993bd0554a3023cba09f4192a7b9aed831572b8.rFbxAgQde59azurOYBf1s-fZ0slk-cE_x47MLfxfbSA
+ hash: v1.k794b7964.ad2cb47d76ab291b31e84102a821c01dead1ba448950dc9dde6414a24c2891e1.9u-YOJvW_VYRSOtZ6eaZ3zUXPeM0ETlPHRL8ri4BYhs
products-business-intelligence-scatter--detail-and-color--light:
- hash: v1.k794b7964.cefa152e63113b303d692533efb14bb2de2d9a3e741d728baab9a85e6872b06a.UEo_hWDx_kVM-k6jlwiaVZzzbQ2nJgUcApu4nEF25Kk
+ hash: v1.k794b7964.9496627a852f9a3245aeca8e505e1bbe5f9807a8fb92f7961cecf62f452e42f4.CvZKhdcFlOWzsKWUwyB6tfMCtfl6zFs-xygDpqHBhDA
products-business-intelligence-scatter--narrow--dark:
- hash: v1.k794b7964.c31725fbc5c0b2c9e5cd113f580c7693b92f73230b2bd13b053aeb840e439cd6.0nvX_0v-V-hA9i64ym7AZzNMMcvcbNBUMCy9xqxz3PE
+ hash: v1.k794b7964.18fc5ffe4152828340b17f3bf5f6c7196cd0a57ca211d61c1d76ba7ff042f593.zIIV4aK8uPfMSpcEYKwiQnEDA2B5W4wvO-SRi5vZHtY
products-business-intelligence-scatter--narrow--light:
- hash: v1.k794b7964.d92d93d905d850641bd661c0dffcdbaa59115b11e6cd1a00b6ae9c915cbf6677.FHXHFMiZytwruI4rYyx0_ZQU4YAFPEEFbAQKAl36DsI
+ hash: v1.k794b7964.b5f58da7e2c6183af226ebfcfc67d0d7d80036d9266ae3a7de5fa7bdd94fa5fb.tz297VQb3pwNAw397wzBcKu4l0OKpkhANKH62JnTjx8
products-business-intelligence-scatter--read-only--dark:
hash: v1.k794b7964.5272d9fc095372492de4bc666a4fd7c995c2fb3de8c859a48ddbf7dae5094c8b.VCgPn7znPvjkY-Sx_PsctneSMhp8KtDuBPxFoGjYdPA
products-business-intelligence-scatter--read-only--light:
@@ -6799,9 +6799,9 @@ snapshots:
products-business-intelligence-worksheet-exploration--narrow--light:
hash: v1.k794b7964.0fee0f5823ffe92065e82cbb68cf41af052ef0686f4af6983f002e14b6b7cc72.VIRLrujj_vgA_1g5UdicDqQ1qqGE4uomAIV93eW7YIk
products-business-intelligence-worksheet-exploration--scatter-selection--dark:
- hash: v1.k794b7964.f9498533f26dcbda10f7e4061038e713a7325f635743eb9977bcdd7cc4a04ae0.uhcKGOmcxsxznbzt19e2cZZcN3lNE-9cSBy5VlVq0pU
+ hash: v1.k794b7964.16b94e8d73a8d564096dc3c3600cccf22d4d1d123605ad499d6a3e0ccd8dfe11.Q5QHE8jnCZ_xX7p1RXGnV3BafVmnqUoYxwBoWBxyqyg
products-business-intelligence-worksheet-exploration--scatter-selection--light:
- hash: v1.k794b7964.2f3dee4b9e5f3f86f8d5639a380f16dfa8be646209b4a859d4476e6d2217c344.uykpvzQ3tWg2uGnQUAxfwrDNYlVHEI9zfqjWeaLCtuo
+ hash: v1.k794b7964.f862962672535e38e8687d2eeb6cf279719f0594be616d90027904eee06b4714.LJ3rLIyxwpuSgEMQNPieT_dZ4QX4cMWQ0dKXmivZH_I
products-business-intelligence-worksheet-exploration--sql-preview--dark:
hash: v1.k794b7964.0c799dde5f45d0132adea9cd565d4ef7d074b78255da1138a1b9c76b5030373c.1fmdtlQ1z0XQlGBswx8rJNK2wmfkwWYd-WdqLJaAMyg
products-business-intelligence-worksheet-exploration--sql-preview--light:
diff --git a/products/business_intelligence/frontend/BIScatterGraph.tsx b/products/business_intelligence/frontend/BIScatterGraph.tsx
index aba1364a2b4f..dad4cff3bc67 100644
--- a/products/business_intelligence/frontend/BIScatterGraph.tsx
+++ b/products/business_intelligence/frontend/BIScatterGraph.tsx
@@ -1,7 +1,7 @@
import { useActions, useValues } from 'kea'
import { useCallback, useMemo } from 'react'
-import { LemonBanner, LemonButton, LemonSelect } from '@posthog/lemon-ui'
+import { LemonBanner, LemonButton, LemonSelect, LemonTag } from '@posthog/lemon-ui'
import {
SqlScatterGraph,
@@ -116,7 +116,10 @@ export function BIScatterGraph({
return (
<div className="flex h-full w-full flex-1 min-h-0 min-w-0 flex-col">
{onKeepOnly && (
- <div className="flex flex-wrap items-center gap-2 px-3 py-1 text-xs" data-attr="bi-scatter-selection">
+ <div
+ className="flex shrink-0 flex-wrap items-center gap-2 border-b bg-surface-primary px-3 py-2 text-xs"
+ data-attr="bi-scatter-selection"
+ >
<LemonSelect
size="xsmall"
value={mode}
@@ -126,11 +129,17 @@ export function BIScatterGraph({
{ value: 'zoom', label: 'Zoom area' },
]}
/>
- <span data-attr="bi-scatter-selection-count">
- <span translate="no">{selectedCount}</span> selected
- </span>
+ <LemonTag
+ type={selectedCount ? 'highlight' : 'default'}
+ data-attr="bi-scatter-selection-count"
+ role="status"
+ aria-live="polite"
+ >
+ <span>{`${selectedCount} selected`}</span>
+ </LemonTag>
<LemonButton
- size="xsmall"
+ size="small"
+ type="primary"
onClick={() => {
onKeepOnly(selectedRecords)
clear()
@@ -151,9 +160,11 @@ export function BIScatterGraph({
Keep only
</LemonButton>
<LemonButton
- size="xsmall"
+ size="small"
+ type="secondary"
onClick={clear}
disabledReason={!selected.length ? 'No points selected' : undefined}
+ data-attr="bi-scatter-clear-selection"
>
Clear selection
</LemonButton>
@@ -164,7 +175,7 @@ export function BIScatterGraph({
>
Reset zoom
</LemonButton>
- <span className="text-secondary">
+ <span className="w-full text-secondary">
Click to toggle points or drag an area. Keep only changes worksheet filters; Undo restores them.
Missing coordinates are omitted; log axes require positive values.
</span>
diff --git a/products/business_intelligence/frontend/BusinessIntelligenceScene.stories.tsx b/products/business_intelligence/frontend/BusinessIntelligenceScene.stories.tsx
index 891ad4c8237c..999c05de3c4f 100644
--- a/products/business_intelligence/frontend/BusinessIntelligenceScene.stories.tsx
+++ b/products/business_intelligence/frontend/BusinessIntelligenceScene.stories.tsx
@@ -95,7 +95,7 @@ const meta: Meta = {
'/api/projects/:team_id/external_data_sources/direct_connection_options/': [],
},
post: {
- '/api/environments/:team_id/query/:kind/': async ({ request }) => {
+ '/api/environments/:team_id/query/:query_kind/': async ({ request }) => {
const { query } = (await request.json()) as {
query: { kind: string; query?: string; limit?: number }
}
diff --git a/products/business_intelligence/frontend/biDrilldown.ts b/products/business_intelligence/frontend/biDrilldown.ts
index ad66699be4da..9e50667ee4a1 100644
--- a/products/business_intelligence/frontend/biDrilldown.ts
+++ b/products/business_intelligence/frontend/biDrilldown.ts
@@ -18,6 +18,7 @@ import {
buildBITopMembership,
fieldExpression,
getBIResultDimensions,
+ isDateTimeBIField,
} from './biEditorTypes'
import { isBIConditionGroup, normalizeBIConditionGroup } from './biFilterGroups'
import { getBIMemberLabel } from './biMemberAliases'
@@ -113,7 +114,7 @@ export function getBIDrillSelection(config: BIConfig, record: Record<string, unk
if (other && typeof value === 'string' && value.startsWith('Other') && value.endsWith(' (category)')) {
value = value.slice(0, -11)
}
- const shiftedDate = previous && ['date', 'datetime'].includes(field.type)
+ const shiftedDate = previous && isDateTimeBIField(field)
const expression = fieldExpression(
shiftedDate ? { ...field, expression: getBIComparisonDateExpression(field) } : field
)
@@ -126,7 +127,7 @@ export function getBIDrillSelection(config: BIConfig, record: Record<string, unk
if (typeof value === 'number' && !Number.isFinite(value)) {
continue
}
- if (typeof value === 'number' && field.type === 'date') {
+ if (typeof value === 'number' && field.type === 'date' && isDateTimeBIField(field)) {
const date = dayjs.unix(value).utc()
if (!date.isValid()) {
continue
diff --git a/products/business_intelligence/frontend/biEditorTypes.ts b/products/business_intelligence/frontend/biEditorTypes.ts
index ce4f190a18ef..a946084eb8c5 100644
--- a/products/business_intelligence/frontend/biEditorTypes.ts
+++ b/products/business_intelligence/frontend/biEditorTypes.ts
@@ -952,7 +952,7 @@ function aggregationExpression(value: BIValue): string | null {
export function getBIFilterValidationError(filter: BIFilter): string | null {
if (
filter.enabled === false ||
- !isNumericBIField(filter.field) ||
+ !isNumericBIResultField(filter.field) ||
['custom', 'contains', 'is_set', 'is_not_set', 'last_7_days'].includes(filter.operator)
) {
return null
@@ -1043,7 +1043,7 @@ function filterExpression(filter: BIFilter): string | null {
}
// Strip leading zeroes so decimal input cannot become an octal HogQL literal.
const literal = (value: string): string =>
- isNumericBIField(filter.field) ? value.trim().replace(/^([+-]?)0+(?=\d)/, '$1') : escapeHogQLString(value)
+ isNumericBIResultField(filter.field) ? value.trim().replace(/^([+-]?)0+(?=\d)/, '$1') : escapeHogQLString(value)
if (filter.operator === 'in' || filter.operator === 'not_in') {
const values = filter.values ?? []
return values.length
diff --git a/products/business_intelligence/frontend/biQueryResults.test.ts b/products/business_intelligence/frontend/biQueryResults.test.ts
new file mode 100644
index 000000000000..c40a768f8e1a
--- /dev/null
+++ b/products/business_intelligence/frontend/biQueryResults.test.ts
@@ -0,0 +1,90 @@
+import { BIConfig, BIField, BIVisualizationNode } from '~/queries/schema/schema-business-intelligence'
+import { HogQLQueryResponse, NodeKind } from '~/queries/schema/schema-general'
+import { ChartDisplayType } from '~/types'
+
+import { buildBIQuery, DEFAULT_BI_CONFIG, getBIResultDimensions } from './biEditorTypes'
+import { getBIResultSummary, getBIVisualizationResponse, getBIVisualizationSource } from './biQueryResults'
+
+const field = (name: string): BIField => ({
+ id: name,
+ name,
+ expression: name,
+ type: 'string',
+ source: { table: 'example_orders' },
+})
+const config: BIConfig = {
+ ...DEFAULT_BI_CONFIG,
+ source: { table: 'example_orders' },
+ rows: [field('region')],
+ columns: [field('category')],
+ values: [{ field: { ...field('revenue'), type: 'float' }, aggregation: 'sum' }],
+ chartType: ChartDisplayType.ActionsBar,
+}
+const node = (config: BIConfig): BIVisualizationNode => ({
+ ...buildBIQuery(config)!.node,
+ kind: NodeKind.BIVisualizationNode,
+ config,
+})
+
+describe('BI visualization data reuse', () => {
+ test.each([
+ ChartDisplayType.ActionsTable,
+ ChartDisplayType.ScatterPlot,
+ ChartDisplayType.ActionsLineGraph,
+ ChartDisplayType.ActionsBarValue,
+ ChartDisplayType.ActionsAreaGraph,
+ ChartDisplayType.ActionsStackedBar,
+ ])('reuses grouped data for %s and retains the expected column names', (chartType) => {
+ const bar = node(config)
+ const query = node({ ...config, chartType })
+ expect(getBIVisualizationSource(query)).toEqual(getBIVisualizationSource(bar))
+ const columns = [...getBIResultDimensions(config).map(({ column }) => column), 'sum_revenue']
+ const response: HogQLQueryResponse = {
+ columns,
+ types: columns.map((column, index) => [column, index < 2 ? 'String' : 'Float64']),
+ results: [
+ ['east', 'books', 12],
+ ['west', 'games', 19],
+ ],
+ }
+ const visible = getBIVisualizationResponse(query, response) as HogQLQueryResponse
+ const expected = [...getBIResultDimensions(query.config).map(({ column }) => column), 'sum_revenue']
+ expect(visible.columns).toEqual(expected)
+ expect(visible.types?.map(([column]) => column)).toEqual(expected)
+ expect(visible.results).toEqual(response.results)
+ expect(response.columns).toEqual(columns)
+ expect(getBIResultSummary(query, visible)).toMatchObject({ groups: 2, marks: 2 })
+ // Cached responses from before data-request normalization already use the display's columns.
+ expect((getBIVisualizationResponse(query, visible) as HogQLQueryResponse).columns).toEqual(expected)
+ const cached: HogQLQueryResponse = {
+ ...response,
+ columns: ['region', 'category', 'sum_revenue'],
+ types: [
+ ['region', 'String'],
+ ['category', 'String'],
+ ['sum_revenue', 'Float64'],
+ ],
+ }
+ expect((getBIVisualizationResponse(query, cached) as HogQLQueryResponse).columns).toEqual(expected)
+ })
+
+ it('keeps data changes and pivot queries distinct, and preserves source execution options', () => {
+ const query = node(config)
+ const source = getBIVisualizationSource(query)
+ expect(
+ getBIVisualizationSource(node({ ...config, chartType: ChartDisplayType.TwoDimensionalHeatmap }))
+ ).not.toEqual(source)
+ expect(
+ getBIVisualizationSource(
+ node({ ...config, filters: [{ field: config.rows[0], operator: 'equals', value: 'east' }] })
+ )
+ ).not.toEqual(source)
+ expect(getBIVisualizationSource(node({ ...config, limit: 10000 }))).not.toEqual(source)
+ query.source.connectionId = 'example-connection'
+ query.source.variables = { example: { variableId: 'example', code_name: 'threshold', value: 3 } }
+ expect(getBIVisualizationSource(query)).toMatchObject({
+ connectionId: 'example-connection',
+ variables: query.source.variables,
+ })
+ })
+})
diff --git a/products/business_intelligence/frontend/biQueryResults.ts b/products/business_intelligence/frontend/biQueryResults.ts
index 568aa480c94f..93a7d3026488 100644
--- a/products/business_intelligence/frontend/biQueryResults.ts
+++ b/products/business_intelligence/frontend/biQueryResults.ts
@@ -1,9 +1,12 @@
import { getSeriesColor } from 'lib/colors'
+import { BIConfig } from '~/queries/schema/schema-business-intelligence'
import { AnyResponseType, ChartAxis, NodeKind, VisualizationNode } from '~/queries/schema/schema-general'
+import { ChartDisplayType } from '~/types'
+import { hasBIAnalysis } from './biAnalysis'
import { getBIComparisonGroupLimit } from './biComparisonLimit'
-import { buildBIQuery, getBIResultDimensions, getBIResultMeasureColumns } from './biEditorTypes'
+import { buildBIQuery, fieldExpression, getBIResultDimensions, getBIResultMeasureColumns } from './biEditorTypes'
export function getBISeriesSettings(query: VisualizationNode, settings: ChartAxis['settings']): ChartAxis['settings'] {
return query.kind === NodeKind.BIVisualizationNode && query.config.colorBy === null
@@ -48,11 +51,20 @@ export function getBIResultSummary(
}
}
+function getBIDataConfig(config: BIConfig): BIConfig {
+ return config.rows.length + config.columns.length === 2 &&
+ !hasBIAnalysis(config) &&
+ !config.compareFilter?.compare &&
+ !config.missingDates
+ ? { ...config, chartType: ChartDisplayType.ActionsBar }
+ : config
+}
+
export function getBIVisualizationSource(query: VisualizationNode): VisualizationNode['source'] {
if (query.kind !== NodeKind.BIVisualizationNode) {
return query.source
}
- const probe = buildBIQuery(query.config, true)
+ const probe = buildBIQuery(getBIDataConfig(query.config), true)
return probe ? { ...query.source, query: probe.query } : query.source
}
@@ -68,6 +80,24 @@ export function getBIVisualizationResponse(
) {
return response
}
+ const dataConfig = getBIDataConfig(query.config)
+ if (dataConfig !== query.config && 'columns' in response && Array.isArray(response.columns)) {
+ const dimensions = getBIResultDimensions(query.config)
+ const columns = response.columns
+ const aliases = new Map<string, string>()
+ getBIResultDimensions(dataConfig).forEach(({ column, field }, index) => {
+ if (columns[index] === column || columns[index] === fieldExpression(field)) {
+ aliases.set(columns[index], dimensions[index].column)
+ }
+ })
+ response = {
+ ...response,
+ columns: response.columns.map((column) => aliases.get(column) ?? column),
+ ...('types' in response && Array.isArray(response.types)
+ ? { types: response.types.map(([column, type]) => [aliases.get(column) ?? column, type]) }
+ : {}),
+ }
+ }
const trimmed = {
...response,
results: response.results.slice(0, query.config.limit),
@@ -84,7 +114,7 @@ export function getBIVisualizationResponse(
const selected = new Set([...groups].slice(0, getBIComparisonGroupLimit(query.config)))
return {
...response,
- results: response.results.filter((row) => selected.has(key(row))),
+ results: response.results.filter((row: unknown[]) => selected.has(key(row))),
hasMore: groups.size > selected.size || ('hasMore' in response && response.hasMore === true),
}
}
diff --git a/products/business_intelligence/frontend/biScatter.test.ts b/products/business_intelligence/frontend/biScatter.test.ts
index b570c60d48a7..2d9cbd2bf7ac 100644
--- a/products/business_intelligence/frontend/biScatter.test.ts
+++ b/products/business_intelligence/frontend/biScatter.test.ts
@@ -185,3 +185,23 @@ it('keeps exact selected tuples AND existing OR restrictions, including null and
expect(keepBIScatterRows(config, [])).toBeNull()
expect(keepBIScatterRows(config, Array(201).fill({ [itemColumn]: 'A' }))).toBeNull()
})
+
+it.each(['month', 'quarter', 'day_of_week'] as const)(
+ 'keeps numeric %s members without converting them to dates',
+ (datePart) => {
+ const worksheet: BIConfig = {
+ ...config,
+ rows: [],
+ columns: [{ ...field('placed_at', 'date'), datePart }],
+ values: [config.values[0]],
+ }
+ const column = getBIResultDimensions(worksheet)[0].column
+ const selected = keepBIScatterRows(worksheet, [{ [column]: 2 }, { [column]: 3 }])!
+ expect(selected.filters.map(({ value }) => value)).toEqual(['2', '3'])
+ const sql = buildBIQuery(selected)!.query
+ expect(sql).toContain(`${column} = 2`)
+ expect(sql).toContain(`${column} = 3`)
+ expect(sql).not.toContain('1970-01-01')
+ expect(buildBIQuery({ ...selected, filters: [{ ...selected.filters[0], value: 'not a number' }] })).toBeNull()
+ }
+)
diff --git a/products/business_intelligence/frontend/biSceneLogic.test.ts b/products/business_intelligence/frontend/biSceneLogic.test.ts
index 427e071fd5e4..7bcba0195440 100644
--- a/products/business_intelligence/frontend/biSceneLogic.test.ts
+++ b/products/business_intelligence/frontend/biSceneLogic.test.ts
@@ -851,7 +851,7 @@ describe('biSceneLogic', () => {
logic.actions.restoreWorksheet(worksheet())
const data = dataNodeLogic({
key: logic.values.dataNodeKey,
- query: logic.values.worksheet.source,
+ query: getBIVisualizationSource(logic.values.worksheet),
autoLoad: false,
})
data.mount()
@@ -873,7 +873,7 @@ describe('biSceneLogic', () => {
expect(run).toHaveBeenCalledTimes(state === 'ready' ? 0 : 1)
editor.actions.setChartType(ChartDisplayType.ActionsTable)
await jest.advanceTimersByTimeAsync(500)
- expect(run).toHaveBeenCalledTimes(state === 'ready' ? 1 : 2)
+ expect(run).toHaveBeenCalledTimes(state === 'ready' ? 0 : 1)
} finally {
jest.useRealTimers()
data.unmount()
@@ -882,6 +882,23 @@ describe('biSceneLogic', () => {
}
)
+ it('applies display-only chart changes with auto-update off while leaving query edits pending', () => {
+ logic.actions.restoreWorksheet(worksheet())
+ editor.actions.setAutoUpdate(false)
+ const run = jest.spyOn(logic.actions, 'runQuery')
+ try {
+ editor.actions.setChartType(ChartDisplayType.ActionsTable)
+ expect(logic.values.lastRunQuery?.display).toBe(ChartDisplayType.ActionsTable)
+ editor.actions.setLimit(10000)
+ editor.actions.setChartType(ChartDisplayType.ActionsLineGraph)
+ expect(logic.values.lastRunQuery?.display).toBe(ChartDisplayType.ActionsTable)
+ expect(logic.values.lastRunQuery?.config.limit).toBe(1000)
+ expect(run).not.toHaveBeenCalled()
+ } finally {
+ run.mockRestore()
+ }
+ })
+
test.each(['disable', 'clear', 'invalid', 'unchanged'] as const)(
'handles pending auto-update when %s',
async (transition) => {
diff --git a/products/business_intelligence/frontend/biSceneLogic.ts b/products/business_intelligence/frontend/biSceneLogic.ts
index 62e09e9140bd..65fbfda6b05c 100644
--- a/products/business_intelligence/frontend/biSceneLogic.ts
+++ b/products/business_intelligence/frontend/biSceneLogic.ts
@@ -765,7 +765,8 @@ export const biSceneLogic: LogicWrapper<biSceneLogicType> = kea<biSceneLogicType
if (values.autoUpdate && values.generatedQuery) {
const dataLogic = dataNodeLogic.findMounted({ key: values.dataNodeKey })
if (
- !equal(values.lastRunQuery?.source, values.worksheet.source) ||
+ !values.lastRunQuery ||
+ !equal(getBIVisualizationSource(values.lastRunQuery), getBIVisualizationSource(values.worksheet)) ||
(!dataLogic?.values.responseLoading &&
(!dataLogic?.values.response ||
dataLogic.values.responseError ||
@@ -777,12 +778,24 @@ export const biSceneLogic: LogicWrapper<biSceneLogicType> = kea<biSceneLogicType
}
}
},
+ setChartType: () => {
+ if (
+ !values.autoUpdate &&
+ values.lastRunQuery &&
+ equal({ ...values.lastRunQuery.config, chartType: values.config.chartType }, values.config) &&
+ equal(getBIVisualizationSource(values.lastRunQuery), getBIVisualizationSource(values.worksheet))
+ ) {
+ actions.setLastRunQuery(values.worksheet)
+ }
+ },
runQuery: () => {
if (!values.generatedQuery) {
return
}
captureBIEditorQueryRun({ editorView: BIEditorView.BI, config: values.config })
- const unchanged = equal(values.lastRunQuery?.source, values.worksheet.source)
+ const unchanged =
+ !!values.lastRunQuery &&
+ equal(getBIVisualizationSource(values.lastRunQuery), getBIVisualizationSource(values.worksheet))
actions.setLastRunQuery(values.worksheet)
if (unchanged) {
dataNodeLogic.findMounted({ key: values.dataNodeKey })?.actions.loadData('force_async')
diff --git a/products/business_intelligence/frontend/components/BIChartTypes.tsx b/products/business_intelligence/frontend/components/BIChartTypes.tsx
index 52628ecd3dc2..6ec394fe5023 100644
--- a/products/business_intelligence/frontend/components/BIChartTypes.tsx
+++ b/products/business_intelligence/frontend/components/BIChartTypes.tsx
@@ -34,7 +34,8 @@ export function BIChartTypes(): JSX.Element {
active={selected}
icon={option.icon}
size="small"
- className={!fits && !selected ? 'justify-center opacity-40' : 'justify-center'}
+ center
+ className={!fits && !selected ? 'opacity-40' : undefined}
tooltip={option.label}
aria-label={option.label}
aria-pressed={selected}