plot icon indicating copy to clipboard operation
plot copied to clipboard

strokeDashArray affects markers

Open prostolyubo opened this issue 1 year ago • 2 comments

Current State

Certain settings on strokeDasharray property may break the markers. Here for instance instead of an arrow on the line we have a tick: image

Repro

Plot.plot({
  marks: [
    Plot.lineY([[0,5],[5,2],[10,0]], { 
      x: (d) => d[0], 
      y : (d) => d[1],
      strokeDasharray: "1,10",
      strokeWidth:3,
      markerMid: "arrow"
    })
  ]
})

Expected State

strokeDasharray should not affect markers, or there should be a separate property to control it: image

prostolyubo avatar Aug 12 '24 01:08 prostolyubo

Yes, this looks like a bug. The marker element is inheriting the stroke-dasharray because it’s within the g of the line mark. We could either move it up so it doesn’t inherit, or set the stroke-dasharray attribute on the marker explicitly to none. It seems reasonable that the marker shouldn’t inherit dashed strokes.

mbostock avatar Aug 12 '24 02:08 mbostock

Thanks for confirmation and pointing me into the right direction. Seems like an easy fix for me to figure it out. I'll make a PR if I fix it.

prostolyubo avatar Aug 12 '24 13:08 prostolyubo