Skip to content
Advertisement

Variable in JavaScript with firebase

I am creating a simple polling website using HTML & JavaScript (through Glitch) and also Firebase, I followed a tutorial to do it. I have it all working and the voting works fine and displays the results as intended. I now want to take the results and use them to display a chart on my HTML page. I understand how this works, just not how to get the voting results variable into the JS code for the chart. I am using charts.js and the code for this is towards the bottom. The y values should be a variable reading the total votes, but it isn’t working. Any suggestions?

Thanks

JavaScript

Advertisement

Answer

Try placing the chart.js code only when firebase has loaded and performed its needed actions.

Try this:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement