import type { ChartComponentLike, Chart as ChartJS } from 'chart.js'; export type ChartCallback = (chartJS: typeof ChartJS) => void | Promise; export interface ChartJSNapiRSCanvasOptions { /** * The width of the charts to render, in pixels. */ readonly width: number; /** * The height of the charts to render, in pixels. */ readonly height: number; /** * Optional callback which is called once with a new ChartJS global reference as the only parameter. */ readonly chartCallback?: ChartCallback; /** * Optional canvas type ('PDF' or 'SVG'), see the [canvas pdf doc](https://github.com/Automattic/node-canvas#pdf-output-support). */ readonly type?: 'pdf' | 'svg'; /** * Optional plugins to register. */ readonly plugins?: ChartJSNapiRSCanvasPlugins; /** * Optional background color for the chart, otherwise it will be transparent. Note, this will apply to all charts. See the [fillStyle](https://www.w3schools.com/tags/canvas_fillstyle.asp) canvas API used for possible values. */ readonly backgroundColour?: string; } export type ChartJSNapiRSCanvasPlugins = { /** * Global plugins, see https://www.chartjs.org/docs/latest/developers/plugins.html. */ readonly modern?: ReadonlyArray; /** * This will work for plugins that `require` ChartJS themselves. */ readonly requireChartJSLegacy?: readonly string[]; /** * This should work for any plugin that expects a global Chart variable. */ readonly globalVariableLegacy?: readonly string[]; /** * This will work with plugins that just return a plugin object and do no specific loading themselves. */ readonly requireLegacy?: readonly string[]; };