//import Chart from 'chart.js/auto'
//import { getAquisitionsByYear } from '../src/api.js';

//const data = await getAquisitionsByYear();

(async function() {
  const data = [
    { year: 2010, count: 10 },
    { year: 2011, count: 20 },
    { year: 2012, count: 15 },
    { year: 2013, count: 25 },
    { year: 2014, count: 22 },
    { year: 2015, count: 30 },
    { year: 2016, count: 28 },
  ];
  //const data = await getAquisitionsByYear();

  new Chart(
    document.getElementById('acquisitions'),
    {
      type: 'bar',
      options: {
        scales: {
            y: { beginAtZero: true }
        },
          animation: false,
          plugins: {
            legend: {
                display: true
            },
            tooltip: {
                enabled: true
            }
          }
      },
      
      data: {
        labels: data.map(row => row.year),
        datasets: [
          {
            label: 'Acquisitions by year',
            data: data.map(row => row.count),
            //indexAxis: 'y',
            fill: {
                target: '20',
                above: 'rgb(255,0,0)',
                below: 'rgb(0,255,0)'
            }
          }
        ]
      } 
    }
  );
})();
 