Skip to content

Commit 627a8dd

Browse files
committed
feat: allow font spec for marker labels
1 parent c4e7621 commit 627a8dd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

projects/ngx-gauge/src/gauge/gauge.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export class NgxGauge implements AfterViewInit, OnChanges, OnDestroy, OnInit {
227227
for(let i = 0; i < ranges.length; ++i) {
228228
let r = ranges[i];
229229
this._context.beginPath();
230-
this._context.strokeStyle = r.backgroundColor ? r.backgroundColor : r.color;
230+
this._context.strokeStyle = r.backgroundColor ? r.backgroundColor : (r.bgOpacity) ? r.color : this.backgroundColor;
231231
if (r.bgOpacity !== undefined && r.bgOpacity !== null) {
232232
this._context.globalAlpha = r.bgOpacity;
233233
}
@@ -266,7 +266,7 @@ export class NgxGauge implements AfterViewInit, OnChanges, OnDestroy, OnInit {
266266

267267
}
268268

269-
private _addMarker(angle,color,label?,type?,len?) {
269+
private _addMarker(angle,color,label?,type?,len?,font?) {
270270

271271
var rad = angle * Math.PI / 180;
272272

@@ -339,7 +339,7 @@ export class NgxGauge implements AfterViewInit, OnChanges, OnDestroy, OnInit {
339339
this._context.translate(x2, y2);
340340
this._context.rotate((angle + 90) * (Math.PI / 180));
341341
this._context.textAlign = "center";
342-
this._context.font = '13px Arial';
342+
this._context.font = (font) ? font : '13px Arial';
343343
this._context.fillText(label,0,-3);
344344
this._context.restore();
345345
}
@@ -523,6 +523,7 @@ export class NgxGauge implements AfterViewInit, OnChanges, OnDestroy, OnInit {
523523
color: '#555',
524524
size: 5,
525525
label: '10',
526+
font: '11px verdana'
526527
type: 'line',
527528
},
528529
'20': {
@@ -542,7 +543,7 @@ export class NgxGauge implements AfterViewInit, OnChanges, OnDestroy, OnInit {
542543
var angle = bounds.start + (n * perD);
543544

544545
var m = this.markers[mv];
545-
this._addMarker(angle,m.color,m.label,m.type,m.size);
546+
this._addMarker(angle,m.color,m.label,m.type,m.size,m.font);
546547
}
547548
}
548549

0 commit comments

Comments
 (0)