import type {ChartArea, Scale} from '../types/index.js';
-import type Chart from '../core/core.controller.js';
-import type {ChartEvent} from '../types.js';
+import type PrivateChart from '../core/core.controller.js';
+import type {Chart, ChartEvent} from '../types.js';
import {INFINITY} from './helpers.math.js';
-/**
- * Note: typedefs are auto-exported, so use a made-up `dom` namespace where
- * necessary to avoid duplicates with `export * from './helpers`; see
- * https://github.com/microsoft/TypeScript/issues/46011
- * @typedef { import('../core/core.controller.js').default } dom.Chart
- * @typedef { import('../../types').ChartEvent } ChartEvent
- */
-
/**
* @private
*/
export function getRelativePosition(
event: Event | ChartEvent | TouchEvent | MouseEvent,
- chart: Chart
+ chart: Chart | PrivateChart
): { x: number; y: number } {
if ('native' in event) {
return event;
* @returns True if the canvas context size or transformation has changed.
*/
export function retinaScale(
- chart: Chart,
+ chart: Chart | PrivateChart,
forceRatio: number,
forceStyle?: boolean
): boolean | void {
const deviceHeight = Math.floor(chart.height * pixelRatio);
const deviceWidth = Math.floor(chart.width * pixelRatio);
- chart.height = Math.floor(chart.height);
- chart.width = Math.floor(chart.width);
+ (chart as PrivateChart).height = Math.floor(chart.height);
+ (chart as PrivateChart).width = Math.floor(chart.width);
const canvas = chart.canvas;
if (chart.currentDevicePixelRatio !== pixelRatio
|| canvas.height !== deviceHeight
|| canvas.width !== deviceWidth) {
- chart.currentDevicePixelRatio = pixelRatio;
+ (chart as PrivateChart).currentDevicePixelRatio = pixelRatio;
canvas.height = deviceHeight;
canvas.width = deviceWidth;
chart.ctx.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);