Skip to content

Commit

Permalink
setRawValue() implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
mstadnyk committed Mar 7, 2013
1 parent 4f0d78b commit 423dd43
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
33 changes: 21 additions & 12 deletions gauge.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,19 @@ var Gauge = function( config) {

return this;
};

/**
* Sets a new value to gauge and updates the gauge view without
* any animation (even if configured)
*
* @param {Number} val - the new value to set to the gauge
* @return {Gauge} this - returns self
*/
this.setRawValue = function( val) {
fromValue = value = val;
this.draw();
return this;
};

/**
* Clears the value of the gauge
Expand Down Expand Up @@ -625,11 +638,11 @@ var Gauge = function( config) {
ctx.shadowColor = 'rgba(188, 143, 143, 0.45)';
}
;

ctx.save();


shad();

ctx.save();

if (fromValue < 0) {
fromValue = Math.abs(config.minValue - fromValue);
} else if (config.minValue > 0) {
Expand Down Expand Up @@ -999,20 +1012,16 @@ domReady( function() {
}
}
}

var g = new Gauge( config);

if (gauge.getAttribute( 'data-onready')) {
g.onready = function() {
eval( this.config.renderTo.getAttribute( 'data-onready'));
};
if (gauge.getAttribute('data-value')) {
g.setRawValue( parseFloat( gauge.getAttribute('data-value')));
}

if (gauge.getAttribute('data-value')) {
var r = g.onready;
if (gauge.getAttribute( 'data-onready')) {
g.onready = function() {
this.setValue( parseFloat( this.config.renderTo.getAttribute('data-value')));
r && r.call( this);
eval( this.config.renderTo.getAttribute( 'data-onready'));
};
}

Expand Down
Loading

0 comments on commit 423dd43

Please sign in to comment.