From cc0f347fb1d96deda9b6f74c33942b841ddc38c9 Mon Sep 17 00:00:00 2001 From: Harry Whorlow Date: Fri, 20 Nov 2026 11:50:10 +0100 Subject: [PATCH] feat(graphs): add bar graph colors --- .../shared/InteractionBreakdownChart.astro | 7 ++- .../shared/InteractionChartCaption.astro | 27 ++++++++-- .../src/components/ComparisonBarChart.astro | 29 ++++++++-- .../docs/src/components/StackedBarChart.astro | 54 ++++++++++++------- packages/docs/src/lib/chart-styles.ts | 15 ++++++ 5 files changed, 106 insertions(+), 26 deletions(-) diff --git a/packages/docs/src/benchmarks/shared/InteractionBreakdownChart.astro b/packages/docs/src/benchmarks/shared/InteractionBreakdownChart.astro index 384836fb..7ef23f1f 100644 --- a/packages/docs/src/benchmarks/shared/InteractionBreakdownChart.astro +++ b/packages/docs/src/benchmarks/shared/InteractionBreakdownChart.astro @@ -3,6 +3,7 @@ import { prepareInteractionBreakdownTable } from '../../lib/prepare-table' import StatsTable from '../../components/StatsTable.astro' import ViewSwitcher from '../../components/ViewSwitcher.astro' import { INTERACTION_PHASES } from '../../lib/interaction-phases' +import { stackLegendSwatch } from '../../lib/chart-styles' import InteractionChartCaption from './InteractionChartCaption.astro' import StackedBarChart from '../../components/StackedBarChart.astro' @@ -37,7 +38,11 @@ const chart1Table = prepareInteractionBreakdownTable(chart1) defaultValue="chart" > - + stackLegendSwatch(index, count)} + outlined + /> diff --git a/packages/docs/src/benchmarks/shared/InteractionChartCaption.astro b/packages/docs/src/benchmarks/shared/InteractionChartCaption.astro index a3d891bb..cda99be7 100644 --- a/packages/docs/src/benchmarks/shared/InteractionChartCaption.astro +++ b/packages/docs/src/benchmarks/shared/InteractionChartCaption.astro @@ -1,11 +1,23 @@ --- import { INTERACTION_PHASES } from '../../lib/interaction-phases' +type InteractionPhase = (typeof INTERACTION_PHASES)[number] + interface Props { title?: string + swatchColor?: ( + phase: InteractionPhase, + index: number, + count: number, + ) => string + outlined?: boolean } -const { title } = Astro.props +const { + title, + swatchColor = (phase: InteractionPhase) => phase.color, + outlined = false, +} = Astro.props ---
@@ -25,10 +37,13 @@ const { title } = Astro.props