(ctx, chartArea, scales, annotation)
| 38 | }, |
| 39 | |
| 40 | drawLine(ctx, chartArea, scales, annotation) { |
| 41 | const { left, right, top, bottom } = chartArea; |
| 42 | let x1, y1, x2, y2; |
| 43 | |
| 44 | if (annotation.scaleID) { |
| 45 | const scale = scales[annotation.scaleID]; |
| 46 | if (!scale) return; |
| 47 | |
| 48 | const pixel = scale.getPixelForValue(annotation.value); |
| 49 | |
| 50 | if (scale.isHorizontal()) { |
| 51 | // Vertical line |
| 52 | x1 = x2 = pixel; |
| 53 | y1 = top; |
| 54 | y2 = bottom; |
| 55 | } else { |
| 56 | // Horizontal line |
| 57 | x1 = left; |
| 58 | x2 = right; |
| 59 | y1 = y2 = pixel; |
| 60 | } |
| 61 | } else { |
| 62 | // Default to horizontal line on primary y-axis |
| 63 | const yScale = scales.y || scales.primary; |
| 64 | if (!yScale) return; |
| 65 | |
| 66 | const pixel = yScale.getPixelForValue(annotation.value); |
| 67 | x1 = left; |
| 68 | x2 = right; |
| 69 | y1 = y2 = pixel; |
| 70 | } |
| 71 | |
| 72 | ctx.beginPath(); |
| 73 | ctx.moveTo(x1, y1); |
| 74 | ctx.lineTo(x2, y2); |
| 75 | |
| 76 | ctx.strokeStyle = annotation.borderColor || '#ff0000'; |
| 77 | ctx.lineWidth = annotation.borderWidth || 2; |
| 78 | ctx.lineDashOffset = annotation.borderDashOffset || 0; |
| 79 | |
| 80 | if (annotation.borderDash) { |
| 81 | ctx.setLineDash(annotation.borderDash); |
| 82 | } |
| 83 | |
| 84 | ctx.stroke(); |
| 85 | |
| 86 | // Draw label if provided |
| 87 | if (annotation.label && annotation.label.content) { |
| 88 | this.drawLabel(ctx, x1, y1, x2, y2, annotation.label); |
| 89 | } |
| 90 | }, |
| 91 | |
| 92 | drawLabel(ctx, x1, y1, x2, y2, label) { |
| 93 | const content = label.content; |
nothing calls this directly
no test coverage detected