From f1c5b88c16744354ec5e4eef192fdf244e0a5a7a Mon Sep 17 00:00:00 2001 From: quao Date: Tue, 14 Oct 2025 20:36:11 +0800 Subject: [PATCH 01/10] =?UTF-8?q?fix=20=E6=95=B0=E5=80=BC=E8=BD=B4?= =?UTF-8?q?=E5=8F=96=E5=80=BC=E8=8C=83=E5=9B=B4=E5=85=BC=E9=A1=BEmarker?= =?UTF-8?q?=E6=A0=87=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coord/cartesian/Grid.ts | 56 ++++++++- test/axis-marker-extent.html | 228 +++++++++++++++++++++++++++++++++++ 2 files changed, 283 insertions(+), 1 deletion(-) create mode 100644 test/axis-marker-extent.html diff --git a/src/coord/cartesian/Grid.ts b/src/coord/cartesian/Grid.ts index 97ac081bf0..7fcc0c6ebd 100644 --- a/src/coord/cartesian/Grid.ts +++ b/src/coord/cartesian/Grid.ts @@ -44,7 +44,7 @@ import GlobalModel from '../../model/Global'; import ExtensionAPI from '../../core/ExtensionAPI'; import { Dictionary } from 'zrender/src/core/types'; import {CoordinateSystemMaster} from '../CoordinateSystem'; -import { NullUndefined, ScaleDataValue } from '../../util/types'; +import { NullUndefined, ScaleDataValue, SeriesOption } from '../../util/types'; import SeriesData from '../../data/SeriesData'; import OrdinalScale from '../../scale/Ordinal'; import { @@ -81,6 +81,8 @@ type AxesMap = { type ParsedOuterBoundsContain = 'all' | 'axisLabel'; +type MarkerTypes = 'markPoint' | 'markLine' | 'markArea'; + // margin is [top, right, bottom, left] const XY_TO_MARGIN_IDX = [ [3, 1], // xyIdx 0 => 'x' @@ -542,6 +544,16 @@ class Grid implements CoordinateSystemMaster { unionExtent(data, xAxis); unionExtent(data, yAxis); + + // 处理 markPoint、markLine、markArea + const markerTypes: MarkerTypes[] = ['markPoint', 'markLine', 'markArea']; + + markerTypes.forEach(markerType => { + const markerOpt = seriesModel.get(markerType as keyof SeriesOption); + if (markerOpt && markerOpt.data) { + unionMarkerExtent(markerOpt.data, xAxis, yAxis); + } + }); } }, this); @@ -550,6 +562,48 @@ class Grid implements CoordinateSystemMaster { axis.scale.unionExtentFromData(data, dim); }); } + + function UnionExtentForAxisByValue( + value: any, + axis: Axis2D, + axisType: string, + ): void { + if (value != null && typeof value !== 'string' && axisType !== 'category') { + const val = axis.scale.parse(value); + if (!isNaN(val)) { + axis.scale._innerUnionExtent([val, val]); + } + } + } + + function unionMarkerExtent( + markerData: any[], + xAxis: Axis2D, + yAxis: Axis2D, + ): void { + each(markerData, function (item) { + if (!item) { + return; + } + const items = isObject(item) && !item.coord && !item.xAxis && !item.yAxis + ? (Array.isArray(item) ? item : [item]) + : [item]; + + each(items, function (markerItem) { + if (!markerItem) { + return; + } + + UnionExtentForAxisByValue(markerItem.xAxis, xAxis, xAxis.type); + UnionExtentForAxisByValue(markerItem.yAxis, yAxis, yAxis.type); + + if (markerItem.coord && Array.isArray(markerItem.coord)) { + UnionExtentForAxisByValue(markerItem.coord[0], xAxis, xAxis.type); + UnionExtentForAxisByValue(markerItem.coord[1], yAxis, yAxis.type); + } + }); + }); + } } /** diff --git a/test/axis-marker-extent.html b/test/axis-marker-extent.html new file mode 100644 index 0000000000..2b833c604c --- /dev/null +++ b/test/axis-marker-extent.html @@ -0,0 +1,228 @@ + + + + + + + + + + + +
无标记(基础折线图)
+
+
+
+
+ +
仅有 markLine
+
+
+
+
+ +
仅有 markPoint
+
+
+
+
+ +
仅有 markArea
+
+
+
+
+ + + + From 36c1c59731834fa3f57f7a2a0084b67a4ff83878 Mon Sep 17 00:00:00 2001 From: quao Date: Wed, 15 Oct 2025 16:46:51 +0800 Subject: [PATCH 02/10] =?UTF-8?q?feat=20=E6=96=B0=E5=A2=9E=E8=BD=B4?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=A1=B9includeMarkerInExtent=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E8=AE=A1=E7=AE=97=E9=BB=98=E8=AE=A4=E8=BD=B4=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=E6=97=B6=E6=98=AF=E5=90=A6=E8=80=83=E8=99=91marker?= =?UTF-8?q?=E6=A0=87=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coord/axisCommonTypes.ts | 3 ++ src/coord/cartesian/Grid.ts | 8 +++-- test/axis-marker-extent.html | 70 ++++++++++++++++++++++++++++++++++-- 3 files changed, 76 insertions(+), 5 deletions(-) diff --git a/src/coord/axisCommonTypes.ts b/src/coord/axisCommonTypes.ts index 6d607d0166..3fa1d3c8fe 100644 --- a/src/coord/axisCommonTypes.ts +++ b/src/coord/axisCommonTypes.ts @@ -129,6 +129,9 @@ export interface AxisBaseOptionCommon extends ComponentOption, breakLabelLayout?: { moveOverlap?: 'auto' | boolean; } + + // Whether to include marker data (markPoint, markLine, markArea) in axis extent calculation + includeMarkerInExtent?: boolean; } export interface NumericAxisBaseOptionCommon extends AxisBaseOptionCommon { diff --git a/src/coord/cartesian/Grid.ts b/src/coord/cartesian/Grid.ts index 7fcc0c6ebd..43d6aa7071 100644 --- a/src/coord/cartesian/Grid.ts +++ b/src/coord/cartesian/Grid.ts @@ -53,7 +53,7 @@ import { updateCartesianAxisViewCommonPartBuilder, isCartesian2DInjectedAsDataCoordSys } from './cartesianAxisHelper'; -import { CategoryAxisBaseOption, NumericAxisBaseOptionCommon } from '../axisCommonTypes'; +import { CategoryAxisBaseOption, NumericAxisBaseOptionCommon, OptionAxisType } from '../axisCommonTypes'; import { AxisBaseModel } from '../AxisBaseModel'; import { isIntervalOrLogScale } from '../../scale/helper'; import { alignScaleTicks } from '../axisAlignTicks'; @@ -566,9 +566,11 @@ class Grid implements CoordinateSystemMaster { function UnionExtentForAxisByValue( value: any, axis: Axis2D, - axisType: string, + axisType: OptionAxisType, ): void { - if (value != null && typeof value !== 'string' && axisType !== 'category') { + // 检查该轴是否配置为包含 marker 数据 + const includeMarkerInExtent = axis.model.get('includeMarkerInExtent') ?? true; + if (includeMarkerInExtent && value != null && typeof value !== 'string' && axisType !== 'category') { const val = axis.scale.parse(value); if (!isNaN(val)) { axis.scale._innerUnionExtent([val, val]); diff --git a/test/axis-marker-extent.html b/test/axis-marker-extent.html index 2b833c604c..813427e688 100644 --- a/test/axis-marker-extent.html +++ b/test/axis-marker-extent.html @@ -47,7 +47,7 @@ -
无标记(基础折线图)
+
仅有 markLine(includeMarkerInExtent: false)
@@ -59,6 +59,12 @@
+
仅有 markLine(includeMarkerInExtent: true)
+
+
+
+
+
仅有 markPoint
@@ -107,9 +113,22 @@ var chartNone = echarts.init(document.getElementById('main-none')); chartNone.setOption({ ...optionBase, + yAxis: { + ...optionBase.yAxis, + includeMarkerInExtent: false + }, series: [{ data: [150, 230, 224, 218, 135, 147, 260], - type: 'line' + type: 'line', + markLine: { + data: [ + { + name: '两个屏幕坐标之间的标线', + yAxis: 467, + lineStyle: { color: 'red' } + } + ] + } }] }); @@ -159,6 +178,53 @@ }] }); + // 2.1 仅有 markLine(includeMarkerInExtent: true)用例 + var chartMarklineIncludeMarker = echarts.init(document.getElementById('main-markline-include-marker')); + chartMarklineIncludeMarker.setOption({ + ...optionBase, + yAxis: { + ...optionBase.yAxis, + includeMarkerInExtent: true + }, + series: [{ + data: [150, 230, 224, 218, 135, 147, 260], + type: 'line', + markLine: { + data: [ + { + name: '两个屏幕坐标之间的标线', + yAxis: 467, + lineStyle: { color: 'red' } + } + ] + } + }] + }); + + var chartMarklineIncludeMarkerMinMax = echarts.init(document.getElementById('main-markline-include-marker-minmax')); + chartMarklineIncludeMarkerMinMax.setOption({ + ...getOptionWithYAxisMinMax(optionBase), + yAxis: { + ...optionBase.yAxis, + min: -100, + max: 400, + includeMarkerInExtent: true + }, + series: [{ + data: [150, 230, 224, 218, 135, 147, 260], + type: 'line', + markLine: { + data: [ + { + name: '两个屏幕坐标之间的标线', + yAxis: 467, + lineStyle: { color: 'red' } + } + ] + } + }] + }); + // 3. 仅 markPoint var chartMarkpoint = echarts.init(document.getElementById('main-markpoint')); chartMarkpoint.setOption({ From 03276b8274bbc72840c9f33c2d4a21c621ac0172 Mon Sep 17 00:00:00 2001 From: quao Date: Wed, 15 Oct 2025 17:20:04 +0800 Subject: [PATCH 03/10] =?UTF-8?q?enha=20=E4=BC=98=E5=8C=96=E4=B8=89?= =?UTF-8?q?=E5=85=83=E8=A1=A8=E8=BE=BE=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coord/cartesian/Grid.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/coord/cartesian/Grid.ts b/src/coord/cartesian/Grid.ts index 43d6aa7071..55f361ed5f 100644 --- a/src/coord/cartesian/Grid.ts +++ b/src/coord/cartesian/Grid.ts @@ -587,9 +587,8 @@ class Grid implements CoordinateSystemMaster { if (!item) { return; } - const items = isObject(item) && !item.coord && !item.xAxis && !item.yAxis - ? (Array.isArray(item) ? item : [item]) - : [item]; + const items = isObject(item) && !item.coord && !item.xAxis && !item.yAxis && Array.isArray(item) + ? item : [item]; each(items, function (markerItem) { if (!markerItem) { From d1695919eaf9fc07f78439afaa21d480dd100c40 Mon Sep 17 00:00:00 2001 From: quao Date: Wed, 15 Oct 2025 18:20:44 +0800 Subject: [PATCH 04/10] =?UTF-8?q?fix=20=E9=85=8D=E7=BD=AE=E9=A1=B9?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E7=A7=BB=E5=85=A5=E7=AC=9B=E5=8D=A1=E5=B0=94?= =?UTF-8?q?=E8=BD=B4=E7=9A=84=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coord/axisCommonTypes.ts | 3 --- src/coord/cartesian/AxisModel.ts | 2 ++ src/coord/cartesian/Grid.ts | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/coord/axisCommonTypes.ts b/src/coord/axisCommonTypes.ts index 3fa1d3c8fe..6d607d0166 100644 --- a/src/coord/axisCommonTypes.ts +++ b/src/coord/axisCommonTypes.ts @@ -129,9 +129,6 @@ export interface AxisBaseOptionCommon extends ComponentOption, breakLabelLayout?: { moveOverlap?: 'auto' | boolean; } - - // Whether to include marker data (markPoint, markLine, markArea) in axis extent calculation - includeMarkerInExtent?: boolean; } export interface NumericAxisBaseOptionCommon extends AxisBaseOptionCommon { diff --git a/src/coord/cartesian/AxisModel.ts b/src/coord/cartesian/AxisModel.ts index 1b0d35a137..f502d9013e 100644 --- a/src/coord/cartesian/AxisModel.ts +++ b/src/coord/cartesian/AxisModel.ts @@ -37,6 +37,8 @@ export type CartesianAxisOption = AxisBaseOption & { // Offset is for multiple axis on the same position. offset?: number; categorySortInfo?: OrdinalSortInfo; + // Whether to include marker data (markPoint, markLine, markArea) in axis extent calculation + includeMarkerInExtent?: boolean; }; export type XAXisOption = CartesianAxisOption & { diff --git a/src/coord/cartesian/Grid.ts b/src/coord/cartesian/Grid.ts index 55f361ed5f..14d5e7a654 100644 --- a/src/coord/cartesian/Grid.ts +++ b/src/coord/cartesian/Grid.ts @@ -568,7 +568,6 @@ class Grid implements CoordinateSystemMaster { axis: Axis2D, axisType: OptionAxisType, ): void { - // 检查该轴是否配置为包含 marker 数据 const includeMarkerInExtent = axis.model.get('includeMarkerInExtent') ?? true; if (includeMarkerInExtent && value != null && typeof value !== 'string' && axisType !== 'category') { const val = axis.scale.parse(value); From 18ff220e0b94dca06de812d83ca3085f19d5a133 Mon Sep 17 00:00:00 2001 From: quao Date: Wed, 15 Oct 2025 18:41:21 +0800 Subject: [PATCH 05/10] =?UTF-8?q?fix=20=E9=80=9A=E8=BF=87=E6=9E=84?= =?UTF-8?q?=E9=80=A0=E4=BC=A0=E5=8F=82=E6=94=B9=E7=94=A8unionExtentFromDat?= =?UTF-8?q?a=E9=81=BF=E5=85=8D=E4=BD=BF=E7=94=A8=E7=A7=81=E6=9C=89?= =?UTF-8?q?=E6=96=B9=E6=B3=95=5FinnerUnionExtent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coord/cartesian/Grid.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/coord/cartesian/Grid.ts b/src/coord/cartesian/Grid.ts index 14d5e7a654..3724539680 100644 --- a/src/coord/cartesian/Grid.ts +++ b/src/coord/cartesian/Grid.ts @@ -572,7 +572,10 @@ class Grid implements CoordinateSystemMaster { if (includeMarkerInExtent && value != null && typeof value !== 'string' && axisType !== 'category') { const val = axis.scale.parse(value); if (!isNaN(val)) { - axis.scale._innerUnionExtent([val, val]); + // Construct the parameter and use unionExtentFromData to avoid using the private method _innerUnionExtent + axis.scale.unionExtentFromData({ + getApproximateExtent: () => [val, val] + } as any, 0); } } } From dcfd98d2c1b58eb442ff5764fe6638c06355285f Mon Sep 17 00:00:00 2001 From: quao Date: Thu, 16 Oct 2025 15:22:02 +0800 Subject: [PATCH 06/10] =?UTF-8?q?enha=20=E4=BC=98=E5=8C=96=E4=B8=89?= =?UTF-8?q?=E5=85=83=E8=A1=A8=E8=BE=BE=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coord/cartesian/Grid.ts | 3 +-- test/axis-marker-extent.html | 42 ++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/coord/cartesian/Grid.ts b/src/coord/cartesian/Grid.ts index 3724539680..d80b871e3c 100644 --- a/src/coord/cartesian/Grid.ts +++ b/src/coord/cartesian/Grid.ts @@ -589,8 +589,7 @@ class Grid implements CoordinateSystemMaster { if (!item) { return; } - const items = isObject(item) && !item.coord && !item.xAxis && !item.yAxis && Array.isArray(item) - ? item : [item]; + const items = Array.isArray(item) ? item : [item]; each(items, function (markerItem) { if (!markerItem) { diff --git a/test/axis-marker-extent.html b/test/axis-marker-extent.html index 813427e688..4d26d05a40 100644 --- a/test/axis-marker-extent.html +++ b/test/axis-marker-extent.html @@ -59,6 +59,12 @@
+
markLine为负值用例
+
+
+
+
+
仅有 markLine(includeMarkerInExtent: true)
@@ -178,6 +184,42 @@ }] }); + var chartMarklineNegative = echarts.init(document.getElementById('main-markline-negative')); + chartMarklineNegative.setOption({ + ...optionBase, + series: [{ + data: [150, 230, 224, 218, 135, 147, 260], + type: 'line', + markLine: { + data: [ + { + name: '负值标线', + yAxis: -80, + lineStyle: { color: 'green' } + } + ] + } + }] + }); + + var chartMarklineNegativeMinMax = echarts.init(document.getElementById('main-markline-negative-minmax')); + chartMarklineNegativeMinMax.setOption({ + ...getOptionWithYAxisMinMax(optionBase), + series: [{ + data: [150, 230, 224, 218, 135, 147, 260], + type: 'line', + markLine: { + data: [ + { + name: '负值标线', + yAxis: -80, + lineStyle: { color: 'green' } + } + ] + } + }] + }); + // 2.1 仅有 markLine(includeMarkerInExtent: true)用例 var chartMarklineIncludeMarker = echarts.init(document.getElementById('main-markline-include-marker')); chartMarklineIncludeMarker.setOption({ From 621d8af0990eb61fcfe72dd826ac60cf765d5627 Mon Sep 17 00:00:00 2001 From: quao Date: Mon, 17 Nov 2025 18:31:08 +0800 Subject: [PATCH 07/10] fix cr --- src/component/marker/checkMarkerInSeries.ts | 2 +- src/coord/cartesian/Grid.ts | 20 +++--- src/scale/Scale.ts | 12 ++++ test/axis-marker-extent.html | 68 +++++++++++++++++++++ 4 files changed, 89 insertions(+), 13 deletions(-) diff --git a/src/component/marker/checkMarkerInSeries.ts b/src/component/marker/checkMarkerInSeries.ts index 5f87a4c358..12ad5b9476 100644 --- a/src/component/marker/checkMarkerInSeries.ts +++ b/src/component/marker/checkMarkerInSeries.ts @@ -20,7 +20,7 @@ import { isArray } from 'zrender/src/core/util'; import { SeriesOption } from '../../util/types'; -type MarkerTypes = 'markPoint' | 'markLine' | 'markArea'; +export type MarkerTypes = 'markPoint' | 'markLine' | 'markArea'; type SeriesWithMarkerOption = SeriesOption & Partial>; diff --git a/src/coord/cartesian/Grid.ts b/src/coord/cartesian/Grid.ts index d80b871e3c..e82172b992 100644 --- a/src/coord/cartesian/Grid.ts +++ b/src/coord/cartesian/Grid.ts @@ -70,6 +70,7 @@ import { error, log } from '../../util/log'; import { AxisTickLabelComputingKind } from '../axisTickLabelBuilder'; import { injectCoordSysByOption } from '../../core/CoordinateSystem'; import { mathMax, parsePositionSizeOption } from '../../util/number'; +import { MarkerTypes } from '../../component/marker/checkMarkerInSeries'; type Cartesian2DDimensionName = 'x' | 'y'; @@ -81,8 +82,6 @@ type AxesMap = { type ParsedOuterBoundsContain = 'all' | 'axisLabel'; -type MarkerTypes = 'markPoint' | 'markLine' | 'markArea'; - // margin is [top, right, bottom, left] const XY_TO_MARGIN_IDX = [ [3, 1], // xyIdx 0 => 'x' @@ -545,7 +544,7 @@ class Grid implements CoordinateSystemMaster { unionExtent(data, xAxis); unionExtent(data, yAxis); - // 处理 markPoint、markLine、markArea + // Handle markPoint, markLine, markArea const markerTypes: MarkerTypes[] = ['markPoint', 'markLine', 'markArea']; markerTypes.forEach(markerType => { @@ -563,7 +562,7 @@ class Grid implements CoordinateSystemMaster { }); } - function UnionExtentForAxisByValue( + function unionExtentForAxisByValue( value: any, axis: Axis2D, axisType: OptionAxisType, @@ -572,10 +571,7 @@ class Grid implements CoordinateSystemMaster { if (includeMarkerInExtent && value != null && typeof value !== 'string' && axisType !== 'category') { const val = axis.scale.parse(value); if (!isNaN(val)) { - // Construct the parameter and use unionExtentFromData to avoid using the private method _innerUnionExtent - axis.scale.unionExtentFromData({ - getApproximateExtent: () => [val, val] - } as any, 0); + axis.scale.unionExtentByValue(val); } } } @@ -596,12 +592,12 @@ class Grid implements CoordinateSystemMaster { return; } - UnionExtentForAxisByValue(markerItem.xAxis, xAxis, xAxis.type); - UnionExtentForAxisByValue(markerItem.yAxis, yAxis, yAxis.type); + unionExtentForAxisByValue(markerItem.xAxis, xAxis, xAxis.type); + unionExtentForAxisByValue(markerItem.yAxis, yAxis, yAxis.type); if (markerItem.coord && Array.isArray(markerItem.coord)) { - UnionExtentForAxisByValue(markerItem.coord[0], xAxis, xAxis.type); - UnionExtentForAxisByValue(markerItem.coord[1], yAxis, yAxis.type); + unionExtentForAxisByValue(markerItem.coord[0], xAxis, xAxis.type); + unionExtentForAxisByValue(markerItem.coord[1], yAxis, yAxis.type); } }); }); diff --git a/src/scale/Scale.ts b/src/scale/Scale.ts index 1f1fbdecf2..f613b217e6 100644 --- a/src/scale/Scale.ts +++ b/src/scale/Scale.ts @@ -133,6 +133,18 @@ abstract class Scale this._innerUnionExtent(data.getApproximateExtent(dim)); } + /** + * Update extent by value + */ + unionExtentByValue(value: number): void { + const extent = this._extent; + // Considered that number could be NaN and should not write into the extent. + this._innerSetExtent( + value < extent[0] ? value : extent[0], + value > extent[1] ? value : extent[1] + ); + } + /** * Get a new slice of extent. * Extent is always in increase order. diff --git a/test/axis-marker-extent.html b/test/axis-marker-extent.html index 4d26d05a40..57f5c33926 100644 --- a/test/axis-marker-extent.html +++ b/test/axis-marker-extent.html @@ -83,6 +83,13 @@
+ +
Bar Chart(水平)基于 markLine 用例
+
+
+
+
+ From c6eea0e3eda9be3f822ce203f3924f0489b45882 Mon Sep 17 00:00:00 2001 From: quao Date: Tue, 18 Nov 2025 10:06:10 +0800 Subject: [PATCH 08/10] =?UTF-8?q?fix=20=E6=9B=B4=E6=94=B9=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=8F=96=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coord/cartesian/Grid.ts | 2 +- test/axis-marker-extent.html | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/coord/cartesian/Grid.ts b/src/coord/cartesian/Grid.ts index e82172b992..4a3f5846d9 100644 --- a/src/coord/cartesian/Grid.ts +++ b/src/coord/cartesian/Grid.ts @@ -567,7 +567,7 @@ class Grid implements CoordinateSystemMaster { axis: Axis2D, axisType: OptionAxisType, ): void { - const includeMarkerInExtent = axis.model.get('includeMarkerInExtent') ?? true; + const includeMarkerInExtent = axis.model.get('includeMarkerInExtent') ?? false; if (includeMarkerInExtent && value != null && typeof value !== 'string' && axisType !== 'category') { const val = axis.scale.parse(value); if (!isNaN(val)) { diff --git a/test/axis-marker-extent.html b/test/axis-marker-extent.html index 57f5c33926..c6ee4e0854 100644 --- a/test/axis-marker-extent.html +++ b/test/axis-marker-extent.html @@ -65,7 +65,7 @@
-
仅有 markLine(includeMarkerInExtent: true)
+
仅有 markLine(includeMarkerInExtent未设置)
@@ -105,7 +105,8 @@ data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { - type: 'value' + type: 'value', + includeMarkerInExtent: true, } }; @@ -227,13 +228,13 @@ }] }); - // 2.1 仅有 markLine(includeMarkerInExtent: true)用例 + // 2.1 仅有 markLine(includeMarkerInExtent未设置)用例 var chartMarklineIncludeMarker = echarts.init(document.getElementById('main-markline-include-marker')); chartMarklineIncludeMarker.setOption({ ...optionBase, yAxis: { ...optionBase.yAxis, - includeMarkerInExtent: true + includeMarkerInExtent: undefined }, series: [{ data: [150, 230, 224, 218, 135, 147, 260], @@ -257,7 +258,7 @@ ...optionBase.yAxis, min: -100, max: 400, - includeMarkerInExtent: true + includeMarkerInExtent: undefined }, series: [{ data: [150, 230, 224, 218, 135, 147, 260], @@ -344,7 +345,8 @@ var barHorizOption = { ...optionBase, xAxis: { - type: 'value' // 水平条形图 x 轴为 value + type: 'value', // 水平条形图 x 轴为 value + includeMarkerInExtent: true, }, yAxis: { type: 'category', @@ -374,7 +376,8 @@ xAxis: { type: 'value', min: -100, - max: 400 + max: 400, + includeMarkerInExtent: true, }, yAxis: { type: 'category', From 774c2095a56e43abdc03c67d1bdb5e93c6513d69 Mon Sep 17 00:00:00 2001 From: quao Date: Tue, 25 Nov 2025 17:20:08 +0800 Subject: [PATCH 09/10] =?UTF-8?q?enha=20=E6=95=B0=E5=80=BC=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coord/cartesian/Grid.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coord/cartesian/Grid.ts b/src/coord/cartesian/Grid.ts index 4a3f5846d9..40bed5435e 100644 --- a/src/coord/cartesian/Grid.ts +++ b/src/coord/cartesian/Grid.ts @@ -568,7 +568,8 @@ class Grid implements CoordinateSystemMaster { axisType: OptionAxisType, ): void { const includeMarkerInExtent = axis.model.get('includeMarkerInExtent') ?? false; - if (includeMarkerInExtent && value != null && typeof value !== 'string' && axisType !== 'category') { + const isValidNumber = typeof value === 'number' && !isNaN(value); + if (includeMarkerInExtent && isValidNumber && axisType !== 'category') { const val = axis.scale.parse(value); if (!isNaN(val)) { axis.scale.unionExtentByValue(val); From 4f388dcd154c2f156b7e2784c7d205971369828f Mon Sep 17 00:00:00 2001 From: quao Date: Wed, 26 Nov 2025 17:45:35 +0800 Subject: [PATCH 10/10] =?UTF-8?q?feat=20=E6=89=A9=E5=85=85=E5=AF=B9?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=BD=B4=E5=92=8C=E5=AF=B9=E6=95=B0=E8=BD=B4?= =?UTF-8?q?=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coord/cartesian/Grid.ts | 2 +- src/scale/Log.ts | 6 ++ test/axis-marker-extent.html | 139 +++++++++++++++++++++++++++++++++++ 3 files changed, 146 insertions(+), 1 deletion(-) diff --git a/src/coord/cartesian/Grid.ts b/src/coord/cartesian/Grid.ts index 40bed5435e..ba5164ce2e 100644 --- a/src/coord/cartesian/Grid.ts +++ b/src/coord/cartesian/Grid.ts @@ -569,7 +569,7 @@ class Grid implements CoordinateSystemMaster { ): void { const includeMarkerInExtent = axis.model.get('includeMarkerInExtent') ?? false; const isValidNumber = typeof value === 'number' && !isNaN(value); - if (includeMarkerInExtent && isValidNumber && axisType !== 'category') { + if (includeMarkerInExtent && (isValidNumber || typeof value === 'string') && axisType !== 'category') { const val = axis.scale.parse(value); if (!isNaN(val)) { axis.scale.unionExtentByValue(val); diff --git a/src/scale/Log.ts b/src/scale/Log.ts index bdd799056c..18ffd2974c 100644 --- a/src/scale/Log.ts +++ b/src/scale/Log.ts @@ -134,6 +134,12 @@ class LogScale extends IntervalScale { this._innerUnionExtent(loggedOther); } + unionExtentByValue(value: number): void { + this._originalScale.unionExtentByValue(value); + const loggedValue = logTransform(this.base, [value, value], true); + this._innerUnionExtent(loggedValue); + } + /** * Update interval and extent of intervals for nice ticks * @param approxTickNum default 10 Given approx tick number diff --git a/test/axis-marker-extent.html b/test/axis-marker-extent.html index c6ee4e0854..cc1525d02b 100644 --- a/test/axis-marker-extent.html +++ b/test/axis-marker-extent.html @@ -90,6 +90,18 @@
+ +
x轴为 time 类型
+
+
+
+
+
y轴为 log 类型
+
+
+
+
+