回答 Rob 的评论:
minorTicks 和majorTicks 不可能有不同的宽度,因为在内部,一个轴的刻度元素是一个 SVG 路径。但是,有几种可能的解决方法:
1) 根本不显示minorTicks:
const board = JXG.JSXGraph.initBoard('jxgbox', {
boundingbox: [-5, 5, 5, -5],
axis:true,
defaultAxes: {
x: {
ticks: {
strokeWidth: 5,
minorTicks: 0
}
},
y: {
ticks: {
strokeWidth: 5,
minorTicks: 0
}
}
}
});
2) 如果您坚持使用次要刻度和 主要刻度,则不要在默认轴的默认刻度中显示majorTicks,而是在默认轴上添加不带minorTicks 的粗刻度,见https://jsfiddle.net/vf3muqgn/1/:
const board = JXG.JSXGraph.initBoard('jxgbox', {
boundingbox: [-5, 5, 5, -5],
axis:true,
defaultAxes: {
x: {
ticks: {
majorHeight: 0
}
},
y: {
ticks: {
majorHeight: 0
}
}
}
});
board.create('ticks', [board.defaultAxes.x], {
strokeColor: '#cccccc',
minorTicks: 0,
majorHeight: -1,
strokeWidth: 3
});
board.create('ticks', [board.defaultAxes.y], {
strokeColor: '#cccccc',
minorTicks: 0,
majorHeight: -1,
strokeWidth: 3
});