From bf10433751cb40ef0f91e095936527d140e84391 Mon Sep 17 00:00:00 2001 From: joaosa Date: Mon, 11 Nov 2024 15:29:34 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20axis=20alignment=20when=20?= =?UTF-8?q?scale=20domain=20is=200=20to=200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/core/lume-axis/lume-axis.vue | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/lib/src/components/core/lume-axis/lume-axis.vue b/packages/lib/src/components/core/lume-axis/lume-axis.vue index 6fcab0ef..f0c4e607 100644 --- a/packages/lib/src/components/core/lume-axis/lume-axis.vue +++ b/packages/lib/src/components/core/lume-axis/lume-axis.vue @@ -179,22 +179,18 @@ const { allOptions } = useOptions( const { showTick } = useSkip(scale, tickRefs, allOptions); +const alignAxisBaseline = computed( + () => isEmpty.value || !scale.value || isScaleEmpty(scale.value) +); + const axisTransform = computed(() => { // if empty, aligns baseline to the bottom - if ( - computedType.value === 'y' && - isEmpty.value && - (!scale.value || isScaleEmpty(scale.value)) - ) { + if (computedType.value === 'y' && alignAxisBaseline.value) { return `translate(0, ${containerSize.value?.height / 2})`; } // if empty, aligns baseline to the left - if ( - computedType.value === 'x' && - isEmpty.value && - (!scale.value || isScaleEmpty(scale.value)) - ) { + if (computedType.value === 'x' && alignAxisBaseline.value) { return `translate(-${containerSize.value?.width / 2}, ${ containerSize.value?.height })`;