Chartjs-Add rectangle fill to line chart

1👍

managed to do this with following code:

const plugins = [
  {
   beforeDraw: (chartInstance, easing) => {
   const ctx = chartInstance.chart.ctx;
   ctx.fillStyle = "lightgreen";
   ctx.fillRect(30, 200, 955, 50);
  },
 },
];
//...
<Line
    data={data}
    plugins={plugins}
  />

0👍

You can draw it before the Line chart with drawTime: 'beforeDatasetsDraw'

Leave a comment