From 239487433f7eeb7cad2d4f32901f4bba2ac44f43 Mon Sep 17 00:00:00 2001 From: Alexander Karan <47707063+AlexanderKaran@users.noreply.github.com> Date: Sat, 21 Nov 2026 18:39:51 +0800 Subject: [PATCH] Numbers now on right of bars --- .../src/components/ComparisonBarChart.astro | 6 +++++- .../docs/src/components/StackedBarChart.astro | 21 +++++-------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/packages/docs/src/components/ComparisonBarChart.astro b/packages/docs/src/components/ComparisonBarChart.astro index 5cc2a3a1c..7b08f8685 100644 --- a/packages/docs/src/components/ComparisonBarChart.astro +++ b/packages/docs/src/components/ComparisonBarChart.astro @@ -334,7 +334,11 @@ const chartPayload = JSON.stringify({ ], scales: { x: { - scale: () => scaleLinear().domain([0, max > 0 ? max * 1.15 : 1]), + scale: () => + scaleLinear().domain([ + 0, + max > 0 ? max * (variance ? 1.15 : 1) : 1, + ]), axis: variance ? { ticks: { diff --git a/packages/docs/src/components/StackedBarChart.astro b/packages/docs/src/components/StackedBarChart.astro index 42cea851f..17117e686 100644 --- a/packages/docs/src/components/StackedBarChart.astro +++ b/packages/docs/src/components/StackedBarChart.astro @@ -212,7 +212,7 @@ const { title, series, data, valueFormat = 'kb', ...attrs } = Astro.props sigFigs: 2, }) const definition = defineChart({ - margin: { left: 36, right: 0, top: 12, bottom: 0 }, + margin: { left: 36, top: 12, bottom: 0 }, focusRing: false, marks: [ ...segments @@ -236,26 +236,15 @@ const { title, series, data, valueFormat = 'kb', ...attrs } = Astro.props x: 'total', y: 'name', text: (d) => format(d.total), - anchor: (d) => (d.total / max > 0.85 ? 'end' : 'start'), - dx: (d) => (d.total / max > 0.85 ? -10 : 10), - fill: (d) => - d.total / max > 0.85 - ? segments.findLast( - (segment) => segment.name === d.name && segment.value > 0, - )?.color === '#f7df1e' - ? '#203329' - : '#fff' - : muted, + anchor: 'start', + dx: 10, + fill: muted, fontWeight: 600, }), ], scales: { x: { - scale: () => - scaleLinear().domain([ - 0, - Math.max(1, ...labels.map((d) => d.total)), - ]), + scale: () => scaleLinear().domain([0, max]), axis: false, }, y: {