Last active
October 19, 2016 08:17
-
-
Save larsgk/7e5731de0b9af417a9208c62b7de69c8 to your computer and use it in GitHub Desktop.
Example of wrapping an external component in a polymer element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="import" href="../bower_components/polymer/polymer.html"> | |
<script src="../3rdparty/justgage-1.2.9/raphael-2.1.4.min.js"></script> | |
<script src="../3rdparty/justgage-1.2.9/justgage.js"></script> | |
<dom-module id="justgage-element"> | |
<template> | |
<div id="gauge"></div> | |
</template> | |
<script> | |
Polymer({ | |
is: 'justgage-element', | |
properties: { | |
value: { | |
type: Number, | |
observer: '_valueChanged' | |
} | |
}, | |
ready: function() { | |
this.g = new JustGage({ | |
parentNode: this.$$('#gauge'), | |
value: 110, | |
min: 60, | |
max: 160, | |
startAnimationTime: 10, | |
refreshAnimationTime: 20, | |
gaugeWidthScale: 0.4, | |
title: "tick", | |
customSectors: { | |
length: 1, // TEMP workaround for bug in JustGage | |
ranges: [{ | |
color : "#ff0000", | |
lo : 0, | |
hi : 99 | |
},{ | |
color : "#00ff00", | |
lo : 100, | |
hi : 120 | |
},{ | |
color : "#ff0000", | |
lo : 121, | |
hi : 220 | |
}] | |
} | |
}); | |
console.log(this.g); | |
}, | |
_valueChanged: function() { | |
this.g.refresh(this.value & 0xff); | |
} | |
}); | |
</script> | |
</dom-module> |
Author
larsgk
commented
Oct 19, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment