Skip to content

Instantly share code, notes, and snippets.

@domadev812
Forked from ToeJamson/1.js
Last active November 15, 2017 21:05
Show Gist options
  • Save domadev812/c8c59e58f2e46da6b7e1c1833e86783d to your computer and use it in GitHub Desktop.
Save domadev812/c8c59e58f2e46da6b7e1c1833e86783d to your computer and use it in GitHub Desktop.
<script src="https://cdn.pubnub.com/sdk/javascript/pubnub.4.17.0.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 = new PubNub({
subscribeKey: "demo",
publishKey: "demo",
ssl: true
})
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