Skip to content

Instantly share code, notes, and snippets.

@robfallows
Last active August 29, 2015 14:16
Show Gist options
  • Save robfallows/9bd0e199fcbcf456d607 to your computer and use it in GitHub Desktop.
Save robfallows/9bd0e199fcbcf456d607 to your computer and use it in GitHub Desktop.
Simple tunguska:gauge example
<head>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=0, width=device-width">
</head>
<body>
{{> gauge id="demo" style="basic"}}
</body>
<template name="gauge">
<div id="demo" style="display:inline-block;width:200px;height:200px;"></div>
</template>
GaugeData = new Mongo.Collection('gauge-data');
Template.gauge.rendered = function() {
var self = this;
self.gauge = new TunguskaGauge({
id: self.data.id,
theme: self.data.style
});
self.subscribe('current-gauge-data', function() { // Uses new Meteor 1.0.4 Template.subscribe() method
self.autorun(function() {
self.gauge.set(GaugeData.findOne({_id:'demo'}).value);
});
});
}
Meteor.publish('current-gauge-data', function() {
var init = false;
var self = this;
Meteor.setInterval(function() {
var ran = Math.floor(Math.random() * 101);
if (init) {
self.changed('gauge-data', 'test', {value:ran});
} else {
self.added('gauge-data', 'test', {value:ran});
}
self.ready();
init = true;
}, 1000);
});
@ionescu77
Copy link

Wow, this looks amazing!

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