Open jihoonlee1980 opened 6 years ago
The same but inside of the gaude:
this.ctx.font="bold 22px sans-serif";
this.ctx.fillStyle = 'white';
this.ctx.fillText('Ruim', -190, -150);
this.ctx.fillText('Regular', 30, -210);
this.ctx.fillText('Bom', 170, -125);
this.ctx.fillText('Ótimo', 200, -30);
@paulobezerr How did you manage to show percentage instead of number?
@talk2cerlin, I have manually added + '%'
in fillText.
this.ctx.fillText(
formatNumber(value.label, staticLabels.fractionDigits) + '%',
0,
-radius - this.lineWidth / 2
);
@paulobezerr How did you manage to show percentage instead of number?
See https://github.com/bernii/gauge.js/issues/4#issuecomment-7761988 for an example of how to do this. I updated it to also account for the minimum value. My use case is a gauge that shows battery voltage (in millivolts) with a label that represents it as a percentage value with 2.8 volts = 0% and 3.6 volts = 100%. Here's my take on it.
var gauge = new Gauge(target).setOptions(opts);
gauge.maxValue = 3600;
gauge.setMinValue(2800);
var textRenderer = new TextRenderer(document.getElementById("preview-textfield"))
textRenderer.render = function(gauge){
percentage = (gauge.displayedValue-gauge.minValue) / (gauge.maxValue-gauge.minValue)
this.el.innerHTML = (percentage * 100).toFixed(2) + "%"
};
gauge.setTextField(textRenderer);
@paulobezerr Hello, I try to implement this gauge like you done with text inside, but with no success. I think i modify the code in the wrong position. Can you please precise where exactly in the code and what to change? thank you!
I move out from the company that has this change. Maybe @raphaelneumann can help you.
Can I use a text label on a gauge?
I want to draw directly in the canvas. But I am using npm.
So, I forked npm and tried the following: But it does not work
This is my modified code.
Example I think