{%extends 'base.html'%}
{%block head%}
<title>Graph</title>
{%endblock%}

{%block body%}

<div align='center'>
  <a href="http://localhost:8000/review/list/">
    <button class="button">
      <h3>
        Go to the list of Reviews
      </h3>
    </button>
  </a> <br>
</div>
{{data}}
<style>
  #graph {
    background-color: black;
  }

  button {
    width: 50%;
    background-color: #ffcc00;
    color: white;
    padding: 14px 20px;
    margin: 8px 0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
  }

  button:hover {
    background-color: #ff9933
  }
</style>
<div style="width: 100%" align='center' id="graph">
  <canvas id="myChart" width="100%" height="40%"></canvas>
  <script>
    var ctx = document.getElementById('myChart').getContext('2d');
    
    var tmdb_rating = parseFloat("{{data.tmdb_rating}}")
    var sentiment = parseFloat("{{data.sentiment}}")
    var IMDB = parseFloat("{{data.IMDB}}")
    var imt = parseFloat("{{data.imt}}")
    var proposed = parseFloat("{{data.proposed}}")

    // console.log(sentiment)
    var myChart = new Chart(ctx, {
      type: 'bar',

      data: {
        labels: ['based on TMDB data', 'based on web scraped data', 'actual IMDB rating', 'Using the trained model pkl', 'proposed rating'],
        datasets: [{
          label: 'points',
          data: [tmdb_rating, sentiment, IMDB, imt, proposed],
          backgroundColor: [
            'rgba(255, 0 , 0, 1)',
            'rgba(255, 127, 0, 1)',
            'rgba(0, 255, 0, 1)',
            'rgba(0, 0, 255, 1)',
            '#FF00CC',
            '#652DC1'
          ],
          borderColor: [
            'rgba(255, 0 , 0, 1)',
            'rgba(255, 127, 0, 1)',
            'rgba(0, 255, 0, 1)',
            'rgba(0, 0, 255, 1)',
            '#FF00CC',
            '#652DC1'
          ],
          borderWidth: 1
        }]
      },
      options: {
        scales: {
          yAxes: [{
            ticks: {
              beginAtZero: true
            }
          }]
        }
      }
    });
  </script>
</div>

{%endblock%}