Closed orefalo closed 12 years ago
I've added a helper class that wraps text div to help you customize the rendering of the text field. Here you can find a simple source code (JavaScript) that converts gauge value to percentage :)
gauge = new Gauge(target).setOptions(opts);
var textRenderer = new TextRenderer(document.getElementById('preview-textfield'))
textRenderer.render = function(gauge){
percentage = gauge.displayedValue / gauge.maxValue
this.el.innerHTML = (percentage * 100).toFixed(2) + "%"
};
gauge.setTextField(textRenderer);
it worked for me....thanks
Muito obrigado. Funcionou perfeitamente pra mim. Eu usei para valor monetário. Deixo o código para ajudar outros Devs.
let textRenderer = new TextRenderer(document.getElementById("preview-textfield"))
textRenderer.render = function(gauge) {
this.el.innerHTML = "R$ " + gauge.displayedValue.toLocaleString("pt-BR");
};
gauge.setTextField(textRenderer);
Very neat project, congrats.
what about a percentage rather than the actual gauge value ?