[Chartjs]-How to populate a chart with data coming from API?

2👍

Read carefully the documentation and notice how the data prop of the Bar component is of type Object while you are feeding it with Array.

Follow the example from the documentation and use a Vuex getter instead of directly reading the state in order to generate the right data format:

const getters = {
  getAllSales(state)
  {
    return {
      labels: [ 'January', 'February', 'March'],
      datasets: [
        {
          label: 'Data One',
          backgroundColor: '#F87979',
          data: state.allSales,
        }
      ]
    };
  },
};

Leave a comment