(shapePath, gd, shapeOptions)
| 227 | } |
| 228 | |
| 229 | function setClipPath(shapePath, gd, shapeOptions) { |
| 230 | // note that for layer="below" the clipAxes can be different from the |
| 231 | // subplot we're drawing this in. This could cause problems if the shape |
| 232 | // spans two subplots. See https://github.com/plotly/plotly.js/issues/1452 |
| 233 | // |
| 234 | // if axis is 'paper' or an axis with " domain" appended, then there is no |
| 235 | // clip axis |
| 236 | |
| 237 | const xref = shapeOptions.xref; |
| 238 | const yref = shapeOptions.yref; |
| 239 | |
| 240 | // For multi-axis shapes, create a custom clip path from axis bounds |
| 241 | if (Array.isArray(xref) || Array.isArray(yref)) { |
| 242 | const clipId = 'clip' + gd._fullLayout._uid + 'shape' + shapeOptions._index; |
| 243 | const rect = getMultiAxisClipRect(gd, xref, yref); |
| 244 | |
| 245 | Lib.ensureSingleById(gd._fullLayout._clips, 'clipPath', clipId, function (s) { |
| 246 | s.append('rect'); |
| 247 | }) |
| 248 | .select('rect') |
| 249 | .attr(rect); |
| 250 | |
| 251 | Drawing.setClipUrl(shapePath, clipId, gd); |
| 252 | } else { |
| 253 | const clipAxes = (xref + yref).replace(/paper/g, '').replace(/[xyz][0-9]* *domain/g, ''); |
| 254 | Drawing.setClipUrl(shapePath, clipAxes ? 'clip' + gd._fullLayout._uid + clipAxes : null, gd); |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | function getMultiAxisClipRect(gd, xref, yref) { |
| 259 | const gs = gd._fullLayout._size; |
no test coverage detected
searching dependent graphs…