From b11be1f7f9a833cd6a993fa93750b2a596521e02 Mon Sep 17 00:00:00 2001 From: xiaoiver Date: Sun, 26 May 2024 20:15:07 +0800 Subject: [PATCH] fix: hide axisZ when axis disabled (#6246) --- src/runtime/layout.ts | 6 +++--- src/runtime/transform.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/runtime/layout.ts b/src/runtime/layout.ts index 5ad7823d55..515238623d 100644 --- a/src/runtime/layout.ts +++ b/src/runtime/layout.ts @@ -29,11 +29,11 @@ import { } from './coordinate'; export function processAxisZ(components: G2GuideComponentOptions[]) { + const axisX = components.find(({ type }) => type === 'axisX'); + const axisY = components.find(({ type }) => type === 'axisY'); const axisZ = components.find(({ type }) => type === 'axisZ'); - if (axisZ) { - const axisX = components.find(({ type }) => type === 'axisX'); + if (axisX && axisY && axisZ) { axisX.plane = 'xy'; - const axisY = components.find(({ type }) => type === 'axisY'); axisY.plane = 'xy'; axisZ.plane = 'yz'; axisZ.origin = [axisX.bbox.x, axisX.bbox.y, 0]; diff --git a/src/runtime/transform.ts b/src/runtime/transform.ts index 981da8d9df..ad2e0b396e 100644 --- a/src/runtime/transform.ts +++ b/src/runtime/transform.ts @@ -260,8 +260,8 @@ export function addGuideToScale( }; const axisChannels = typeof axis === 'object' - ? Array.from(new Set(['x', 'y', ...Object.keys(axis)])) - : ['x', 'y']; + ? Array.from(new Set(['x', 'y', 'z', ...Object.keys(axis)])) + : ['x', 'y', 'z']; deepMix(mark, { scale: {