<div class="chart">
  <canvas id="<%= chart_id %>" width="<%= canvas_width %>" height="<%= canvas_height %>"></canvas>
</div>
<script>
const expedited = (ctx, value) => ctx.p0.raw.expedited == 1 ? value : undefined;
const notExpedited = (ctx, value) => ctx.p0.raw.expedited == 0 ? value : undefined;

new Chart(document.getElementById('<%= chart_id %>').getContext('2d'), {
  type: 'scatter',
  data: {
    datasets: <%= JSON.generate(data_sets) %>
  },
  options: {
    title: {
      display: true,
      text: "Cycletime Scatterplot"
    },
    responsive: <%= canvas_responsive? %>, // If responsive is true then it fills the screen
    scales: {
      x: {
        type: "time",
        scaleLabel: {
          display: true,
          labelString: 'Date Completed'
        },
        min: "<%= date_range.begin.to_s %>",
        max: "<%= date_range.end.to_s %>",
        grid: {
          color: <%= CssVariable['--grid-line-color'].to_json %>
        },
      },
      y: {
        scaleLabel: {
          display: true,
          labelString: 'Days'
        },
        title: {
          display: true,
          text: 'Age in days'
        },        
        min: 0,
        grid: {
          color: <%= CssVariable['--grid-line-color'].to_json %>
        },
      }
    },
    plugins: {
      tooltip: {
        callbacks: {
          label: function(context) {
            return context.dataset.data[context.dataIndex].title
          }
        }
      },
      autocolors: false,
      annotation: {
        annotations: {
          <%= working_days_annotation %>
        }
      }
    }
  }
});
</script>