File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -142,6 +142,9 @@ function drawSpeedometer(value) {
142142 ctx . stroke ( ) ;
143143
144144 drawMarkers ( startAngle , endAngle ) ;
145+ // console.log("debug:",startAngle,endAngle)
146+ // drawMarkers(-180, 180);
147+
145148 drawNeedle ( value ) ;
146149
147150
@@ -177,11 +180,14 @@ function drawMarkers(startAngle, endAngle) {
177180
178181 ctx . font = '16px Montserrat' ;
179182 ctx . fillStyle = getCSSVariable ( '--text' ) ;
183+ ctx . textAlign = "center" ;
184+ ctx . textBaseline = "middle" ;
180185
181186 markerValues . forEach ( ( markerValue ) => {
182187 const markerAngle = startAngle + ( markerValue / maxValue ) * arcLength ;
183- const xPos = ( canvasSize / 2 + Math . cos ( markerAngle ) * markerRadius ) - 16 ;
184- const yPos = ( canvasSize / 2 + Math . sin ( markerAngle ) * markerRadius ) ;
188+ const xPos = canvasSize / 2 + Math . cos ( markerAngle ) * markerRadius ;
189+ const yPos = canvasSize / 2 + Math . sin ( markerAngle ) * markerRadius ;
190+ // console.log("debug:>>", Math.cos(markerAngle) * markerRadius, (markerValue / maxValue));
185191 ctx . fillText ( markerValue . toFixed ( 1 ) , xPos , yPos ) ;
186192 } ) ;
187193}
Original file line number Diff line number Diff line change 305305 height: 100%; */
306306 display : block;
307307 width : 80vw ;
308- max-width : 400 px ;
308+ max-width : 442 px ;
309309 height : auto;
310310}
311311
You can’t perform that action at this time.
0 commit comments