# Mirror

Use scriptable options to mirror the anchor, align and rotation options around the horizontal scale origin.

{
  type: 'bar',
  data: {
    labels: labels,
    datasets: [{
      backgroundColor: Utils.color(0),
      borderColor: Utils.color(0),
      data: Utils.numbers({
        count: DATA_COUNT,
        min: -100,
        max: 100
      })
    }]
  },
  options: {
    plugins: {
      datalabels: {
        align: function(context) {
          var value = context.dataset.data[context.dataIndex];
          return value > 0 ? 'end' : 'start';
        },
        anchor: function(context) {
          var value = context.dataset.data[context.dataIndex];
          return value > 0 ? 'end' : 'start';
        },
        borderRadius: 4,
        color: 'white',
        rotation: function(context) {
          var value = context.dataset.data[context.dataIndex];
          return value > 0 ? 45 : 180 - 45;
        },
        backgroundColor: function(context) {
          return context.dataset.backgroundColor;
        },
        formatter: Math.round,
        padding: 6,
      }
    },

    // Core options
    aspectRatio: 5 / 3,
    layout: {
      padding: {
        top: 32,
        right: 24,
        bottom: 24,
        left: 0
      }
    },
    elements: {
      line: {
        fill: false,
        tension: 0.4
      },
      point: {
        hoverRadius: 7,
        radius: 5
      }
    },
  },
}