MCPcopy
hub / github.com/toorshia/justgage / _drawGauge

Method _drawGauge

src/core/JustGage.js:156–204  ·  view source on GitHub ↗

* Draw the complete gauge * @private

()

Source from the content-addressed store, hash-verified

154 * @private
155 */
156 _drawGauge() {
157 const config = this.config;
158
159 // Calculate widget dimensions using original algorithm
160 const { widgetW, widgetH, dx, dy } = this._calculateGaugeGeometry();
161
162 // Draw gauge background using original path generation
163 const gaugePath = this.renderer.createGaugePath(
164 config.max,
165 config.min,
166 config.max,
167 widgetW,
168 widgetH,
169 dx,
170 dy,
171 config.gaugeWidthScale || 1.0,
172 config.donut,
173 false // this is relevant only for level drawing
174 );
175
176 this.canvas.gauge = this.renderer.path(gaugePath).attr({
177 fill: config.gaugeColor,
178 stroke: 'none',
179 });
180
181 // Apply donut rotation to background gauge (like original)
182 this._applyDonutRotation(this.canvas.gauge, config, widgetW, widgetH, dx, dy);
183
184 // Draw value level or sector colors based on configuration
185 if (config.showSectorColors) {
186 // Draw static sector colors once (uses customSectors, levelColors, or gaugeColor)
187 this._drawSectorColors();
188 } else {
189 // Draw value level (start from appropriate value for animation)
190 // Differential gauges start from middle (0), regular gauges from min
191 const startValue = config.differential ? (config.max + config.min) / 2 : config.min;
192 this._drawLevel(startValue);
193 }
194
195 // Draw labels
196 this._drawLabels();
197
198 // Draw pointer if enabled
199 if (config.pointer) {
200 this._drawPointer();
201 }
202
203 this._drawTargetLine();
204 }
205
206 /**
207 * Draw gauge level (filled arc)

Callers 1

_initializeGaugeMethod · 0.95

Calls 10

_applyDonutRotationMethod · 0.95
_drawSectorColorsMethod · 0.95
_drawLevelMethod · 0.95
_drawLabelsMethod · 0.95
_drawPointerMethod · 0.95
_drawTargetLineMethod · 0.95
createGaugePathMethod · 0.80
attrMethod · 0.80
pathMethod · 0.80

Tested by

no test coverage detected