Percentage #4

Closed
orefalo opened this Issue Jul 31, 2012 · 1 comment

Projects

None yet

2 participants

@orefalo
orefalo commented Jul 31, 2012

Very neat project, congrats.

what about a percentage rather than the actual gauge value ?

@bernii bernii was assigned Aug 15, 2012
@bernii
Owner
bernii commented Aug 15, 2012

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);
@bernii bernii closed this Aug 15, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment