In this step, you will display the poll results.
- Backport your
app.js
from the previous step into this one. - Update the
PollService
, by adding a methodgetVotes()
that retrieves the result of the votes from APISpark. - Update the
PollAppController
to add a getVotes() function to the controller. Purpose of the function is to prepare the data structure that will be passed to the Graph. Make sure to return an result that respect following structure:
{ "key":"Vote Results",
"values":[ {"label":"Javascript", "value":0},
{"label":"Java","value":0},
{"label":"Ruby","value":0},
{"label":"C/C++","value":0},
{"label":"Python","value":0} ] }
- Edit
chart.directive.js
and implementcreateBarChart(chartId, data)
function. HINT: Refer to nvd3 documentation for help. - Then, implement
updateBarChart(data)
function. HINT: Refer to this stackoverflow topic for help. - Finally, edit the
index.html
to add a reference to theBarChart
directive with proper params.
Now that we have displayed vote's results in a Bar Chart, let's see how to update chart in realtime using Streamdata.io, Go to step-06.