: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
chore(insights): delete unused legacy chart.js pie and line graph (#76921)
Sam Pennington084b83707cc3
diff --git a/frontend/src/scenes/insights/views/LineGraph/LineGraph.test.tsx b/frontend/src/scenes/insights/views/LineGraph/LineGraph.test.tsxdeleted file mode 100644index 53131b7a1398..000000000000--- a/frontend/src/scenes/insights/views/LineGraph/LineGraph.test.tsx+++ /dev/null@@ -1,154 +0,0 @@-import { cleanup } from '@testing-library/react'--import { ChartEvent, InteractionItem } from 'lib/Chart'--import { GraphDataset, GraphPointPayload } from '~/types'--import { onChartClick } from './LineGraph'--describe('LineGraph', () => {- afterEach(cleanup)-- describe('onChartClick', () => {- // Stacked bar geometry (canvas coords, y=0 at top):- // Email (dataset 2): top=50, base=150, center=100- // Flutter (dataset 1): top=150, base=250, center=200- // Webapp DAU (dataset 0): top=250, base=350, center=300- const datasets: GraphDataset[] = [- { id: 0, label: 'Webapp DAU', data: [100], action: { order: 0 } } as GraphDataset,- { id: 1, label: 'Flutter', data: [100], action: { order: 1 } } as GraphDataset,- { id: 2, label: 'Email', data: [100], action: { order: 2 } } as GraphDataset,- ]-- const barElements = [- { y: 250, base: 350, x: 100 }, // Webapp DAU (bottom of stack)- { y: 150, base: 250, x: 100 }, // Flutter (middle)- { y: 50, base: 150, x: 100 }, // Email (top)- ]-- function makeIndexElements(): InteractionItem[] {- return barElements.map((el, i) => ({- element: el as any,- datasetIndex: i,- index: 0,- }))- }-- function makeMockChart(- pointHits: InteractionItem[] = [],- tooltipDataPoints?: { datasetIndex: number; dataIndex: number }[]- ): any {- return {- getElementsAtEventForMode: (_event: Event, mode: string) => {- if (mode === 'point') {- return pointHits- }- return makeIndexElements()- },- tooltip: tooltipDataPoints ? { dataPoints: tooltipDataPoints } : undefined,- }- }-- function makeEvent(y: number): ChartEvent {- return {- type: 'click',- native: new MouseEvent('click'),- x: 100,- y,- }- }-- function clickAndCapture(chart: any, event: ChartEvent): GraphPointPayload | undefined {- let captured: GraphPointPayload | undefined- onChartClick(event, chart, datasets, (payload) => {- captured = payload- })- return captured- }-- it.each([- ['below center (y=220)', 220],- ['above center (y=180)', 180],- ])('selects Flutter when clicking %s in a stacked bar chart', (_, y) => {- const chart = makeMockChart()- const payload = clickAndCapture(chart, makeEvent(y as number))-- expect(payload).toBeTruthy()- expect(payload!.points.referencePoint.dataset.label).toBe('Flutter')- expect(payload!.points.referencePoint.datasetIndex).toBe(1)- })-- it('selects the correct series when pointsIntersectingClick has a direct hit', () => {- const directHit: InteractionItem[] = [{ element: barElements[1] as any, datasetIndex: 1, index: 0 }]- const chart = makeMockChart(directHit)- const payload = clickAndCapture(chart, makeEvent(200))-- expect(payload).toBeTruthy()- expect(payload!.points.referencePoint.dataset.label).toBe('Flutter')- expect(payload!.points.clickedPointNotLine).toBe(true)- })-- it('uses tooltip reference point over click detection to match what user sees', () => {- // Tooltip says Flutter but click detection hits Email — tooltip should win- const directHit: InteractionItem[] = [{ element: barElements[2] as any, datasetIndex: 2, index: 0 }]- const tooltipDataPoints = [{ datasetIndex: 1, dataIndex: 0 }]- const chart = makeMockChart(directHit, tooltipDataPoints)- const payload = clickAndCapture(chart, makeEvent(200))-- expect(payload).toBeTruthy()- expect(payload!.points.referencePoint.dataset.label).toBe('Flutter')- expect(payload!.points.referencePoint.datasetIndex).toBe(1)- })-- it('falls back to click detection when no tooltip is active', () => {- const chart = makeMockChart([], undefined)- const payload = clickAndCapture(chart, makeEvent(200))-- expect(payload).toBeTruthy()- expect(payload!.points.referencePoint.dataset.label).toBe('Flutter')- })-- it('ignores stale tooltip pointing to a different column than the click', () => {- // Tooltip cached from hovering a different data index (index=5) — should be ignored- const tooltipDataPoints = [{ datasetIndex: 1, dataIndex: 5 }]- const chart = makeMockChart([], tooltipDataPoints)- const payload = clickAndCapture(chart, makeEvent(200))-- expect(payload).toBeTruthy()- // Falls back to click detection since tooltip column doesn't match- expect(payload!.points.referencePoint.dataset.label).toBe('Flutter')- })-- it('works correctly for line charts where elements have no base property', () => {- const lineDatasets: GraphDataset[] = [- { id: 0, label: 'Series A', data: [50], action: { order: 0 } } as GraphDataset,- { id: 1, label: 'Series B', data: [80], action: { order: 1 } } as GraphDataset,- ]- const lineElements = [- { y: 200, x: 100 }, // Series A- { y: 100, x: 100 }, // Series B (higher value = lower y)- ]- const chart = {- getElementsAtEventForMode: (_event: Event, mode: string) => {- if (mode === 'point') {- return []- }- return lineElements.map((el, i) => ({- element: el as any,- datasetIndex: i,- index: 0,- }))- },- }-- // Click at y=110, closer to Series B (y=100)- let captured: GraphPointPayload | undefined- onChartClick(makeEvent(110), chart as any, lineDatasets, (payload) => {- captured = payload- })-- expect(captured).toBeTruthy()- expect(captured!.points.referencePoint.dataset.label).toBe('Series B')- })- })-})diff --git a/frontend/src/scenes/insights/views/LineGraph/LineGraph.tsx b/frontend/src/scenes/insights/views/LineGraph/LineGraph.tsxdeleted file mode 100644index bbc4c70092f2..000000000000--- a/frontend/src/scenes/insights/views/LineGraph/LineGraph.tsx+++ /dev/null@@ -1,137 +0,0 @@-import { Chart, ChartEvent, ChartType, DeepPartial, InteractionItem, LegendOptions } from 'lib/Chart'-import { TooltipConfig } from 'scenes/insights/InsightTooltip/insightTooltipUtils'--import { GoalLine, TrendsFilter } from '~/queries/schema/schema-general'-import { GraphDataset, GraphPoint, GraphPointPayload, GraphType } from '~/types'--import { AnomalyPoint } from 'products/alerts/frontend/types'--export function onChartClick(- event: ChartEvent,- chart: Chart,- datasets: GraphDataset[],- onClick?: { (payload: GraphPointPayload): void | undefined }-): void {- const nativeEvent = event.native- if (!nativeEvent) {- return- }- // Get all points along line- const sortPoints = (a: InteractionItem, b: InteractionItem): number => {- const eventY = event.y ?? 0- // Compare distance to bar center, not top edge (stacked bars share edges)- const aEl = a.element as unknown as { y: number; base?: number }- const bEl = b.element as unknown as { y: number; base?: number }- const aY = aEl.base != null ? (aEl.y + aEl.base) / 2 : aEl.y- const bY = bEl.base != null ? (bEl.y + bEl.base) / 2 : bEl.y- return Math.abs(aY - eventY) - Math.abs(bY - eventY)- }- const pointsIntersectingLine = chart- .getElementsAtEventForMode(- nativeEvent,- 'index',- {- intersect: false,- },- true- )- .sort(sortPoints)- // Get all points intersecting clicked point- const pointsIntersectingClick = chart- .getElementsAtEventForMode(- nativeEvent,- 'point',- {- intersect: true,- },- true- )- .sort(sortPoints)-- if (!pointsIntersectingClick.length && !pointsIntersectingLine.length) {- return- }-- const clickedPointNotLine = pointsIntersectingClick.length !== 0-- // Use the tooltip's active data point so the modal matches what the user sees,- // but only when the tooltip refers to the same data column as the click- const tooltipDataPoint = chart.tooltip?.dataPoints?.[0]- const tooltipIsForThisColumn =- tooltipDataPoint != null &&- pointsIntersectingLine.some(- (p) => p.datasetIndex === tooltipDataPoint.datasetIndex && p.index === tooltipDataPoint.dataIndex- )- const referencePoint: GraphPoint = tooltipIsForThisColumn- ? {- datasetIndex: tooltipDataPoint.datasetIndex,- index: tooltipDataPoint.dataIndex,- element: tooltipDataPoint.element,- dataset: datasets[tooltipDataPoint.datasetIndex],- }- : clickedPointNotLine- ? { ...pointsIntersectingClick[0], dataset: datasets[pointsIntersectingClick[0].datasetIndex] }- : { ...pointsIntersectingLine[0], dataset: datasets[pointsIntersectingLine[0].datasetIndex] }-- const crossDataset = datasets- .filter((_dt) => !_dt.dotted)- .map((_dt) => ({- ..._dt,- personUrl: _dt.persons_urls?.[referencePoint.index].url,- pointValue: _dt.data[referencePoint.index],- }))-- onClick?.({- points: {- pointsIntersectingLine: pointsIntersectingLine.map((p) => ({- ...p,- dataset: datasets[p.datasetIndex],- })),- pointsIntersectingClick: pointsIntersectingClick.map((p) => ({- ...p,- dataset: datasets[p.datasetIndex],- })),- clickedPointNotLine,- referencePoint,- },- index: referencePoint.index,- crossDataset,- seriesId: datasets[referencePoint.datasetIndex].id,- })-}--export interface LineGraphProps {- datasets: GraphDataset[]- labels: string[]- type: GraphType- isInProgress?: boolean- onClick?: (payload: GraphPointPayload) => void- ['data-attr']: string- inSharedMode?: boolean- showPersonsModal?: boolean- tooltip?: TooltipConfig- inSurveyView?: boolean- isArea?: boolean- incompletenessOffsetFromEnd?: number // Number of data points at end of dataset to replace with a dotted line. Only used in line graphs.- labelGroupType: number | 'people' | 'none'- trendsFilter?: TrendsFilter | null- formula?: string | null- showValuesOnSeries?: boolean | null- showPercentStackView?: boolean | null- supportsPercentStackView?: boolean- showPercentView?: boolean | null- hideAnnotations?: boolean- hideXAxis?: boolean- hideYAxis?: boolean- inCardView?: boolean- legend?: DeepPartial<LegendOptions<ChartType>>- yAxisScaleType?: string | null- showMultipleYAxes?: boolean | null- goalLines?: GoalLine[]- isStacked?: boolean- showTrendLines?: boolean- anomalyPoints?: AnomalyPoint[]- ignoreActionsInSeriesLabels?: boolean- datalabelFormatter?: (value: number, datasetIndex: number) => string- onDateRangeZoom?: (dateFrom: string, dateTo: string) => void-}diff --git a/frontend/src/scenes/insights/views/LineGraph/PieChart.tsx b/frontend/src/scenes/insights/views/LineGraph/PieChart.tsxdeleted file mode 100644index e3cec77c379d..000000000000--- a/frontend/src/scenes/insights/views/LineGraph/PieChart.tsx+++ /dev/null@@ -1,304 +0,0 @@-import ChartDataLabels, { Context } from 'chartjs-plugin-datalabels'-import { useActions, useValues } from 'kea'--import {- ActiveElement,- Chart,- ChartDataset,- ChartEvent,- ChartOptions,- ChartType,- Plugin,- TooltipModel,-} from 'lib/Chart'-import { SeriesLetter } from 'lib/components/SeriesGlyph'-import { useChart } from 'lib/hooks/useChart'-import { isString } from 'lib/utils/guards'-import {- formatAggregationAxisValue,- formatAggregationAxisValueWithShareOfTotal,-} from 'scenes/insights/aggregationAxisFormat'-import { insightLogic } from 'scenes/insights/insightLogic'-import { InsightTooltip } from 'scenes/insights/InsightTooltip/InsightTooltip'-import { SeriesDatum } from 'scenes/insights/InsightTooltip/insightTooltipUtils'-import { useInsightTooltip } from 'scenes/insights/useInsightTooltip'-import { LineGraphProps, onChartClick } from 'scenes/insights/views/LineGraph/LineGraph'-import { createTooltipData } from 'scenes/insights/views/LineGraph/tooltip-data'-import { teamLogic } from 'scenes/teamLogic'-import { IndexedTrendResult } from 'scenes/trends/types'--import { groupsModel } from '~/models/groupsModel'-import { BreakdownFilter } from '~/queries/schema/schema-general'-import { GraphType } from '~/types'--function getPercentageForDataPoint(context: Context): number {- const total = context.dataset.data.reduce((a, b) => (a as number) + (b as number), 0) as number- return ((context.dataset.data[context.dataIndex] as number) / total) * 100-}--export interface PieChartProps extends LineGraphProps {- breakdownFilter?: BreakdownFilter | null | undefined- showLabelOnSeries?: boolean | null- disableHoverOffset?: boolean | null- valueFormatter?: ((value: number) => string) | null-}--export function PieChart({- datasets: _datasets,- labels,- type,- onClick,- ['data-attr']: dataAttr,- trendsFilter,- breakdownFilter,- formula,- showValuesOnSeries,- showLabelOnSeries,- supportsPercentStackView,- showPercentStackView,- tooltip: tooltipConfig,- showPersonsModal = true,- labelGroupType,- disableHoverOffset,- valueFormatter,-}: PieChartProps): JSX.Element {- const isPie = type === GraphType.Pie- const isPercentStackView = !!supportsPercentStackView && !!showPercentStackView-- if (!isPie) {- throw new Error('PieChart must be a pie chart')- }-- const datasets = _datasets-- const { aggregationLabel } = useValues(groupsModel)- const { highlightSeries } = useActions(insightLogic)- const { getTooltip, hideTooltip, positionTooltip } = useInsightTooltip()- const { baseCurrency } = useValues(teamLogic)-- const { canvasRef } = useChart<'pie'>({- getConfig: () => {- const processedDatasets = datasets.map((dataset) => dataset as ChartDataset<'pie'>)- const onlyOneValue = processedDatasets?.[0]?.data?.length === 1-- return {- type: 'pie',- plugins: [ChartDataLabels as Plugin<'pie'>],- data: {- labels,- datasets: processedDatasets,- },- options: {- responsive: true,- maintainAspectRatio: false,- hover: {- mode: 'point',- intersect: true,- },- layout: {- padding: {- top: 12,- left: 20,- right: 20,- bottom: 20,- },- },- borderWidth: 0,- borderRadius: 0,- hoverOffset: onlyOneValue || disableHoverOffset ? 0 : 16,- onHover(event: ChartEvent, _: ActiveElement[], chart: Chart) {- const nativeEvent = event.native- if (!nativeEvent) {- return- }- const target = nativeEvent.target as HTMLDivElement- const hitsSlice =- chart.getElementsAtEventForMode(nativeEvent, 'point', { intersect: true }, true).length > 0- target.style.cursor = onClick && hitsSlice ? 'pointer' : 'default'- },- onClick: (event: ChartEvent, _: ActiveElement[], chart: Chart) => {- const nativeEvent = event.native- if (!nativeEvent) {- return- }- const hitsSlice =- chart.getElementsAtEventForMode(nativeEvent, 'point', { intersect: true }, true).length > 0- if (hitsSlice) {- onChartClick(event, chart, datasets, onClick)- }- },- plugins: {- datalabels: {- color: 'white',- anchor: 'end',- backgroundColor: (context) => {- const { backgroundColor } = context.dataset- if (Array.isArray(backgroundColor)) {- return backgroundColor[context.dataIndex] || 'black'- }- return isString(backgroundColor) ? backgroundColor : 'black'- },- display: (context) => {- const percentage = getPercentageForDataPoint(context)- const showValueForSeries =- showValuesOnSeries !== false && context.dataset.data.length > 1- return (showValueForSeries || showLabelOnSeries) && percentage > 5 ? 'auto' : false- },- padding: (context) => {- const value = context.dataset.data[context.dataIndex] as number- const paddingY = value < 10 ? 2 : 4- const paddingX = value < 10 ? 5 : 4- return { top: paddingY, bottom: paddingY, left: paddingX, right: paddingX }- },- formatter: (value: number, context) => {- if (showLabelOnSeries) {- return (context.dataset as any).labels?.[context.dataIndex]- }- if (isPercentStackView) {- const percentage = getPercentageForDataPoint(context)- return `${percentage.toFixed(1)}%`- }-- if (valueFormatter) {- return valueFormatter(value)- }-- return formatAggregationAxisValue(trendsFilter, value, baseCurrency)- },- font: {- weight: 500,- },- borderRadius: 25,- borderWidth: 2,- borderColor: 'white',- },- legend: {- display: false,- },- crosshair: false,- tooltip: {- position: 'cursor',- enabled: false,- intersect: true,- external: function ({- chart,- tooltip,- }: {- chart: Chart- tooltip: TooltipModel<ChartType>- }) {- const [tooltipRoot, tooltipEl] = getTooltip()- if (tooltip.opacity === 0) {- if (trendsFilter?.showLegend) {- highlightSeries(null)- }- hideTooltip()- return- }-- tooltipEl.classList.remove('above', 'below', 'no-transform', 'opacity-0', 'invisible')- tooltipEl.classList.add(tooltip.yAlign || 'no-transform')- tooltipEl.style.opacity = '1'-- if (tooltip.body) {- const referenceDataPoint = tooltip.dataPoints[0]- const dataset = datasets[referenceDataPoint.datasetIndex]- const seriesData = createTooltipData(- tooltip.dataPoints,- (dp) => dp.datasetIndex >= 0 && dp.datasetIndex < _datasets.length- )-- highlightSeries(seriesData[0] as unknown as IndexedTrendResult)-- tooltipRoot.render(- <InsightTooltip- seriesData={seriesData}- breakdownFilter={breakdownFilter}- hideColorCol={!!tooltipConfig?.hideColorCol}- showHeader={false}- renderSeries={(value: React.ReactNode, datum: SeriesDatum) => {- const hasBreakdown =- datum.breakdown_value !== undefined && !!datum.breakdown_value- return (- <div className="datum-label-column">- {!formula && (- <SeriesLetter- className="mr-2"- hasBreakdown={hasBreakdown}- seriesIndex={datum?.action?.order ?? datum.id}- />- )}- <div className="flex flex-col">- {hasBreakdown && !formula && datum.breakdown_value}- {value}- </div>- </div>- )- }}- renderCount={- tooltipConfig?.renderCount ||- ((value: number): string => {- if (valueFormatter) {- return valueFormatter(value)- }-- const total = dataset.data.reduce(- (a: number, b: number) => a + b,- 0- )- return formatAggregationAxisValueWithShareOfTotal(- trendsFilter,- value,- total,- baseCurrency- )- })- }- hideInspectActorsSection={!onClick || !showPersonsModal}- groupTypeLabel={- labelGroupType === 'people'- ? 'people'- : labelGroupType === 'none'- ? ''- : aggregationLabel(labelGroupType).plural- }- {...tooltipConfig}- />- )- }-- const bounds = chart.canvas.getBoundingClientRect()- positionTooltip(tooltipEl, bounds, tooltip.caretX || 0, tooltip.caretY || 0)- },- },- },- } as ChartOptions<'pie'>,- }- },- deps: [- datasets,- labels,- onClick,- trendsFilter,- breakdownFilter,- formula,- showValuesOnSeries,- showLabelOnSeries,- isPercentStackView,- tooltipConfig,- showPersonsModal,- labelGroupType,- disableHoverOffset,- getTooltip,- hideTooltip,- highlightSeries,- aggregationLabel,- ],- })-- return (- <div className="absolute w-full h-full" data-attr={dataAttr}>- <canvas ref={canvasRef} />- </div>- )-}diff --git a/frontend/src/scenes/insights/views/LineGraph/tooltip-data.ts b/frontend/src/scenes/insights/views/LineGraph/tooltip-data.tsdeleted file mode 100644index b0abe2efc84e..000000000000--- a/frontend/src/scenes/insights/views/LineGraph/tooltip-data.ts+++ /dev/null@@ -1,57 +0,0 @@-import { TooltipItem } from 'lib/Chart'-import { SeriesDatum } from 'scenes/insights/InsightTooltip/insightTooltipUtils'--import { GraphDataset } from '~/types'--export function createTooltipData(- tooltipDataPoints: TooltipItem<any>[],- filterFn?: (s: SeriesDatum) => boolean-): SeriesDatum[] {- if (!tooltipDataPoints) {- return []- }- let data = tooltipDataPoints- .map((dp, idx) => {- const pointDataset = (dp?.dataset ?? {}) as GraphDataset- return {- id: idx,- dataIndex: dp.dataIndex,- datasetIndex: dp.datasetIndex,- seriesIndex: dp.dataIndex,- dotted: !!pointDataset?.dotted,- breakdown_value:- pointDataset?.breakdown_value ??- pointDataset?.breakdownLabels?.[dp.dataIndex] ??- pointDataset?.breakdownValues?.[dp.dataIndex] ??- undefined,- compare_label: pointDataset?.compare_label ?? pointDataset?.compareLabels?.[dp.dataIndex] ?? undefined,- action: pointDataset?.action ?? pointDataset?.actions?.[dp.dataIndex] ?? undefined,- label: pointDataset?.label ?? pointDataset.labels?.[dp.dataIndex] ?? undefined,- date_label: pointDataset?.labels?.[dp.dataIndex] ?? undefined,- order: pointDataset?.order ?? 0,- color: Array.isArray(pointDataset.borderColor)- ? pointDataset.borderColor?.[dp.dataIndex]- : pointDataset.borderColor,- count: pointDataset?.data?.[dp.dataIndex] || 0,- filter: pointDataset?.filter ?? {},- hideTooltip: (pointDataset as any).hideTooltip,- anomalyScore: (pointDataset as any).anomalyScores?.[dp.dataIndex],- }- })- .sort((a, b) => {- // Sort by descending order and fallback on alphabetic sort- return (- b.count - a.count ||- (a.label === undefined || b.label === undefined ? -1 : a.label.localeCompare(b.label))- )- })-- if (filterFn) {- data = data.filter(filterFn)- }-- return data.map((s, id) => ({- ...s,- id,- }))-}diff --git a/frontend/src/scenes/surveys/components/question-visualizations/SingleChoiceQuestionViz.tsx b/frontend/src/scenes/surveys/components/question-visualizations/SingleChoiceQuestionViz.tsxdeleted file mode 100644index c38a8527a91d..000000000000--- a/frontend/src/scenes/surveys/components/question-visualizations/SingleChoiceQuestionViz.tsx+++ /dev/null@@ -1,81 +0,0 @@-import clsx from 'clsx'-import { BindLogic } from 'kea'--import { insightLogic } from 'scenes/insights/insightLogic'-import { PieChart } from 'scenes/insights/views/LineGraph/PieChart'-import { CHART_INSIGHTS_COLORS } from 'scenes/surveys/components/question-visualizations/util'--import { ChoiceQuestionProcessedResponses, GraphType, InsightLogicProps, MultipleSurveyQuestion } from '~/types'--const insightProps: InsightLogicProps = {- dashboardItemId: `new-survey`,-}--interface Props {- question: MultipleSurveyQuestion- processedData: ChoiceQuestionProcessedResponses-}--export function SingleChoiceQuestionViz({- question,- processedData: { data, totalResponses },-}: Props): JSX.Element | null {- return (- <div className="h-80 overflow-y-auto border rounded pt-4 pb-2 flex">- <div className="relative h-full w-80">- <BindLogic logic={insightLogic} props={insightProps}>- <PieChart- labelGroupType={1}- data-attr="survey-rating"- type={GraphType.Pie}- hideAnnotations={true}- formula="-"- tooltip={{- showHeader: false,- hideColorCol: true,- }}- datasets={[- {- id: 1,- data: data.map((d: { value: number }) => d.value),- labels: data.map((d: { label: string }) => d.label),- backgroundColor: data.map(- (_: any, i: number) => CHART_INSIGHTS_COLORS[i % CHART_INSIGHTS_COLORS.length]- ),- },- ]}- labels={data.map((d: { label: string }) => d.label)}- />- </BindLogic>- </div>- <div- className={clsx(- 'grid h-full pl-4',- data.length < 5 ? 'py-20' : data.length < 7 ? 'py-15' : data.length < 10 ? 'py-10' : 'py-5',- Math.min(Math.ceil(data.length / 10), 3) === 1- ? 'grid-cols-1'- : Math.min(Math.ceil(data.length / 10), 3) === 2- ? 'grid-cols-2'- : 'grid-cols-3'- )}- >- {data.map((d: { value: number; label: string }, i: number) => {- const percentage = ((d.value / totalResponses) * 100).toFixed(1)-- return (- <div key={`single-choice-legend-${question.id}-${i}`} className="flex items-center mr-6">- <div- className="w-3 h-3 rounded-full mr-2"- // eslint-disable-next-line react/forbid-dom-props- style={{ backgroundColor: CHART_INSIGHTS_COLORS[i % CHART_INSIGHTS_COLORS.length] }}- />- <span className="font-semibold text-secondary max-w-48 truncate">{`${d.label}`}</span>- <span className="font-bold ml-1 truncate">{` ${percentage}% `}</span>- <span className="font-semibold text-secondary ml-1 truncate">{`(${d.value})`}</span>- </div>- )- })}- </div>- </div>- )-}diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex ea9a7b346dc5..c5b92c333137 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -5183,14 +5183,6 @@ export interface ProjectTreeBreadcrumb extends BreadcrumbBase {}export type Breadcrumb = LinkBreadcrumb | RenamableBreadcrumb | SymbolBreadcrumb | ProjectTreeBreadcrumb-export enum GraphType {- Bar = 'bar',- HorizontalBar = 'horizontalBar',- Line = 'line',- Histogram = 'histogram',- Pie = 'doughnut',-}-export type GraphDataset = ChartDataset<ChartType> &Partial<Pick<