<div class="chart">
  <canvas id="<%= chart_id %>" width="<%= canvas_width %>" height="<%= canvas_height %>"></canvas>
</div>
<script>
new Chart(document.getElementById('<%= chart_id %>').getContext('2d'),
{
  type: 'bar',
  data: {
    datasets: <%= JSON.generate(data_sets) %>
  },
  options: {
    title: {
      display: true,
      text:    "Work that is blocked or stalled"
    },
    responsive: true, // If responsive is true then it fills the screen
    scales: {
      x: {
        type: 'time',
        time: {
          unit: 'day'
        },
        stacked: true,
        grid: {
          color: <%= CssVariable['--grid-line-color'].to_json %>
        },
      },
      y: {
        stacked: true,
        scaleLabel: {
          display: true,
          labelString: 'WIP'
        },
        title: {
          display: true,
          text: 'Count of items'
        },
        grid: {
          color: <%= CssVariable['--grid-line-color'].to_json %>
        },
      }
    },
    plugins: {
      tooltip: {
        callbacks: {
          label: function(context) {
            return context.dataset.data[context.dataIndex].title
          }
        }
      },
      annotation: {
        annotations: {
          <%= working_days_annotation %>
        }
      },
      legend: {
        labels: {
          filter: function(item, chart) {
            // Logic to remove a particular legend item goes here
            return !item.text.includes('Trendline');
          }
        }
      }
    }
  }
});
</script>
