<!-- pass in chart label, data, labels -->
<canvas id="chart" width="400" height="200"></canvas>
<script>
function getGetOrdinal(n) {
  var s=["th","st","nd","rd"],
  v=n%100;
  return n+(s[(v-20)%10]||s[v]||s[0]);
}
function getPreviousDay(dd){
  var today = new Date();
  var previous = new Date(today);
  previous.setDate(today.getDate() - dd);
  return previous.getDate();
}
function initializeLineChart(apiData, labels){
  var data = {
    labels: labels,
    datasets: [
      {
        label: "{{ label }}",
        fill: false,
        lineTension: 0.25,
        backgroundColor: "rgba(75,192,192,0.4)",
        borderColor: "rgba(75,192,192,1)",
        borderCapStyle: 'butt',
        borderDash: [],
        borderDashOffset: 0.0,
        borderJoinStyle: 'miter',
        pointBorderColor: "rgba(75,192,192,1)",
        pointBackgroundColor: "#fff",
        pointBorderWidth: 1,
        pointHoverRadius: 5,
        pointHoverBackgroundColor: "rgba(75,192,192,1)",
        pointHoverBorderColor: "rgba(220,220,220,1)",
        pointHoverBorderWidth: 2,
        pointRadius: 1,
        pointHitRadius: 10,
        data: apiData,
        spanGaps: false,
      }
    ]
  };
  var lineChart = new Chart(document.getElementById("chart"), {
    type: 'line',
    data: data,
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero: true,
                    stepSize: 1
                }
            }]
        }
    }
  });
}
(function createChart(){
    var labels = {{ labels }};
    for(var j=0; j<labels.length; j++){
      labels[j] = getGetOrdinal(labels[j]);
    }
    initializeLineChart({{ data }}, labels);
})();
</script>
