New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Percentage #4

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

Comments

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 ?

@ghost ghost assigned bernii Aug 15, 2012

@bernii

This comment has been minimized.

Show comment
Hide comment
@bernii

bernii Aug 15, 2012

Owner

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);
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