@@ -273,7 +273,7 @@ public string GetWindImage(double windDirectionInDegrees, double windVelocity, d
273
273
274
274
public string GetGenericGaugeImage ( string text , double value , double min , double max , int ? fontSize , string valueFormat , string ? subValueText = null )
275
275
{
276
- var font = SystemFonts . CreateFont ( "Arial" , fontSize ?? 22 , FontStyle . Regular ) ;
276
+ var valueFont = SystemFonts . CreateFont ( "Arial" , fontSize ?? 22 , FontStyle . Regular ) ;
277
277
var titleFont = SystemFonts . CreateFont ( "Arial" , 13 , FontStyle . Regular ) ;
278
278
var pen = new SolidPen ( Color . DarkRed , 5 ) ;
279
279
var range = max - min ;
@@ -306,19 +306,22 @@ public string GetGenericGaugeImage(string text, double value, double min, double
306
306
307
307
ctx . DrawLine ( pen , needle ) ;
308
308
309
- FontRectangle size = new FontRectangle ( 0 , 0 , 0 , 0 ) ;
309
+ FontRectangle titleSize = new FontRectangle ( 0 , 0 , 0 , 0 ) ;
310
310
if ( ! string . IsNullOrWhiteSpace ( text ) )
311
311
{
312
- size = TextMeasurer . MeasureSize ( text , new TextOptions ( titleFont ) ) ;
313
- ctx . DrawText ( text , titleFont , Color . White , new PointF ( HALF_WIDTH - size . Width / 2 , 43 ) ) ;
312
+ titleSize = TextMeasurer . MeasureSize ( text , new TextOptions ( titleFont ) ) ;
313
+ ctx . DrawText ( text , titleFont , Color . White , new PointF ( HALF_WIDTH - titleSize . Width / 2 , 46 ) ) ;
314
314
}
315
315
316
316
var valueText = value . ToString ( valueFormat ) ;
317
- var sizeValue = TextMeasurer . MeasureSize ( valueText , new TextOptions ( font ) ) ;
317
+ var valueSize = TextMeasurer . MeasureSize ( valueText , new TextOptions ( valueFont ) ) ;
318
318
var textColor = value > max ? Color . Red : Color . White ;
319
- ctx . DrawText ( valueText , font , textColor , new PointF ( 18 , 46 - sizeValue . Height ) ) ;
319
+ ctx . DrawText ( valueText , valueFont , textColor , new PointF ( 18 , 46 - 4 - valueSize . Height ) ) ;
320
320
321
- if ( ! string . IsNullOrWhiteSpace ( subValueText ) ) ctx . DrawText ( subValueText , titleFont , textColor , new PointF ( 20 , 41 + size . Height ) ) ;
321
+ if ( ! string . IsNullOrWhiteSpace ( subValueText ) )
322
+ {
323
+ ctx . DrawText ( subValueText , titleFont , textColor , new PointF ( 20 , 46 + 3 + titleSize . Height ) ) ;
324
+ }
322
325
} ) ;
323
326
324
327
return img . ToBase64PNG ( ) ;
0 commit comments