It’s voting time. Get ready to see a million graphs showing poll results of all the various groups — how many left-handed cellists voted green party, how many fiscally liberal vampires want to defund global warming, how many otters publicly opinion that eating is best while lying on your back.

I used Chart.js to build a bar graph that displays poll results between three counters. In this blog, I’ll show you how I did it.

Image for post

Jump to the GitHub

Tutorial

Table of Contents

  • Preliminary Junk
  • HTML & CSS
  • JavaScript for Vote Buttons and Results Text
  • Applying Chart.js
  • Conclusion

Preliminary Junk

To start, I set up a file for my HTML, CSS, and JavaScript. Then, I installed Chart.js with npm:

npm install chart.js --save

I ended up with a file structure (minus poll-machine-demo.gif) like this :

Image for post

HTML & CSS

I set up the bones for this project in index.html.

Image for post

And of course, I connected my stylesheet, JavaScript file and the Chart.js node module.

Image for post

Image for post

#software-development #javascript #programming #chartjs #web-development

Using Chart.js to Display Poll Data in a Cool Way
3.65 GEEK