lineDash - 自定义虚线样式

通过 lineDash 属性可以自定义任意虚线模式(等价于 Canvas 的 setLineDash)。 支持数组字符串两种格式,配合 lineDashOffset 控制偏移量。 比原有的 lineType: 'dotted' 灵活得多。

用法

// 数组格式 - 等间距虚线
style: { stroke: '#00d4ff', lineWidth: 2, lineDash: [10, 5] }

// 字符串格式 - 点划线
style: { stroke: '#ff6b6b', lineWidth: 3, lineDash: '2, 8' }

// 长短交替虚线
style: { stroke: '#ffd93d', lineWidth: 2, lineDash: [20, 5, 5, 5] }

// 带偏移量
style: { stroke: '#fb923c', lineWidth: 2, lineDash: [10, 10], lineDashOffset: 5 }

// 矩形也可以用虚线边框
g.createShape('rect', {
    position: {x: 80, y: 300}, width: 200, height: 60,
    style: { stroke: '#38bdf8', lineWidth: 2, lineDash: [8, 4], close: true, fill: 'transparent' }
});