# Highlight

Listen for mouse enter and leave events to modify the label style using scriptable options.

{
  type: 'line',
  data: {
    labels: labels,
    datasets: [{
      backgroundColor: Utils.color(0),
      borderColor: Utils.color(0),
      data: Utils.numbers({
        count: DATA_COUNT,
        min: 0,
        max: 100
      }),
      datalabels: {
        align: 'start'
      }
    }, {
      backgroundColor: Utils.color(1),
      borderColor: Utils.color(1),
      data: Utils.numbers({
        count: DATA_COUNT,
        min: 0,
        max: 100
      })
    }, {
      backgroundColor: Utils.color(2),
      borderColor: Utils.color(2),
      data: Utils.numbers({
        count: DATA_COUNT,
        min: 0,
        max: 100
      }),
      datalabels: {
        align: 'end'
      }
    }]
  },
  options: {
    plugins: {
      datalabels: {
        backgroundColor: function(context) {
          return context.hovered ? context.dataset.backgroundColor : 'white';
        },
        borderColor: function(context) {
          return context.dataset.backgroundColor;
        },
        borderRadius: 16,
        borderWidth: 3,
        color: function(context) {
          return context.hovered ? 'white' : context.dataset.backgroundColor;
        },
        font: {
          weight: 'bold'
        },
        offset: 8,
        formatter: Math.round,
        listeners: {
          enter: function(context) {
            context.hovered = true;
            return true;
          },
          leave: function(context) {
            context.hovered = false;
            return true;
          }
        }
      }
    },
    // Core options
    aspectRatio: 5 / 3,
    layout: {
      padding: {
        top: 42,
        right: 16,
        bottom: 16,
        left: 8
      }
    },
    elements: {
      line: {
        fill: false,
        tension: 0.4
      }
    },
    scales: {
      y: {
        stacked: true
      }
    }
  }
}