:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { LogicWrapper, MakeLogicType, actions, kea, key, path, props, reducers } from 'kea'
import { ScatterAreaSelection } from '@posthog/quill-charts'
interface BIScatterProps {
chartKey: string
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface biScatterLogicValues {
hiddenSeries: string[]
mode: 'select' | 'zoom'
selected: string[]
viewport: ScatterAreaSelection | null
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface biScatterLogicActions {
clear: () => {
value: true
}
select: (rows: string[]) => {
rows: string[]
}
setHiddenSeries: (keys: string[]) => {
keys: string[]
}
setMode: (mode: 'select' | 'zoom') => {
mode: 'select' | 'zoom'
}
setViewport: (viewport: ScatterAreaSelection | null) => {
viewport: ScatterAreaSelection | null
}
toggle: (row: string) => {
row: string
}
toggleSeries: (
key: string,
hidden: boolean
) => {
hidden: boolean
key: string
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface biScatterLogicMeta {
key: string
}
export type biScatterLogicType = MakeLogicType<
biScatterLogicValues,
biScatterLogicActions,
BIScatterProps,
biScatterLogicMeta
>
export const biScatterLogic: LogicWrapper<biScatterLogicType> = kea<biScatterLogicType>([
props({} as BIScatterProps),
key(({ chartKey }) => chartKey),
path((key) => ['products', 'business_intelligence', 'biScatterLogic', key]),
actions({
toggle: (row: string) => ({ row }),
select: (rows: string[]) => ({ rows }),
clear: true,
setHiddenSeries: (keys: string[]) => ({ keys }),
toggleSeries: (key: string, hidden: boolean) => ({ key, hidden }),
setMode: (mode: 'select' | 'zoom') => ({ mode }),
setViewport: (viewport: ScatterAreaSelection | null) => ({ viewport }),
}),
reducers({
hiddenSeries: [
[] as string[],
{
setHiddenSeries: (_, { keys }) => keys,
toggleSeries: (keys, { key, hidden }) =>
hidden ? [...new Set([...keys, key])] : keys.filter((item) => item !== key),
},
],
selected: [
[] as string[],
{
toggle: (selected, { row }) =>
selected.includes(row) ? selected.filter((index) => index !== row) : [...selected, row],
select: (_, { rows }) => [...new Set(rows)],
clear: () => [],
},
],
mode: ['select' as 'select' | 'zoom', { setMode: (_, { mode }) => mode }],
viewport: [null as ScatterAreaSelection | null, { setViewport: (_, { viewport }) => viewport }],
}),
])