app.js
//creates a list with the results of click votes
creates a list with the results of click votes
creates a list with the results of click votes
function displayResults() {
    var voteCounts = [];
    for (var i = 0; i < allProducts.length; i++) {
        voteCounts.push(allProducts[i].clicks);
    }
      var ctx = document.getElementById('myChart').getContext('2d');
    var myChart = new Chart(ctx, {
        type: 'bar',
        data: {
            labels: productNames,
            datasets: [{
                label: '# of Votes',
                data: voteCounts,
                backgroundColor: [
                    'rgba(255, 99, 132, 0.2)',
                    'rgba(54, 162, 235, 0.2)',
                    'rgba(255, 206, 86, 0.2)',
                    'rgba(75, 192, 192, 0.2)',
                    'rgba(153, 102, 255, 0.2)',
                    'rgba(255, 159, 64, 0.2)'
                ],
                borderColor: [
                    'rgba(255, 99, 132, 1)',
                    'rgba(54, 162, 235, 1)',
                    'rgba(255, 206, 86, 1)',
                    'rgba(75, 192, 192, 1)',
                    'rgba(153, 102, 255, 1)',
                    'rgba(255, 159, 64, 1)'
                ],
                borderWidth: 1
            }]
        },
        options: {
            scales: {
                yAxes: [{
                    ticks: {
                        beginAtZero: true
                    }
                }]
            }
        }
    })
}
function displayResults ( ) { var voteCounts = [ ] ; for ( var i = 0 ; i < allProducts . length ; i ++ ) { voteCounts . push ( allProducts [ i ] . clicks ) ; } var ctx = document . getElementById ( 'myChart' ) . getContext ( '2d' ) ; var myChart = new Chart ( ctx , { type : 'bar' , data : { labels : productNames , datasets : [ { label : '# of Votes' , data : voteCounts , backgroundColor : [ 'rgba(255, 99, 132, 0.2)' , 'rgba(54, 162, 235, 0.2)' , 'rgba(255, 206, 86, 0.2)' , 'rgba(75, 192, 192, 0.2)' , 'rgba(153, 102, 255, 0.2)' , 'rgba(255, 159, 64, 0.2)' ] , borderColor : [ 'rgba(255, 99, 132, 1)' , 'rgba(54, 162, 235, 1)' , 'rgba(255, 206, 86, 1)' , 'rgba(75, 192, 192, 1)' , 'rgba(153, 102, 255, 1)' , 'rgba(255, 159, 64, 1)' ] , borderWidth : 1 } ] } , options : { scales : { yAxes : [ { ticks : { beginAtZero : true } } ] } } } ) }
creates a list with the results of click votes
creates a list with the results of click votes
//     var results = document.getElementById('results'); //     var ul = document.createElement('ul'); //     for(var i = 0; i < allProducts.length; i++){ //       var product = allProducts[i]; //       var li = document.createElement('li'); //       li.textContent = product.name + ' has ' + product.clicks + ' votes.'; //       ul.appendChild(li); //     } //     results.appendChild(ul); //   } //chart.js //////////////////////////////////////////////////////////////// ///where i initially thought storage goes ////////////////////////////////////////////////// // localStorage.setItem('voteCounts', JSON.stringify(voteCounts)); // localStorage.setItem('productNames', JSON.stringify(productNames));    // localStorage.getItem('voteCounts'); // console.log(localStorage) // var saveData = localStorage.getItem('voteCounts');