From 73110d05cbb1ae4e6579b55b453c5bb25bc42b49 Mon Sep 17 00:00:00 2001 From: dhunt84971 Date: Sat, 24 Nov 2018 18:29:02 -0500 Subject: [PATCH 1/2] Add formatted value label to gauge via new value options. --- dist/gauge.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/dist/gauge.js b/dist/gauge.js index 66901b0..e67dda3 100644 --- a/dist/gauge.js +++ b/dist/gauge.js @@ -452,7 +452,16 @@ radiusScale: 1.0, fontSize: 40, limitMax: false, - limitMin: false + limitMin: false, + value: { + show: true, + font: "20px Arial", + color: "black", + down: 0, + right: 0, + decimals: 0, + units: "" + } }; function Gauge(canvas) { @@ -759,6 +768,16 @@ this.ctx.beginPath(); this.ctx.arc(w, h, radius, displayedAngle, (2 - this.options.angle) * Math.PI, false); this.ctx.stroke(); + if (this.options.value.show == true) { + this.ctx.globalCompositeOperation='destination-over'; + this.ctx.font = this.options.value.font; + this.ctx.fillStyle = this.options.value.color; + this.ctx.textAlign = "center"; + this.ctx.fillText(addCommas( + this.displayedValue.toFixed(this.options.value.decimals)) + " " + this.options.value.units, + (this.canvas.width/2) + this.options.value.right, + (this.canvas.height/2) + this.options.value.down); + } this.ctx.save(); this.ctx.translate(w, h); } From 61cc7b7c386e794e80b872bcf67b80c166cdfdf8 Mon Sep 17 00:00:00 2001 From: dhunt84971 Date: Sat, 24 Nov 2018 19:25:12 -0500 Subject: [PATCH 2/2] Remove z-order problem. --- dist/gauge.js | 1 - 1 file changed, 1 deletion(-) diff --git a/dist/gauge.js b/dist/gauge.js index e67dda3..d349555 100644 --- a/dist/gauge.js +++ b/dist/gauge.js @@ -769,7 +769,6 @@ this.ctx.arc(w, h, radius, displayedAngle, (2 - this.options.angle) * Math.PI, false); this.ctx.stroke(); if (this.options.value.show == true) { - this.ctx.globalCompositeOperation='destination-over'; this.ctx.font = this.options.value.font; this.ctx.fillStyle = this.options.value.color; this.ctx.textAlign = "center";