Skip to content

Commit 621d8af

Browse files
author
quao
committed
fix cr
1 parent dcfd98d commit 621d8af

File tree

4 files changed

+89
-13
lines changed

4 files changed

+89
-13
lines changed

src/component/marker/checkMarkerInSeries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import { isArray } from 'zrender/src/core/util';
2121
import { SeriesOption } from '../../util/types';
2222

23-
type MarkerTypes = 'markPoint' | 'markLine' | 'markArea';
23+
export type MarkerTypes = 'markPoint' | 'markLine' | 'markArea';
2424

2525
type SeriesWithMarkerOption = SeriesOption & Partial<Record<MarkerTypes, unknown>>;
2626

src/coord/cartesian/Grid.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import { error, log } from '../../util/log';
7070
import { AxisTickLabelComputingKind } from '../axisTickLabelBuilder';
7171
import { injectCoordSysByOption } from '../../core/CoordinateSystem';
7272
import { mathMax, parsePositionSizeOption } from '../../util/number';
73+
import { MarkerTypes } from '../../component/marker/checkMarkerInSeries';
7374

7475
type Cartesian2DDimensionName = 'x' | 'y';
7576

@@ -81,8 +82,6 @@ type AxesMap = {
8182

8283
type ParsedOuterBoundsContain = 'all' | 'axisLabel';
8384

84-
type MarkerTypes = 'markPoint' | 'markLine' | 'markArea';
85-
8685
// margin is [top, right, bottom, left]
8786
const XY_TO_MARGIN_IDX = [
8887
[3, 1], // xyIdx 0 => 'x'
@@ -545,7 +544,7 @@ class Grid implements CoordinateSystemMaster {
545544
unionExtent(data, xAxis);
546545
unionExtent(data, yAxis);
547546

548-
// 处理 markPointmarkLinemarkArea
547+
// Handle markPoint, markLine, markArea
549548
const markerTypes: MarkerTypes[] = ['markPoint', 'markLine', 'markArea'];
550549

551550
markerTypes.forEach(markerType => {
@@ -563,7 +562,7 @@ class Grid implements CoordinateSystemMaster {
563562
});
564563
}
565564

566-
function UnionExtentForAxisByValue(
565+
function unionExtentForAxisByValue(
567566
value: any,
568567
axis: Axis2D,
569568
axisType: OptionAxisType,
@@ -572,10 +571,7 @@ class Grid implements CoordinateSystemMaster {
572571
if (includeMarkerInExtent && value != null && typeof value !== 'string' && axisType !== 'category') {
573572
const val = axis.scale.parse(value);
574573
if (!isNaN(val)) {
575-
// Construct the parameter and use unionExtentFromData to avoid using the private method _innerUnionExtent
576-
axis.scale.unionExtentFromData({
577-
getApproximateExtent: () => [val, val]
578-
} as any, 0);
574+
axis.scale.unionExtentByValue(val);
579575
}
580576
}
581577
}
@@ -596,12 +592,12 @@ class Grid implements CoordinateSystemMaster {
596592
return;
597593
}
598594

599-
UnionExtentForAxisByValue(markerItem.xAxis, xAxis, xAxis.type);
600-
UnionExtentForAxisByValue(markerItem.yAxis, yAxis, yAxis.type);
595+
unionExtentForAxisByValue(markerItem.xAxis, xAxis, xAxis.type);
596+
unionExtentForAxisByValue(markerItem.yAxis, yAxis, yAxis.type);
601597

602598
if (markerItem.coord && Array.isArray(markerItem.coord)) {
603-
UnionExtentForAxisByValue(markerItem.coord[0], xAxis, xAxis.type);
604-
UnionExtentForAxisByValue(markerItem.coord[1], yAxis, yAxis.type);
599+
unionExtentForAxisByValue(markerItem.coord[0], xAxis, xAxis.type);
600+
unionExtentForAxisByValue(markerItem.coord[1], yAxis, yAxis.type);
605601
}
606602
});
607603
});

src/scale/Scale.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ abstract class Scale<SETTING extends ScaleSettingDefault = ScaleSettingDefault>
133133
this._innerUnionExtent(data.getApproximateExtent(dim));
134134
}
135135

136+
/**
137+
* Update extent by value
138+
*/
139+
unionExtentByValue(value: number): void {
140+
const extent = this._extent;
141+
// Considered that number could be NaN and should not write into the extent.
142+
this._innerSetExtent(
143+
value < extent[0] ? value : extent[0],
144+
value > extent[1] ? value : extent[1]
145+
);
146+
}
147+
136148
/**
137149
* Get a new slice of extent.
138150
* Extent is always in increase order.

test/axis-marker-extent.html

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

0 commit comments

Comments
 (0)