| 1 |
/** |
| 2 |
* @typedef { import('../core/core.controller.js').default } Chart |
| 3 |
*/ |
| 4 |
/** |
| 5 |
* Abstract class that allows abstracting platform dependencies away from the chart. |
| 6 |
*/ |
| 7 |
export default class BasePlatform { |
| 8 |
/** |
| 9 |
* Called at chart construction time, returns a context2d instance implementing |
| 10 |
* the [W3C Canvas 2D Context API standard]{@link https://www.w3.org/TR/2dcontext/}. |
| 11 |
* @param {HTMLCanvasElement} canvas - The canvas from which to acquire context (platform specific) |
| 12 |
* @param {number} [aspectRatio] - The chart options |
| 13 |
*/ |
| 14 |
acquireContext(canvas: HTMLCanvasElement, aspectRatio?: number): void; |
| 15 |
/** |
| 16 |
* Called at chart destruction time, releases any resources associated to the context |
| 17 |
* previously returned by the acquireContext() method. |
| 18 |
* @param {CanvasRenderingContext2D} context - The context2d instance |
| 19 |
* @returns {boolean} true if the method succeeded, else false |
| 20 |
*/ |
| 21 |
releaseContext(context: CanvasRenderingContext2D): boolean; |
| 22 |
/** |
| 23 |
* Registers the specified listener on the given chart. |
| 24 |
* @param {Chart} chart - Chart from which to listen for event |
| 25 |
* @param {string} type - The ({@link ChartEvent}) type to listen for |
| 26 |
* @param {function} listener - Receives a notification (an object that implements |
| 27 |
* the {@link ChartEvent} interface) when an event of the specified type occurs. |
| 28 |
*/ |
| 29 |
addEventListener(chart: Chart, type: string, listener: Function): void; |
| 30 |
/** |
| 31 |
* Removes the specified listener previously registered with addEventListener. |
| 32 |
* @param {Chart} chart - Chart from which to remove the listener |
| 33 |
* @param {string} type - The ({@link ChartEvent}) type to remove |
| 34 |
* @param {function} listener - The listener function to remove from the event target. |
| 35 |
*/ |
| 36 |
removeEventListener(chart: Chart, type: string, listener: Function): void; |
| 37 |
/** |
| 38 |
* @returns {number} the current devicePixelRatio of the device this platform is connected to. |
| 39 |
*/ |
| 40 |
getDevicePixelRatio(): number; |
| 41 |
/** |
| 42 |
* Returns the maximum size in pixels of given canvas element. |
| 43 |
* @param {HTMLCanvasElement} element |
| 44 |
* @param {number} [width] - content width of parent element |
| 45 |
* @param {number} [height] - content height of parent element |
| 46 |
* @param {number} [aspectRatio] - aspect ratio to maintain |
| 47 |
*/ |
| 48 |
getMaximumSize(element: HTMLCanvasElement, width?: number, height?: number, aspectRatio?: number): { |
| 49 |
width: number; |
| 50 |
height: number; |
| 51 |
}; |
| 52 |
/** |
| 53 |
* @param {HTMLCanvasElement} canvas |
| 54 |
* @returns {boolean} true if the canvas is attached to the platform, false if not. |
| 55 |
*/ |
| 56 |
isAttached(canvas: HTMLCanvasElement): boolean; |
| 57 |
/** |
| 58 |
* Updates config with platform specific requirements |
| 59 |
* @param {import('../core/core.config.js').default} config |
| 60 |
*/ |
| 61 |
updateConfig(config: import('../core/core.config.js').default): void; |
| 62 |
} |
| 63 |
export type Chart = import('../core/core.controller.js').default; |