From d5ea9373cc54de245a10cd3e393994e8de643218 Mon Sep 17 00:00:00 2001 From: Ovilia Date: Mon, 27 Feb 2023 14:55:57 +0800 Subject: [PATCH] fix(markArea): fix situations when dims is not defined --- src/chart/bar/BaseBarSeries.ts | 4 ++-- src/component/marker/markerHelper.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/chart/bar/BaseBarSeries.ts b/src/chart/bar/BaseBarSeries.ts index d9349ac2e..81d341520 100644 --- a/src/chart/bar/BaseBarSeries.ts +++ b/src/chart/bar/BaseBarSeries.ts @@ -99,13 +99,13 @@ class BaseBarSeriesModel = BaseBarSeri if (startingAtTick) { each(coordSys.getAxes(), function (axis: Axis2D, idx: number) { // If axis type is category, use tick coords instead - if (axis.type === 'category') { + if (axis.type === 'category' && dims != null) { const tickCoords = axis.getTicksCoords(); let targetTickId = clampData[idx]; // The index of rightmost tick of markArea is 1 larger than x1/y1 index const isEnd = dims[idx] === 'x1' || dims[idx] === 'y1'; - if (dims && isEnd) { + if (isEnd) { targetTickId += 1; } diff --git a/src/component/marker/markerHelper.ts b/src/component/marker/markerHelper.ts index 2777b137f..a0e648f66 100644 --- a/src/component/marker/markerHelper.ts +++ b/src/component/marker/markerHelper.ts @@ -105,14 +105,14 @@ export function dataTransform( const data = seriesModel.getData(); const coordSys = seriesModel.coordinateSystem; - const dims = coordSys.dimensions; + const dims = coordSys?.dimensions; // 1. If not specify the position with pixel directly // 2. If `coord` is not a data array. Which uses `xAxis`, // `yAxis` to specify the coord on each dimension // parseFloat first because item.x and item.y can be percent string like '20%' - if (!hasXAndY(item) && !isArray(item.coord) && coordSys) { + if (!hasXAndY(item) && !isArray(item.coord) && isArray(dims)) { const axisInfo = getAxisInfo(item, data, coordSys, seriesModel); // Clone the option @@ -144,7 +144,7 @@ export function dataTransform( } } // x y is provided - if (item.coord == null) { + if (item.coord == null || !isArray(dims)) { item.coord = []; } else { -- GitLab