Skip to content

Commit 36c1c59

Browse files
author
quao
committed
feat 新增轴配置项includeMarkerInExtent控制计算默认轴范围时是否考虑marker标记
1 parent f1c5b88 commit 36c1c59

File tree

3 files changed

+76
-5
lines changed

3 files changed

+76
-5
lines changed

src/coord/axisCommonTypes.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ export interface AxisBaseOptionCommon extends ComponentOption,
129129
breakLabelLayout?: {
130130
moveOverlap?: 'auto' | boolean;
131131
}
132+
133+
// Whether to include marker data (markPoint, markLine, markArea) in axis extent calculation
134+
includeMarkerInExtent?: boolean;
132135
}
133136

134137
export interface NumericAxisBaseOptionCommon extends AxisBaseOptionCommon {

src/coord/cartesian/Grid.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import {
5353
updateCartesianAxisViewCommonPartBuilder,
5454
isCartesian2DInjectedAsDataCoordSys
5555
} from './cartesianAxisHelper';
56-
import { CategoryAxisBaseOption, NumericAxisBaseOptionCommon } from '../axisCommonTypes';
56+
import { CategoryAxisBaseOption, NumericAxisBaseOptionCommon, OptionAxisType } from '../axisCommonTypes';
5757
import { AxisBaseModel } from '../AxisBaseModel';
5858
import { isIntervalOrLogScale } from '../../scale/helper';
5959
import { alignScaleTicks } from '../axisAlignTicks';
@@ -566,9 +566,11 @@ class Grid implements CoordinateSystemMaster {
566566
function UnionExtentForAxisByValue(
567567
value: any,
568568
axis: Axis2D,
569-
axisType: string,
569+
axisType: OptionAxisType,
570570
): void {
571-
if (value != null && typeof value !== 'string' && axisType !== 'category') {
571+
// 检查该轴是否配置为包含 marker 数据
572+
const includeMarkerInExtent = axis.model.get('includeMarkerInExtent') ?? true;
573+
if (includeMarkerInExtent && value != null && typeof value !== 'string' && axisType !== 'category') {
572574
const val = axis.scale.parse(value);
573575
if (!isNaN(val)) {
574576
axis.scale._innerUnionExtent([val, val]);

test/axis-marker-extent.html

Lines changed: 68 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)