diff --git a/src/component/axis/CartesianAxisView.ts b/src/component/axis/CartesianAxisView.ts index 3cc48e3041..8d99105aac 100644 --- a/src/component/axis/CartesianAxisView.ts +++ b/src/component/axis/CartesianAxisView.ts @@ -29,6 +29,7 @@ import CartesianAxisModel from '../../coord/cartesian/AxisModel'; import GridModel from '../../coord/cartesian/GridModel'; import { Payload } from '../../util/types'; import { isIntervalOrLogScale } from '../../scale/helper'; +import IntervalScale from '../../scale/Interval'; const axisBuilderAttrs = [ 'axisLine', 'axisTickLabel', 'axisName' @@ -135,6 +136,30 @@ const axisElementBuilders: Record 2 && axisScale.getInterval) { + const interval = axisScale.getInterval(); + + const showMinLine = splitLineModel.get('showMinLine'); + if (!showMinLine + || (showMinLine === 'auto' + && ticksCoords[1].tickValue - ticksCoords[0].tickValue < interval + ) + ) { + ticksCoords.shift(); + } + + const showMaxLine = splitLineModel.get('showMaxLine'); + if (!showMaxLine + || (showMaxLine === 'auto' + && ticksCoords[ticksCoords.length - 1].tickValue + - ticksCoords[ticksCoords.length - 2].tickValue < interval + ) + ) { + ticksCoords.pop(); + } + } + const p1 = []; const p2 = []; diff --git a/src/coord/axisCommonTypes.ts b/src/coord/axisCommonTypes.ts index bb4d1b7bf1..9b8476cf01 100644 --- a/src/coord/axisCommonTypes.ts +++ b/src/coord/axisCommonTypes.ts @@ -246,6 +246,10 @@ interface MinorTickOption { interface SplitLineOption { show?: boolean, + // true | false | 'auto'(true when nick tick) + showMinLine?: boolean | 'auto', + // true | false | 'auto'(true when nick tick) + showMaxLine?: boolean | 'auto', interval?: 'auto' | number | ((index:number, value: string) => boolean) // colors will display in turn lineStyle?: LineStyleOption diff --git a/src/coord/axisDefault.ts b/src/coord/axisDefault.ts index 4d2c6674b3..797e970c9a 100644 --- a/src/coord/axisDefault.ts +++ b/src/coord/axisDefault.ts @@ -97,7 +97,9 @@ const defaultOption: AxisBaseOption = { color: ['#E0E6F1'], width: 1, type: 'solid' - } + }, + showMinLine: true, + showMaxLine: true }, splitArea: { show: false, diff --git a/test/axis-interval.html b/test/axis-interval.html index b84c3c8ba7..4d17c74149 100644 --- a/test/axis-interval.html +++ b/test/axis-interval.html @@ -70,6 +70,11 @@

Test xAxis.axisTick.interval

+

Test xAxis.splitLine.showMinLine/showMaxLine

+
+
+
+ + - \ No newline at end of file +