* Draw target line at specified value * @private
()
| 752 | * @private |
| 753 | */ |
| 754 | _drawTargetLine() { |
| 755 | const config = this.config; |
| 756 | |
| 757 | if (config.targetLine == null) { |
| 758 | return; |
| 759 | } |
| 760 | |
| 761 | const { widgetW, widgetH, dx, dy } = this._calculateGaugeGeometry(); |
| 762 | |
| 763 | // Calculate reversed target value if needed (same as original implementation) |
| 764 | let targetValue = config.targetLine; |
| 765 | if (config.reverse) { |
| 766 | targetValue = config.max + config.min - config.targetLine; |
| 767 | } |
| 768 | |
| 769 | // Calculate angle based on gauge type (matching SVG renderer logic) |
| 770 | let alpha; |
| 771 | if (config.donut) { |
| 772 | // Donut gauges use different angle calculation with 2x factor |
| 773 | alpha = (1 - (2 * (targetValue - config.min)) / (config.max - config.min)) * Math.PI; |
| 774 | } else { |
| 775 | // Standard gauge angle calculation |
| 776 | alpha = (1 - (targetValue - config.min) / (config.max - config.min)) * Math.PI; |
| 777 | } |
| 778 | |
| 779 | let Ro = widgetW / 2 - widgetW / 10; |
| 780 | let Ri = Ro - (widgetW / GAUGE_WIDTH_DIVISOR) * config.gaugeWidthScale; |
| 781 | let Cx, Cy, Xo, Yo, Xi, Yi; |
| 782 | |
| 783 | if (config.donut) { |
| 784 | Ro = widgetW / 2 - widgetW / 30; |
| 785 | Ri = Ro - (widgetW / GAUGE_WIDTH_DIVISOR) * config.gaugeWidthScale; |
| 786 | |
| 787 | Cx = widgetW / 2 + dx; |
| 788 | Cy = widgetH / 2 + dy; |
| 789 | |
| 790 | Xo = Cx + Ro * Math.cos(alpha); |
| 791 | Yo = Cy - Ro * Math.sin(alpha); |
| 792 | Xi = Cx + Ri * Math.cos(alpha); |
| 793 | Yi = Cy - Ri * Math.sin(alpha); |
| 794 | } else { |
| 795 | Cx = widgetW / 2 + dx; |
| 796 | Cy = widgetH / 1.25 + dy; |
| 797 | |
| 798 | Xo = Cx + Ro * Math.cos(alpha); |
| 799 | Yo = Cy - Ro * Math.sin(alpha); |
| 800 | Xi = Cx + Ri * Math.cos(alpha); |
| 801 | Yi = Cy - Ri * Math.sin(alpha); |
| 802 | } |
| 803 | |
| 804 | // Create path from inner to outer radius (like original) |
| 805 | const pathData = `M ${Xi} ${Yi} L ${Xo} ${Yo}`; |
| 806 | |
| 807 | this.canvas.targetLine = this.renderer.path(pathData).attr({ |
| 808 | stroke: config.targetLineColor, |
| 809 | 'stroke-width': config.targetLineWidth, |
| 810 | }); |
| 811 |
no test coverage detected