Skip to content

Instantly share code, notes, and snippets.

@ToeJamson
Created February 20, 2015 23:43
Show Gist options
  • Save ToeJamson/b1b19e41470c59e8b764 to your computer and use it in GitHub Desktop.
Save ToeJamson/b1b19e41470c59e8b764 to your computer and use it in GitHub Desktop.
<script src="http://cdn.pubnub.com/pubnub.min.js"></script>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="../js/c3.js"></script>
<script src="../js/pubnub-c3.js"></script>
<div id="chart"></div>
<script>
var chart = pubnubC3({
channel: "c3-spline",
generate: {
bindto: '#chart',
data: {
x: 'x',
columns: [],
labels: true
},
axis : {
x : {
type : 'timeseries',
tick: {
format: '%H:%M:%S'
}
}
}
}
});
</script>
var pubnub = PUBNUB.init({
publish_key: 'demo',
subscribe_key: 'demo'
});
setInterval(function(){
pubnub.publish({
channel: 'c3-spline',
message: {
columns: [
['x', new Date().getTime()],
['Austin', Math.floor(Math.random() * 99)],
['New York', Math.floor(Math.random() * 99)],
['San Francisco', Math.floor(Math.random() * 99)],
['Portland', Math.floor(Math.random() * 99)]
]
}
});
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment