Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/component/axis/CartesianAxisView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const axisElementBuilders: Record<typeof selfBuilderAttrs[number], AxisElementBu
const splitLineModel = axisModel.getModel('splitLine');
const lineStyleModel = splitLineModel.getModel('lineStyle');
let lineColors = lineStyleModel.get('color');
const hiddenTicks = splitLineModel.get('hiddenTicks') || [];

lineColors = zrUtil.isArray(lineColors) ? lineColors : [lineColors];

Expand All @@ -142,6 +143,11 @@ const axisElementBuilders: Record<typeof selfBuilderAttrs[number], AxisElementBu
for (let i = 0; i < ticksCoords.length; i++) {
const tickCoord = axis.toGlobalCoord(ticksCoords[i].coord);

const tickValue = ticksCoords[i].tickValue;
if (hiddenTicks.includes(tickValue)) {
continue
}

if (isHorizontal) {
p1[0] = tickCoord;
p1[1] = gridRect.y;
Expand All @@ -156,9 +162,8 @@ const axisElementBuilders: Record<typeof selfBuilderAttrs[number], AxisElementBu
}

const colorIndex = (lineCount++) % lineColors.length;
const tickValue = ticksCoords[i].tickValue;
const line = new graphic.Line({
anid: tickValue != null ? 'line_' + ticksCoords[i].tickValue : null,
anid: tickValue != null ? 'line_' + tickValue : null,
autoBatch: true,
shape: {
x1: p1[0],
Expand Down
4 changes: 2 additions & 2 deletions src/coord/Axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ function fixOnBandTicksCoords(
let diffSize;
if (ticksLen === 1) {
ticksCoords[0].coord = axisExtent[0];
last = ticksCoords[1] = {coord: axisExtent[1]};
last = ticksCoords[1] = {coord: axisExtent[1], tickValue: ticksCoords[0].tickValue};
}
else {
const crossLen = ticksCoords[ticksLen - 1].tickValue - ticksCoords[0].tickValue;
Expand All @@ -315,7 +315,7 @@ function fixOnBandTicksCoords(
const dataExtent = axis.scale.getExtent();
diffSize = 1 + dataExtent[1] - ticksCoords[ticksLen - 1].tickValue;

last = {coord: ticksCoords[ticksLen - 1].coord + shift * diffSize};
last = {coord: ticksCoords[ticksLen - 1].coord + shift * diffSize, tickValue: dataExtent[1] + 1};

ticksCoords.push(last);
}
Expand Down
3 changes: 2 additions & 1 deletion src/coord/axisCommonTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ interface MinorTickOption {

interface SplitLineOption {
show?: boolean,
interval?: 'auto' | number | ((index:number, value: string) => boolean)
interval?: 'auto' | number | ((index:number, value: string) => boolean),
hiddenTicks?: number[];
// colors will display in turn
lineStyle?: LineStyleOption<ZRColor | ZRColor[]>
}
Expand Down
82 changes: 82 additions & 0 deletions test/axis-splitLine.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.