sf-i-events
Version:
Superflows Navigation Component
18 lines (14 loc) • 543 B
text/typescript
import { Plugin } from 'chart.js';
import { ExportBackgroundOptions } from './types/chartjs-plugins'; // adjust path
export const exportBackgroundPlugin: Plugin = {
id: 'exportBackground',
beforeDraw: (chart, _args, options?: ExportBackgroundOptions) => {
if (!options?.exporting) return;
const { ctx, width, height } = chart;
ctx.save();
ctx.globalCompositeOperation = 'destination-over';
ctx.fillStyle = options.color || '#ffffff';
ctx.fillRect(0, 0, width, height);
ctx.restore();
}
};