[Chartjs]-Add a gradient background to react-chartjs-2

2👍

You will need to use a scriptable function for the backgroundColor which contains the chart which contains the context like so:

const data = {
  labels: labels,
  datasets: [
    {
      data: chartData, 
      fill: true,
      backgroundColor: ({chart: {ctx}}) => {
        const bg = ctx.createLinearGradient(paramters);
        // More config for your gradient
        return bg;
      }
    },
  ],
};

Leave a comment