Slide 31
Slide 31 text
Realtime Pie Graph
created: function() {
var client = io();
client.on("vote", this.updateVote);
client.on("connect", () =>
client.emit("subscribe", this.id, this.setup));
},
methods: {
setup: function(data) {
this.poll = data;
this.chart = $("#vote-pie").epoch({
type: "pie", inner: 90, data: data.choices});
},
updateVote: function(vote) {
this.poll.choices.find(c =>
c.id == vote.choice).value += 1;
this.chart.update(this.poll.choices);
...