Reputation: 2138
Is it possible to add draw a rectangle as a background of Line chart? I'm using react-chartjs-2 and cannot find any examples with drawing a canvas as background...
Upvotes: 0
Views: 813
Reputation: 2138
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}
/>
Upvotes: 1
Reputation: 632
You can draw it before the Line chart with drawTime: 'beforeDatasetsDraw'
Upvotes: 0