Chartjs-React-chartjs-2: How to display timeline of released dates over 5 past years in Bar Chart?

2👍

Not sure the result you are looking for, but the following code will generate a graph with a bar for each year that was released.

const labels = ["2018", "2019", "2020", "2021", "2022"];

export const data = {
  labels,
  datasets: [
    {
      label: "Released",
      data: products.map(p => p.status === "released" ? 1:0),
      backgroundColor: "rgba(255, 99, 132, 0.5)"
    }
  ]
};

export function App() {
  return <Bar options={options} data={data} />;
}

Leave a comment