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.

feat(charts): Improve pie chart visualizations (#65802)

Sinan Kucukkoseler2e12d619bcfe
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 210a2de311cb..da8366fac595 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -784,6 +784,10 @@ snapshots:
hash: v1.k794b7964.95f52c48e6476dd49327e572e78275692bf3085a46c78b57d7ccb0f2af33229d.UKy0xtoAM3JGpdygHr-mG_fCI8HoINH0cq0e-w5MuYY
components-hogcharts-piechart--donut--light:
hash: v1.k794b7964.0094d02615d384b5473614f1e66499dfc907fe2875f5c643ce4c5612daba4915.zgE_VTPCiOQ9B1ml1I4G1oIxWriQKHrQ00KAqen7Dig
+ components-hogcharts-piechart--labels-toward-rim--dark:
+ hash: v1.k794b7964.e9c90cb2ba3eb12f4d38f23f4b1993d58e80e6ac9ef3b1592127be34b7b468f1.wq5lwfS8cAVj0UHQZDTJ5DziOQ_w8XvNGXzEYpfRkwk
+ components-hogcharts-piechart--labels-toward-rim--light:
+ hash: v1.k794b7964.e3d63cd6738f46dfcc17086060652610e44a70d146685326c680283b792cbe34.NXFXlOND-clhLC2iJ9RysxaANfZNqLfJ9zOAqeB3ZrU
components-hogcharts-piechart--long-label-tooltip--dark:
hash: v1.k794b7964.2eb01876c36f7266b5ef594afdb4aa059aaeea48c8ad23fd4a99a4ee531ad2bb.KCI5Xfrd-yW-jq4JXylwkbJ-SUjTX0KlvEgdP2B6JGk
components-hogcharts-piechart--long-label-tooltip--light:
@@ -2565,17 +2569,17 @@ snapshots:
insights-retentionlinechart--realistic-curve--light:
hash: v1.k794b7964.4d86747ef6244c9dfda63e380938e7d5a2d4e8bb5643a689911b7c000da38439.Onr3r4WyIzDx9G1iqCIq-Y3n8HJi7d3D4N2VPP9VMow
insights-sqlpiegraph--breakdown-colors--dark:
- hash: v1.k794b7964.470925de4820537085efce3e34dae137f86e39facc2ea154a9f16b5a5ca7c24d.d6RbyL3SlxGTdxtm-nf-oI1dpKT4rtbyTgRVaCCAM1U
+ hash: v1.k794b7964.60c9dc1733c40284a0f8c4c2a4254eee7fcdbe30c0ad938430d6ab638214376e.orj-HPnV81xgsInKHLt59sKlWPEmEWdjrX15K5e4Vfs
insights-sqlpiegraph--breakdown-colors--light:
- hash: v1.k794b7964.326aeff8c3f2a67f72991d488062e4a522d32b4abf7827a279517ac89cb4e996.rNMY2s51MqI8mbcI4QEYe6mOayeIn-CU439N9mvxua4
+ hash: v1.k794b7964.fde699834181a4ac4f067576f383db5231c6df5138f7ec610392ea1e449a4d43.0fW_VIsTwA6bN0o_S7IcMpcd11LvsSzg16IP6h9cK84
insights-sqlpiegraph--default--dark:
- hash: v1.k794b7964.69d959b6da0714cb15749bda0154bf8e75c851096db4046d7649028cddfbfcec.5HrKjQ_i1oGPCe2C4PjqSSvt5Uo1Ut-mGVX7UwGZh4I
+ hash: v1.k794b7964.003120d926a54f5a0c5385cd117f4c9aa2e6b3d148b40f6fba5e9099d1127114.b4ruasnLfEPAZUqOVavi3Haql0KCm3XFcuZwmHQThlM
insights-sqlpiegraph--default--light:
- hash: v1.k794b7964.f5a009e13082094b0195af966cde19b289974ac8c54261b0871d86ed962fb7b2.aliPJsCIazzCphQ7X-7ZIbBAsKee1OeDrO1Un_p003Q
+ hash: v1.k794b7964.9dec6c12f5a5794b852a7a437c57bc6656230454ea4297eb50904e99d47f41be.0c-HYruonogF-gGwDmN6R3OPVCXZSwNOmw_ZQ77mJWg
insights-sqlpiegraph--with-legend--dark:
- hash: v1.k794b7964.fcb21fd79db53b62394f5a12551c0918b081cba21206788e8fe229ac23f04c7e.yOYHdOAHOMIgzoS7IzahzFGk0KJQqIz_A2kF4Y-mvTY
+ hash: v1.k794b7964.ce006d3e970a5f5a593899b7becf2dbe67aeb87c72e35332da59d8264c0b6499.Vfy9klsxjcqRFIqQH2Y7OiFSTlL2J27w8jS2Pv4LVVQ
insights-sqlpiegraph--with-legend--light:
- hash: v1.k794b7964.56fd0f5cbef5514f7e10d5a38d0a376c399f4d520059c1e12ce4ef557d37bffd.MYW8k6KAEnxVE7EOAPqhhoEqdoltzjuy7G0gRPJuq40
+ hash: v1.k794b7964.6e312f2b1fdb84b3282a1a1ced223ae45162a5be1510367ca10b58aa59442dcb.Zm5NUz6V9wLLvOYLMye8LT423A0QCGquAypN_bzW35I
insights-stickinessbarchart--stacked--dark:
hash: v1.k794b7964.06d7987531ee38109e865aabbe9e5cc197d030ff62e5ecfc18a7f1c7f9184703.blTIjpW25Ww909yC_cJKt6jm1-ZQo_LmovewZTUyTro
insights-stickinessbarchart--stacked--light:
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/PieChart.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/PieChart.tsx
index 4d69887ec4cf..3bf154b7d06c 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/PieChart.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/PieChart.tsx
@@ -64,10 +64,24 @@ function LegacyPieChart({
const slices = useMemo(() => buildPieSlices(xData, yData), [xData, yData])
const formattingSettings = yData[0]?.settings
- const formattingKey = JSON.stringify(formattingSettings?.formatting ?? {})
const total = slices.reduce((sum, slice) => sum + slice.value, 0)
const showLegend = chartSettings.showLegend ?? false
- const showPieTotal = chartSettings.showPieTotal ?? true
+ // 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.
+ const showPieTotal = chartSettings.pie?.showTotal ?? 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 (
@@ -80,7 +94,7 @@ function LegacyPieChart({
const chart = (
<BindLogic logic={insightLogic} props={insightProps}>
<InsightPieChart
- key={formattingKey}
+ key={chartKey}
data-attr="sql-pie-chart"
type={GraphType.Pie}
labelGroupType="none"
@@ -89,7 +103,7 @@ function LegacyPieChart({
tooltip={{
showHeader: false,
hideColorCol: true,
- renderCount: (value: number) => formatPieSliceCount(value, total, formattingSettings),
+ renderCount: (value: number) => formatPieSliceCount(value, total, formattingSettings, asPercent),
}}
datasets={[
{
@@ -101,17 +115,16 @@ function LegacyPieChart({
},
]}
labels={slices.map((slice) => slice.label)}
- showValuesOnSeries={chartSettings.showValuesOnSeries ?? true}
- valueFormatter={(value) => String(formatDataWithSettings(value, formattingSettings) ?? value)}
+ 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">
- {String(formatDataWithSettings(total, formattingSettings) ?? total)}
- </div>
+ <div className="text-5xl font-bold">{absoluteFormatter(total)}</div>
</div>
) : null
@@ -129,9 +142,11 @@ function LegacyPieChart({
</div>
<div className="text-right shrink-0">
<div className="font-semibold">
- {String(formatDataWithSettings(slice.value, formattingSettings) ?? slice.value)}
+ {asPercent ? `${percent}%` : absoluteFormatter(slice.value)}
+ </div>
+ <div className="text-xs text-secondary">
+ {asPercent ? absoluteFormatter(slice.value) : `${percent}%`}
</div>
- <div className="text-xs text-secondary">{percent}%</div>
</div>
</div>
)
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 9a5d0960b83e..11ce9f6a83c9 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.stories.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.stories.tsx
@@ -54,7 +54,7 @@ const render = (props: LineGraphProps): JSX.Element => (
</Stage>
)
-const baseSettings: ChartSettings = { showValuesOnSeries: true, showPieTotal: true }
+const baseSettings: ChartSettings = { pie: { sliceContent: 'values', showTotal: true } }
export const Default: Story = {
render: () =>
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 c471773d7c9c..50c2384742d8 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.test.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.test.tsx
@@ -48,28 +48,76 @@ const baseProps = (chartSettings: ChartSettings, data: (number | null)[]): LineG
chartSettings,
})
-// On-slice value labels are static overlay nodes (not pointer-driven), so they steer clear of the
-// quill PieChart's flaky hover/click interaction tests.
-function sliceLabels(): string[] {
- return Array.from(document.querySelectorAll('[data-attr="hog-chart-pie-slice-label"]')).map((el) => el.textContent!)
+// On-slice labels are static overlay nodes (not pointer-driven), so they steer clear of the
+// quill PieChart's flaky hover/click interaction tests. Each slice renders one <div> per line
+// (label and/or value), so we read the lines per slice rather than the concatenated text.
+function sliceLabelLines(): string[][] {
+ return Array.from(document.querySelectorAll('[data-attr="hog-chart-pie-slice-label"]')).map((el) =>
+ Array.from(el.querySelectorAll('div')).map((line) => line.textContent!)
+ )
+}
+
+async function waitForSlices(): Promise<void> {
+ await screen.findByRole('img', { name: /pie chart with/i }, { timeout: 5000 })
+ await waitFor(
+ () => {
+ if (sliceLabelLines().length === 0) {
+ throw new Error('slice labels not rendered yet')
+ }
+ },
+ { timeout: 5000 }
+ )
}
describe('SqlPieGraph', () => {
- it('renders a value label per positive slice and the aggregation total', async () => {
- render(<SqlPieGraph {...baseProps({ showPieTotal: true }, [40, 30, 20, 10])} />)
+ it('defaults to values and the total when slice content is unset (existing chart)', async () => {
+ render(<SqlPieGraph {...baseProps({}, [40, 30, 20, 10])} />)
- await screen.findByRole('img', { name: /pie chart with/i }, { timeout: 5000 })
- await waitFor(
- () => {
- expect(sliceLabels().length).toBeGreaterThan(0)
- },
- { timeout: 5000 }
- )
+ await waitForSlices()
- expect([...sliceLabels()].sort()).toEqual(['10', '20', '30', '40'])
+ // Unset slice content means a pre-existing chart, which keeps the legacy value-on-slice + total
+ expect(sliceLabelLines()).toEqual([['40'], ['30'], ['20'], ['10']])
expect(screen.getByText('100')).toBeInTheDocument()
})
+ it('shows slice labels and hides the total when slice content is labels', async () => {
+ render(<SqlPieGraph {...baseProps({ pie: { sliceContent: 'labels' } }, [40, 30, 20, 10])} />)
+
+ await waitForSlices()
+
+ expect(sliceLabelLines()).toEqual([['alpha'], ['beta'], ['gamma'], ['delta']])
+ expect(screen.queryByText('100')).not.toBeInTheDocument()
+ })
+
+ it('respects an explicit showTotal override that hides the total in values mode', async () => {
+ render(<SqlPieGraph {...baseProps({ pie: { sliceContent: 'values', showTotal: false } }, [40, 30, 20, 10])} />)
+
+ await waitForSlices()
+
+ expect(sliceLabelLines()).toEqual([['40'], ['30'], ['20'], ['10']])
+ expect(screen.queryByText('100')).not.toBeInTheDocument()
+ })
+
+ it('shows slice values as shares of the total when displaying percentages', async () => {
+ render(
+ <SqlPieGraph
+ {...baseProps({ pie: { sliceContent: 'values', valueDisplay: 'percentage' } }, [40, 30, 20, 10])}
+ />
+ )
+
+ await waitForSlices()
+
+ expect(sliceLabelLines()).toEqual([['40%'], ['30%'], ['20%'], ['10%']])
+ })
+
+ it('renders nothing on slices when slice content is none', async () => {
+ render(<SqlPieGraph {...baseProps({ pie: { sliceContent: 'none' } }, [40, 30, 20, 10])} />)
+
+ await screen.findByRole('img', { name: /pie chart with/i }, { timeout: 5000 })
+
+ expect(sliceLabelLines()).toEqual([])
+ })
+
it('renders the side legend with per-slice values and shares', () => {
// The legend is plain DOM (rendered for both responsive layouts), so it needs no canvas paint.
render(<SqlPieGraph {...baseProps({ showLegend: true }, [60, 40, 0, 0])} />)
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.tsx
index 2d144735caf1..842a0dfe9bdf 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlPieGraph.tsx
@@ -41,16 +41,31 @@ export const SqlPieGraph = ({
const total = useMemo(() => slices.reduce((sum, slice) => sum + slice.value, 0), [slices])
const showLegend = chartSettings.showLegend ?? false
- const showPieTotal = chartSettings.showPieTotal ?? true
-
- const valueFormatter = useCallback(
+ // 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.
+ const showPieTotal = chartSettings.pie?.showTotal ?? sliceContent === 'values'
+ const asPercent = (chartSettings.pie?.valueDisplay ?? 'absolute') === 'percentage'
+
+ const absoluteFormatter = useCallback(
(value: number) => String(formatDataWithSettings(value, formattingSettings) ?? value),
[formattingSettings]
)
+ // `isPercent` makes the chart render on-slice values and tooltips as a share of the total; the
+ // total below the chart and the absolute legend line keep using the raw value formatter.
+ // Labels sit toward the rim (on the wider part of each wedge) and skip slices under 10% so a
+ // long tail of thin slices doesn't pile labels up at the center.
const pieConfig: PieChartConfig = useMemo(
- () => ({ showValueOnSlice: chartSettings.showValuesOnSeries ?? true }),
- [chartSettings.showValuesOnSeries]
+ () => ({
+ showLabelOnSlice: sliceContent === 'labels',
+ showValueOnSlice: sliceContent === 'values',
+ isPercent: asPercent,
+ labelRadiusRatio: 0.72,
+ minSlicePercentForLabel: 0.1,
+ }),
+ [sliceContent, asPercent]
)
const renderTooltip = useCallback(
@@ -65,13 +80,13 @@ export const SqlPieGraph = ({
<TooltipSwatch color={entry.color} />
<span className="font-semibold">{entry.series.label}</span>
<strong className="ml-auto">
- {formatPieSliceCount(entry.value, total, formattingSettings)}
+ {formatPieSliceCount(entry.value, total, formattingSettings, asPercent)}
</strong>
</div>
</TooltipSurface>
)
},
- [total, formattingSettings]
+ [total, formattingSettings, asPercent]
)
if (!slices.length) {
@@ -88,7 +103,7 @@ export const SqlPieGraph = ({
theme={theme}
config={pieConfig}
tooltip={renderTooltip}
- valueFormatter={valueFormatter}
+ valueFormatter={absoluteFormatter}
dataAttr="sql-pie-chart"
onError={handleChartError}
/>
@@ -96,7 +111,7 @@ export const SqlPieGraph = ({
const totalDisplay = showPieTotal ? (
<div className="pt-4 text-center shrink-0">
- <div className="text-5xl font-bold">{valueFormatter(total)}</div>
+ <div className="text-5xl font-bold">{absoluteFormatter(total)}</div>
</div>
) : null
@@ -113,8 +128,12 @@ export const SqlPieGraph = ({
<span className="truncate">{slice.label}</span>
</div>
<div className="text-right shrink-0">
- <div className="font-semibold">{valueFormatter(slice.value)}</div>
- <div className="text-xs text-secondary">{percent}%</div>
+ <div className="font-semibold">
+ {asPercent ? `${percent}%` : absoluteFormatter(slice.value)}
+ </div>
+ <div className="text-xs text-secondary">
+ {asPercent ? absoluteFormatter(slice.value) : `${percent}%`}
+ </div>
</div>
</div>
)
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 5213cccbaef0..60627dbddd57 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlPieGraphAdapter.test.ts
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlPieGraphAdapter.test.ts
@@ -17,19 +17,29 @@ const baseProps = (visualizationType: ChartDisplayType): LineGraphProps => ({
describe('sqlPieGraphAdapter', () => {
describe('formatPieSliceCount', () => {
it.each([
- ['appends share of total', 25, 100, undefined, '25 (25%)'],
- ['rounds share to one decimal place', 1, 3, undefined, '1 (33.3%)'],
- ['omits share when total is zero', 5, 0, undefined, '5'],
- ['omits share for percent-styled values', 25, 100, { formatting: { style: 'percent' as const } }, '25%'],
+ ['appends share of total', 25, 100, undefined, false, '25 (25%)'],
+ ['rounds share to one decimal place', 1, 3, undefined, false, '1 (33.3%)'],
+ ['omits share when total is zero', 5, 0, undefined, false, '5'],
+ [
+ 'omits share for percent-styled values',
+ 25,
+ 100,
+ { formatting: { style: 'percent' as const } },
+ false,
+ '25%',
+ ],
[
'formats value with settings before appending share',
1234.5,
2469,
{ formatting: { style: 'number' as const, decimalPlaces: 0 } },
+ false,
'1,235 (50%)',
],
- ])('%s', (_name, value, total, settings, expected) => {
- expect(formatPieSliceCount(value, total, settings)).toEqual(expected)
+ ['leads with share when displaying as percentage', 25, 100, undefined, true, '25% (25)'],
+ ['falls back to the value when total is zero in percentage mode', 5, 0, undefined, true, '5'],
+ ])('%s', (_name, value, total, settings, asPercent, expected) => {
+ expect(formatPieSliceCount(value, total, settings, asPercent)).toEqual(expected)
})
})
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlPieGraphAdapter.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlPieGraphAdapter.ts
index f97580990ee9..cf7425c60773 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlPieGraphAdapter.ts
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlPieGraphAdapter.ts
@@ -94,13 +94,22 @@ export const buildPieSeries = (slices: PieSlice[]): Series[] => {
}))
}
-export const formatPieSliceCount = (value: number, total: number, settings?: AxisSeriesSettings): string => {
+export const formatPieSliceCount = (
+ value: number,
+ total: number,
+ settings?: AxisSeriesSettings,
+ asPercent = false
+): string => {
const formatted = String(formatDataWithSettings(value, settings) ?? value)
+ const shareOfTotal = total ? parseFloat(((value / total) * 100).toFixed(1)) : 0
+ if (asPercent) {
+ // Lead with the share, keep the absolute value as a secondary detail
+ return total ? `${shareOfTotal}% (${formatted})` : formatted
+ }
// Percent-styled values are already a share, so a share-of-total suffix would be confusing
if (!total || settings?.formatting?.style === 'percent') {
return formatted
}
- const shareOfTotal = parseFloat(((value / total) * 100).toFixed(1))
return `${formatted} (${shareOfTotal}%)`
}
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/DisplayTab.tsx b/frontend/src/queries/nodes/DataVisualization/Components/DisplayTab.tsx
index 648ce3ac08fe..e54bfa8f7ad9 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/DisplayTab.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/DisplayTab.tsx
@@ -7,6 +7,7 @@ import {
LemonCollapse,
LemonInput,
LemonLabel,
+ LemonSegmentedButton,
LemonSelect,
LemonSwitch,
} from '@posthog/lemon-ui'
@@ -18,6 +19,17 @@ import { ChartDisplayType } from '~/types'
import { dataVisualizationLogic } from '../dataVisualizationLogic'
import { displayLogic } from '../displayLogic'
+const PIE_SLICE_CONTENT_OPTIONS: { value: 'labels' | 'values' | 'none'; label: string }[] = [
+ { value: 'labels', label: 'Labels' },
+ { value: 'values', label: 'Values' },
+ { value: 'none', label: 'Nothing' },
+]
+
+const PIE_VALUE_DISPLAY_OPTIONS: { value: 'absolute' | 'percentage'; label: string }[] = [
+ { value: 'absolute', label: 'Absolute' },
+ { value: 'percentage', label: 'Percentage' },
+]
+
export const DisplayTab = (): JSX.Element => {
const { effectiveVisualizationType } = useValues(dataVisualizationLogic)
const { goalLines, chartSettings } = useValues(displayLogic)
@@ -108,20 +120,39 @@ export const DisplayTab = (): JSX.Element => {
/>
{isPieChart ? (
<>
- <LemonSwitch
- className="flex-1 w-full"
- label="Show values on slices"
- checked={chartSettings.showValuesOnSeries ?? true}
- onChange={(value) => {
- updateChartSettings({ showValuesOnSeries: value })
- }}
- />
+ <div className="flex flex-col gap-1">
+ <LemonLabel>Show on slices</LemonLabel>
+ <LemonSegmentedButton
+ className="w-full"
+ value={chartSettings.pie?.sliceContent ?? 'values'}
+ onChange={(value) =>
+ updateChartSettings({ pie: { sliceContent: value } })
+ }
+ options={PIE_SLICE_CONTENT_OPTIONS}
+ fullWidth
+ />
+ </div>
+ <div className="flex flex-col gap-1">
+ <LemonLabel>Show values as</LemonLabel>
+ <LemonSegmentedButton
+ className="w-full"
+ value={chartSettings.pie?.valueDisplay ?? 'absolute'}
+ onChange={(value) =>
+ updateChartSettings({ pie: { valueDisplay: value } })
+ }
+ options={PIE_VALUE_DISPLAY_OPTIONS}
+ fullWidth
+ />
+ </div>
<LemonSwitch
className="flex-1 w-full"
label="Show total below chart"
- checked={chartSettings.showPieTotal ?? true}
+ checked={
+ chartSettings.pie?.showTotal ??
+ (chartSettings.pie?.sliceContent ?? 'values') === 'values'
+ }
onChange={(value) => {
- updateChartSettings({ showPieTotal: value })
+ updateChartSettings({ pie: { showTotal: value } })
}}
/>
</>
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/SeriesTab.tsx b/frontend/src/queries/nodes/DataVisualization/Components/SeriesTab.tsx
index 276d47bc9916..6cfdade11f0e 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/SeriesTab.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/SeriesTab.tsx
@@ -47,7 +47,8 @@ export const SeriesTab = (): JSX.Element => {
dataVisualizationProps,
effectiveVisualizationType,
} = useValues(dataVisualizationLogic)
- const { updateXSeries, addYSeries, setTransposeResults } = useActions(dataVisualizationLogic)
+ const { updateXSeries, addYSeries, updateSeriesIndex, deleteYSeries, setTransposeResults } =
+ useActions(dataVisualizationLogic)
const breakdownLogic = seriesBreakdownLogic({ key: dataVisualizationProps.key })
const { selectedSeriesBreakdownColumn, showSeriesBreakdown } = useValues(breakdownLogic)
const { addSeriesBreakdown } = useActions(breakdownLogic)
@@ -99,6 +100,66 @@ export const SeriesTab = (): JSX.Element => {
),
}))
+ if (effectiveVisualizationType === ChartDisplayType.ActionsPie) {
+ const valueColumn = selectedYAxis?.find((series) => series !== null)?.name ?? null
+ const valueOptions = numericalColumns.map(({ name, type }) => ({
+ value: name,
+ label: (
+ <div className="items-center flex-1">
+ {name}
+ <LemonTag className="ml-2" type="default">
+ {type.name}
+ </LemonTag>
+ </div>
+ ),
+ }))
+
+ // A pie encodes a single value column. Set it on the first series and drop any others
+ // the chart may have carried over from another chart type.
+ const setValueColumn = (columnName: string): void => {
+ if (!selectedYAxis || selectedYAxis.length === 0) {
+ addYSeries(columnName)
+ return
+ }
+ updateSeriesIndex(0, columnName)
+ for (let index = selectedYAxis.length - 1; index >= 1; index--) {
+ deleteYSeries(index)
+ }
+ }
+
+ return (
+ <div className="flex flex-col w-full p-3">
+ <LemonLabel className="mb-1">Label</LemonLabel>
+ <LemonSelect
+ className="w-full"
+ value={xData !== null ? xData.column.name : 'None'}
+ options={options}
+ disabledReason={responseLoading ? 'Query loading...' : undefined}
+ onChange={(value) => {
+ const column = columns.find((n) => n.name === value)
+ if (column) {
+ updateXSeries(column.name)
+ }
+ }}
+ />
+
+ <LemonLabel className="mt-4 mb-1">Value</LemonLabel>
+ <LemonSelect
+ className="w-full"
+ placeholder="Select a column"
+ value={valueColumn}
+ options={valueOptions}
+ disabledReason={responseLoading ? 'Query loading...' : undefined}
+ onChange={(value) => {
+ if (value) {
+ setValueColumn(value)
+ }
+ }}
+ />
+ </div>
+ )
+ }
+
return (
<div className="flex flex-col w-full p-3">
<LemonLabel className="mb-1">X-axis</LemonLabel>
diff --git a/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.test.ts b/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.test.ts
index 4a6648858f0b..b99171dfee02 100644
--- a/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.test.ts
+++ b/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.test.ts
@@ -358,6 +358,23 @@ describe('dataVisualizationLogic', () => {
},
})
})
+ it('stamps labels onto the slices when a pie chart is newly picked', async () => {
+ logic.actions.setVisualizationType(ChartDisplayType.ActionsPie)
+
+ await expectLogic(logic).toMatchValues({
+ chartSettings: expect.objectContaining({ pie: { sliceContent: 'labels' } }),
+ })
+ })
+
+ it('does not override existing pie slice content when re-picking pie', async () => {
+ logic.actions.updateChartSettings({ pie: { sliceContent: 'values' } })
+ logic.actions.setVisualizationType(ChartDisplayType.ActionsPie)
+
+ await expectLogic(logic).toMatchValues({
+ chartSettings: expect.objectContaining({ pie: { sliceContent: 'values' } }),
+ })
+ })
+
it('auto-fills 2d heatmap columns when selecting auto on heatmap data', async () => {
dataNodeLogic({ key: testKey, query: defaultQuery.source, dataNodeCollectionId }).actions.setResponse({
columns: ['region', 'segment', 'count'],
diff --git a/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.ts b/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.ts
index e6976b2f103a..5ceac450becd 100644
--- a/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.ts
+++ b/frontend/src/queries/nodes/DataVisualization/dataVisualizationLogic.ts
@@ -345,6 +345,13 @@ const mergeChartSettings = (state: ChartSettings, settings: ChartSettings): Char
...settings.heatmap,
}
: undefined,
+ pie:
+ state.pie || settings.pie
+ ? {
+ ...state.pie,
+ ...settings.pie,
+ }
+ : undefined,
leftYAxisSettings:
state.leftYAxisSettings || settings.leftYAxisSettings
? {
@@ -1251,6 +1258,15 @@ export const dataVisualizationLogic = kea<dataVisualizationLogicType>([
display: visualizationType,
}))
+ // Newly-picked pies default to labels on slices; existing pies (loaded with the type
+ // already set, so this listener never fires) keep the legacy value-on-slice default.
+ if (
+ visualizationType === ChartDisplayType.ActionsPie &&
+ values.chartSettings.pie?.sliceContent === undefined
+ ) {
+ actions.updateChartSettings({ pie: { sliceContent: 'labels' } })
+ }
+
if (
[ChartDisplayType.ActionsLineGraph, ChartDisplayType.ActionsAreaGraph].includes(visualizationType) &&
shouldUseFirstNumericColumnAsContinuousChartXAxis(
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index f16614ee98b0..6b884b02ec6c 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -11941,6 +11941,9 @@
"leftYAxisSettings": {
"$ref": "#/definitions/YAxisSettings"
},
+ "pie": {
+ "$ref": "#/definitions/PieChartSettings"
+ },
"resultCustomizations": {
"additionalProperties": {
"$ref": "#/definitions/ResultCustomizationByValue"
@@ -11960,9 +11963,6 @@
"showNullsAsZero": {
"type": "boolean"
},
- "showPieTotal": {
- "type": "boolean"
- },
"showTotalRow": {
"type": "boolean"
},
@@ -30635,6 +30635,26 @@
"required": ["description", "extra", "source_id", "source_product", "source_type", "weight"],
"type": "object"
},
+ "PieChartSettings": {
+ "additionalProperties": false,
+ "properties": {
+ "showTotal": {
+ "description": "Whether to show the aggregation total below the chart. Defaults to on.",
+ "type": "boolean"
+ },
+ "sliceContent": {
+ "description": "What to render on each slice. Defaults to labels.",
+ "enum": ["labels", "values", "none"],
+ "type": "string"
+ },
+ "valueDisplay": {
+ "description": "Whether slice values show as absolute amounts or shares of the total. Only applies when `sliceContent` is `values`.",
+ "enum": ["absolute", "percentage"],
+ "type": "string"
+ }
+ },
+ "type": "object"
+ },
"PinterestAdsDefaultSources": {
"enum": ["pinterest"],
"type": "string"
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index ced3ee2b22f4..0e460ea605f9 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -1183,6 +1183,16 @@ export interface HeatmapSettings {
sortOrder?: HeatmapSortOrder
}
+export interface PieChartSettings {
+ /** What to render on each slice. Defaults to labels. */
+ sliceContent?: 'labels' | 'values' | 'none'
+ /** Whether slice values show as absolute amounts or shares of the total. Only applies when
+ * `sliceContent` is `values`. */
+ valueDisplay?: 'absolute' | 'percentage'
+ /** Whether to show the aggregation total below the chart. Defaults to on. */
+ showTotal?: boolean
+}
+
export interface YAxisSettings {
label?: string
scale?: 'linear' | 'logarithmic'
@@ -1210,9 +1220,9 @@ export interface ChartSettings {
showLegend?: boolean
showValuesOnSeries?: boolean
showTotalRow?: boolean
- showPieTotal?: boolean
showNullsAsZero?: boolean
heatmap?: HeatmapSettings
+ pie?: PieChartSettings
/** Per-breakdown-value color customizations. Keyed by the raw breakdown column value. */
resultCustomizations?: Record<string, ResultCustomizationByValue>
}
diff --git a/packages/quill/packages/charts/AGENTS.md b/packages/quill/packages/charts/AGENTS.md
index 310e834a93ca..9ce05aa9bce3 100644
--- a/packages/quill/packages/charts/AGENTS.md
+++ b/packages/quill/packages/charts/AGENTS.md
@@ -4,19 +4,19 @@ Quick-reference for AI agents using `@posthog/quill-charts`. Canvas-rendered cha
## Choosing a chart
-| Chart | Use when |
-| -------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
-| LineChart | Categorical x-axis trends; area fills, fill-between (confidence ribbons) |
-| BarChart | Categorical comparisons — `barLayout: 'stacked' \| 'grouped' \| 'percent'`, `axisOrientation: 'horizontal'` for horizontal bars |
-| ComboChart | Mixed bar/line/area series on one band x-axis — set `Series.type`; vertical-only, `barLayout: 'stacked' \| 'grouped'` |
-| TimeSeriesLineChart | Time-indexed labels (ISO strings) with timezone/interval-aware x-axis |
-| TimeSeriesBarChart | Same x-axis handling, bar rendering; supports per-series `yAxisId` axes |
-| TimeSeriesComboChart | Mixed bar + line/area on a time x-axis — `ComboChart` plus the time-series chrome (date x-axis, goal lines, legend, value labels) |
-| PieChart | Part-of-whole, one value per series; `innerRadiusRatio` for donut + `centerLabel` |
-| BoxPlot | Distribution summaries — `{ min, p25, median, mean, p75, max }` per label |
-| Sparkline | Tiny inline trend from a flat `number[]` — no axes, no series structure |
-| MetricCard | Headline number + sparkline + change pill (dashboard stat tiles) |
-| SlopeChart | Change between two points (slopegraph) — one line per series, left "before" → right "after"; `data: [start, end]` |
+| Chart | Use when |
+| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| LineChart | Categorical x-axis trends; area fills, fill-between (confidence ribbons) |
+| BarChart | Categorical comparisons — `barLayout: 'stacked' \| 'grouped' \| 'percent'`, `axisOrientation: 'horizontal'` for horizontal bars |
+| ComboChart | Mixed bar/line/area series on one band x-axis — set `Series.type`; vertical-only, `barLayout: 'stacked' \| 'grouped'` |
+| TimeSeriesLineChart | Time-indexed labels (ISO strings) with timezone/interval-aware x-axis |
+| TimeSeriesBarChart | Same x-axis handling, bar rendering; supports per-series `yAxisId` axes |
+| TimeSeriesComboChart | Mixed bar + line/area on a time x-axis — `ComboChart` plus the time-series chrome (date x-axis, goal lines, legend, value labels) |
+| PieChart | Part-of-whole, one value per series; `innerRadiusRatio` for donut + `centerLabel`; on-slice labels via `showLabelOnSlice`/`showValueOnSlice`, positioned with `labelRadiusRatio` (0=center, 1=rim) and gated by `minSlicePercentForLabel` |
+| BoxPlot | Distribution summaries — `{ min, p25, median, mean, p75, max }` per label |
+| Sparkline | Tiny inline trend from a flat `number[]` — no axes, no series structure |
+| MetricCard | Headline number + sparkline + change pill (dashboard stat tiles) |
+| SlopeChart | Change between two points (slopegraph) — one line per series, left "before" → right "after"; `data: [start, end]` |
## Theme wiring
diff --git a/packages/quill/packages/charts/src/charts/PieChart/PieChart.stories.tsx b/packages/quill/packages/charts/src/charts/PieChart/PieChart.stories.tsx
index f8c19564e212..77e00699bbc0 100644
--- a/packages/quill/packages/charts/src/charts/PieChart/PieChart.stories.tsx
+++ b/packages/quill/packages/charts/src/charts/PieChart/PieChart.stories.tsx
@@ -94,6 +94,25 @@ export const WithBreakdownLabels: Story = {
},
}
+export const LabelsTowardRim: Story = {
+ render: () => {
+ const theme = useReactiveTheme()
+ // Push labels out onto the wider part of each wedge and skip slices under 10%, so a long
+ // tail of thin slices doesn't crowd labels at the center.
+ const config: PieChartConfig = {
+ showLabelOnSlice: true,
+ showValueOnSlice: false,
+ labelRadiusRatio: 0.72,
+ minSlicePercentForLabel: 0.1,
+ }
+ return (
+ <Stage>
+ <PieChart series={BROWSERS} theme={theme} config={config} />
+ </Stage>
+ )
+ },
+}
+
export const LongLabelTooltip: Story = {
render: () => {
const theme = useReactiveTheme()
diff --git a/packages/quill/packages/charts/src/charts/PieChart/PieChart.tsx b/packages/quill/packages/charts/src/charts/PieChart/PieChart.tsx
index 13dc637b41eb..65b5e6accdf9 100644
--- a/packages/quill/packages/charts/src/charts/PieChart/PieChart.tsx
+++ b/packages/quill/packages/charts/src/charts/PieChart/PieChart.tsx
@@ -32,6 +32,9 @@ export interface PieChartConfig<Meta = unknown> {
disableHoverOffset?: boolean
/** Hide on-slice labels for slices smaller than this fraction of the total. Default 0.05. */
minSlicePercentForLabel?: number
+ /** Where on-slice labels sit along the radius: 0 = center, 1 = outer edge. Default 0.5 (mid-slice).
+ * Higher values push labels toward the rim, onto the wider part of each wedge. */
+ labelRadiusRatio?: number
/** Radians gap between slices. Default 0. */
padAngle?: number
/** Slice ordering. `null` (default) preserves input order — needed for stable
@@ -69,6 +72,7 @@ export interface PieChartProps<Meta = unknown> {
const DEFAULT_HOVER_GROWTH = 8
const DEFAULT_HOVER_ANIMATION_MS = 150
const DEFAULT_MIN_SLICE_PERCENT = 0.05
+const DEFAULT_LABEL_RADIUS_RATIO = 0.5
// Hovered slice eases toward white by this fraction at full hover — a subtle highlight.
const HOVER_HIGHLIGHT_TARGET = '#ffffff'
const HOVER_HIGHLIGHT_AMOUNT = 0.15
@@ -134,6 +138,7 @@ function PieChartInner<Meta = unknown>({
hoverAnimationMs = DEFAULT_HOVER_ANIMATION_MS,
disableHoverOffset = false,
minSlicePercentForLabel = DEFAULT_MIN_SLICE_PERCENT,
+ labelRadiusRatio = DEFAULT_LABEL_RADIUS_RATIO,
padAngle = 0,
sort = null,
sliceValue,
@@ -240,6 +245,7 @@ function PieChartInner<Meta = unknown>({
showValueOnSlice={showValueOnSlice}
showLabelOnSlice={showLabelOnSlice}
minSlicePercentForLabel={minSlicePercentForLabel}
+ labelRadiusRatio={labelRadiusRatio}
isPercent={isPercent}
/>
<PieCenterLabel>{centerLabel}</PieCenterLabel>
diff --git a/packages/quill/packages/charts/src/charts/PieChart/SliceLabels.test.tsx b/packages/quill/packages/charts/src/charts/PieChart/SliceLabels.test.tsx
index 1734be6bcfe1..5b14bd75c575 100644
--- a/packages/quill/packages/charts/src/charts/PieChart/SliceLabels.test.tsx
+++ b/packages/quill/packages/charts/src/charts/PieChart/SliceLabels.test.tsx
@@ -46,6 +46,16 @@ describe('SliceLabels', () => {
expect(labels(container)).toHaveLength(1)
})
+ it('pushes labels further from the center as labelRadiusRatio increases', () => {
+ const layout = computePieLayout({ series: [s('a', 50), s('b', 50)], dimensions: PLOT })
+ const cx = layout.cx
+ const { container: near } = renderWithLayout(layout, <SliceLabels labelRadiusRatio={0.3} />)
+ const nearOffset = Math.abs(parseFloat(labels(near)[0].style.left) - cx)
+ const { container: far } = renderWithLayout(layout, <SliceLabels labelRadiusRatio={0.9} />)
+ const farOffset = Math.abs(parseFloat(labels(far)[0].style.left) - cx)
+ expect(farOffset).toBeGreaterThan(nearOffset)
+ })
+
it('respects visibility.valueLabel = false', () => {
const layout = computePieLayout({
series: [s('a', 25), s('b', 25, { visibility: { valueLabel: false } }), s('c', 25), s('d', 25)],
diff --git a/packages/quill/packages/charts/src/charts/PieChart/SliceLabels.tsx b/packages/quill/packages/charts/src/charts/PieChart/SliceLabels.tsx
index 537bb2a7cd7c..bf398ca4d6ea 100644
--- a/packages/quill/packages/charts/src/charts/PieChart/SliceLabels.tsx
+++ b/packages/quill/packages/charts/src/charts/PieChart/SliceLabels.tsx
@@ -16,6 +16,8 @@ export interface SliceLabelsProps {
showLabelOnSlice?: boolean
/** Hide labels for slices with `fraction < threshold`. Default 0.05. */
minSlicePercentForLabel?: number
+ /** Where labels sit along the radius: 0 = center, 1 = outer edge. Default 0.5 (mid-slice). */
+ labelRadiusRatio?: number
isPercent?: boolean
}
@@ -52,13 +54,15 @@ export function SliceLabels({
showValueOnSlice = true,
showLabelOnSlice = false,
minSlicePercentForLabel = 0.05,
+ labelRadiusRatio = 0.5,
isPercent = false,
}: SliceLabelsProps): React.ReactElement | null {
const { layout } = useRadialLayout()
if (!showValueOnSlice && !showLabelOnSlice) {
return null
}
- const midR = layout.innerRadius + (layout.outerRadius - layout.innerRadius) / 2
+ const ratio = Math.min(1, Math.max(0, labelRadiusRatio))
+ const midR = layout.innerRadius + (layout.outerRadius - layout.innerRadius) * ratio
const boxes: LabelBox[] = []
for (let i = 0; i < layout.slices.length; i++) {
diff --git a/posthog/schema.py b/posthog/schema.py
index 836e1ffb0712..2630a549dc96 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -238,6 +238,7 @@ from posthog.schema_enums import (
SlackIntegrationScope as SlackIntegrationScope,
SlackIntegrationScopeInReview as SlackIntegrationScopeInReview,
SlashCommandName as SlashCommandName,
+ SliceContent as SliceContent,
SnapchatAdsConversionFields as SnapchatAdsConversionFields,
SnapchatAdsConversionValueFields as SnapchatAdsConversionValueFields,
SnapchatAdsDefaultSources as SnapchatAdsDefaultSources,
@@ -281,6 +282,7 @@ from posthog.schema_enums import (
UsageMetricDisplay as UsageMetricDisplay,
UsageMetricFormat as UsageMetricFormat,
UserProductListReason as UserProductListReason,
+ ValueDisplay as ValueDisplay,
WebAnalyticsItemKind as WebAnalyticsItemKind,
WebAnalyticsOrderByDirection as WebAnalyticsOrderByDirection,
WebAnalyticsOrderByFields as WebAnalyticsOrderByFields,
@@ -2197,6 +2199,26 @@ class PgAnalyzeIssueSignalExtra(BaseModel):
synced_at: str
+class PieChartSettings(BaseModel):
+ model_config = ConfigDict(
+ extra="forbid",
+ )
+ showTotal: bool | None = Field(
+ default=None,
+ description=("Whether to show the aggregation total below the chart. Defaults to on."),
+ )
+ sliceContent: SliceContent | None = Field(
+ default=None, description="What to render on each slice. Defaults to labels."
+ )
+ valueDisplay: ValueDisplay | None = Field(
+ default=None,
+ description=(
+ "Whether slice values show as absolute amounts or shares of the total. Only"
+ " applies when `sliceContent` is `values`."
+ ),
+ )
+
+
class Mark(BaseModel):
attrs: dict[str, Any] | None = None
type: str
@@ -13015,6 +13037,7 @@ class ChartSettings(BaseModel):
goalLines: list[GoalLine] | None = None
heatmap: HeatmapSettings | None = None
leftYAxisSettings: YAxisSettings | None = None
+ pie: PieChartSettings | None = None
resultCustomizations: dict[str, ResultCustomizationByValue] | None = Field(
default=None,
description=("Per-breakdown-value color customizations. Keyed by the raw breakdown column value."),
@@ -13023,7 +13046,6 @@ class ChartSettings(BaseModel):
seriesBreakdownColumn: str | None = None
showLegend: bool | None = None
showNullsAsZero: bool | None = None
- showPieTotal: bool | None = None
showTotalRow: bool | None = None
showValuesOnSeries: bool | None = None
showXAxisBorder: bool | None = None
diff --git a/posthog/schema_enums.py b/posthog/schema_enums.py
index 99a793bd3694..deca0b212ab0 100644
--- a/posthog/schema_enums.py
+++ b/posthog/schema_enums.py
@@ -2578,6 +2578,17 @@ class PathType(StrEnum):
HOGQL = "hogql"
+class SliceContent(StrEnum):
+ LABELS = "labels"
+ VALUES = "values"
+ NONE = "none"
+
+
+class ValueDisplay(StrEnum):
+ ABSOLUTE = "absolute"
+ PERCENTAGE = "percentage"
+
+
class PinterestAdsDefaultSources(StrEnum):
PINTEREST = "pinterest"
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index 68e753c2b71f..ba609da9bc1c 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -7677,6 +7677,30 @@ export interface YAxisSettingsApi {
startAtZero?: boolean | null
}
+export type SliceContentApi = (typeof SliceContentApi)[keyof typeof SliceContentApi]
+
+export const SliceContentApi = {
+ Labels: 'labels',
+ Values: 'values',
+ None: 'none',
+} as const
+
+export type ValueDisplayApi = (typeof ValueDisplayApi)[keyof typeof ValueDisplayApi]
+
+export const ValueDisplayApi = {
+ Absolute: 'absolute',
+ Percentage: 'percentage',
+} as const
+
+export interface PieChartSettingsApi {
+ /** Whether to show the aggregation total below the chart. Defaults to on. */
+ showTotal?: boolean | null
+ /** What to render on each slice. Defaults to labels. */
+ sliceContent?: SliceContentApi | null
+ /** Whether slice values show as absolute amounts or shares of the total. Only applies when `sliceContent` is `values`. */
+ valueDisplay?: ValueDisplayApi | null
+}
+
export type DisplayTypeApi = (typeof DisplayTypeApi)[keyof typeof DisplayTypeApi]
export const DisplayTypeApi = {
@@ -7736,13 +7760,13 @@ export interface ChartSettingsApi {
goalLines?: GoalLineApi[] | null
heatmap?: HeatmapSettingsApi | null
leftYAxisSettings?: YAxisSettingsApi | null
+ pie?: PieChartSettingsApi | null
/** Per-breakdown-value color customizations. Keyed by the raw breakdown column value. */
resultCustomizations?: ChartSettingsApiResultCustomizations
rightYAxisSettings?: YAxisSettingsApi | null
seriesBreakdownColumn?: string | null
showLegend?: boolean | null
showNullsAsZero?: boolean | null
- showPieTotal?: boolean | null
showTotalRow?: boolean | null
showValuesOnSeries?: boolean | null
showXAxisBorder?: boolean | null
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index efe6d4b62237..cdfd10d5d703 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -7014,6 +7014,30 @@ export interface YAxisSettingsApi {
startAtZero?: boolean | null
}
+export type SliceContentApi = (typeof SliceContentApi)[keyof typeof SliceContentApi]
+
+export const SliceContentApi = {
+ Labels: 'labels',
+ Values: 'values',
+ None: 'none',
+} as const
+
+export type ValueDisplayApi = (typeof ValueDisplayApi)[keyof typeof ValueDisplayApi]
+
+export const ValueDisplayApi = {
+ Absolute: 'absolute',
+ Percentage: 'percentage',
+} as const
+
+export interface PieChartSettingsApi {
+ /** Whether to show the aggregation total below the chart. Defaults to on. */
+ showTotal?: boolean | null
+ /** What to render on each slice. Defaults to labels. */
+ sliceContent?: SliceContentApi | null
+ /** Whether slice values show as absolute amounts or shares of the total. Only applies when `sliceContent` is `values`. */
+ valueDisplay?: ValueDisplayApi | null
+}
+
export type DisplayTypeApi = (typeof DisplayTypeApi)[keyof typeof DisplayTypeApi]
export const DisplayTypeApi = {
@@ -7073,13 +7097,13 @@ export interface ChartSettingsApi {
goalLines?: GoalLineApi[] | null
heatmap?: HeatmapSettingsApi | null
leftYAxisSettings?: YAxisSettingsApi | null
+ pie?: PieChartSettingsApi | null
/** Per-breakdown-value color customizations. Keyed by the raw breakdown column value. */
resultCustomizations?: ChartSettingsApiResultCustomizations
rightYAxisSettings?: YAxisSettingsApi | null
seriesBreakdownColumn?: string | null
showLegend?: boolean | null
showNullsAsZero?: boolean | null
- showPieTotal?: boolean | null
showTotalRow?: boolean | null
showValuesOnSeries?: boolean | null
showXAxisBorder?: boolean | null
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 2db351201166..f51a372da2b4 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -7137,6 +7137,32 @@ export namespace Schemas {
startAtZero?: boolean | null;
}
+ export type SliceContent = typeof SliceContent[keyof typeof SliceContent];
+
+
+ export const SliceContent = {
+ Labels: 'labels',
+ Values: 'values',
+ None: 'none',
+ } as const;
+
+ export type ValueDisplay = typeof ValueDisplay[keyof typeof ValueDisplay];
+
+
+ export const ValueDisplay = {
+ Absolute: 'absolute',
+ Percentage: 'percentage',
+ } as const;
+
+ export interface PieChartSettings {
+ /** Whether to show the aggregation total below the chart. Defaults to on. */
+ showTotal?: boolean | null;
+ /** What to render on each slice. Defaults to labels. */
+ sliceContent?: SliceContent | null;
+ /** Whether slice values show as absolute amounts or shares of the total. Only applies when `sliceContent` is `values`. */
+ valueDisplay?: ValueDisplay | null;
+ }
+
export type DisplayType = typeof DisplayType[keyof typeof DisplayType];
@@ -7199,13 +7225,13 @@ export namespace Schemas {
goalLines?: GoalLine[] | null;
heatmap?: HeatmapSettings | null;
leftYAxisSettings?: YAxisSettings | null;
+ pie?: PieChartSettings | null;
/** Per-breakdown-value color customizations. Keyed by the raw breakdown column value. */
resultCustomizations?: ChartSettingsResultCustomizations;
rightYAxisSettings?: YAxisSettings | null;
seriesBreakdownColumn?: string | null;
showLegend?: boolean | null;
showNullsAsZero?: boolean | null;
- showPieTotal?: boolean | null;
showTotalRow?: boolean | null;
showValuesOnSeries?: boolean | null;
showXAxisBorder?: boolean | null;