Skip to content

Conversation

@adambouchard
Copy link

quick fix to prevent gauge display from breaking if max percent is greater than 100.

var gauge=function(div,percent,fill,highlight){percent > 100 ? 100 : percent;this.canvas=Raphael(div,300,100);this.background=this.canvas.path(arc(80,80,76,-180,0)).attr({"fill":"#f2f2f2","stroke":"none"});this.fill=this.canvas.path(arc(80,80,76,-180,-180*(1+(percent/100)))).attr({"fill":fill,"stroke":"none"});this.indicator=this.canvas.rect(80,80,76,3).attr({"fill":highlight,"stroke":"none"}).rotate(180*(1+(percent/100)),80,80);this.indicator.rotation=180*(1+(percent/100));this.indicatorCircle=this.canvas.circle(80,80,6).attr({"fill":highlight,"stroke":"none"});return{fill:this.fill,indicator:this.indicator,canvas:this.canvas,update:function(percent){this.indicator.rotate(-this.indicator.rotation,80,80).rotate(180*(1+(percent/100)),80,80);this.indicator.rotation=180*(1+(percent/100));this.fill.animate({path:arc(80,80,76,-180,-180*(1+(percent/100)))},300,"elastic").attr({"fill":fill,"stroke":"none"});}}}; No newline at end of file
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just added the following ternary at function start

percent > 100 ? 100 : percent;

@seanbehan
Copy link
Member

looks good

@adambouchard
Copy link
Author

cool. @tristanoneil do you want me to merge to master and update version to

VERSION = "0.0.3"

or do want to be the gatekeeper for this project?

@tristanoneil
Copy link

This should probably be changed in the original javascript gauge project first then the gauge.js file should just be updated in this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants