import type { Cursor, IRenderer } from '@antv/g'; import type { Canvas, CanvasConfig } from '../runtime/canvas'; /** * 画布配置项 * * Canvas spec * @public */ export interface CanvasOptions { /** * 画布容器 * * canvas container */ container?: string | HTMLElement | Canvas; /** * 画布宽度 * * canvas width * @remarks * 如果未设置,则会自动获取容器宽度 * * If not set, the container width will be automatically obtained */ width?: number; /** * 画布高度 * * canvas height * @remarks * 如果未设置,则会自动获取容器高度 * * If not set, the container height will be automatically obtained */ height?: number; /** * 手动置顶渲染器 * * manually set renderer * @remarks * G6 采用了分层渲染的方式,分为 background、main、label、transient 四层,用户可以通过该配置项分别设置每层画布的渲染器 * * G6 adopts a layered rendering method, divided into four layers: background, main, label, transient. Users can set the renderer of each layer canvas separately through this configuration item */ renderer?: (layer: 'background' | 'main' | 'label' | 'transient') => IRenderer; /** * 是否自动调整画布大小 * * whether to auto resize canvas * @defaultValue false * @remarks * 基于 window.onresize 事件自动调整画布大小 * * Automatically adjust the canvas size based on the window.onresize event */ autoResize?: boolean; /** * 画布背景色 * * canvas background color * @remarks * 该颜色作为导出图片时的背景色 * * This color is used as the background color when exporting images */ background?: string; /** * 设备像素比 * * device pixel ratio * @remarks * 用于高清屏的设备像素比,默认为 [window.devicePixelRatio](https://developer.mozilla.org/zh-CN/docs/Web/API/Window/devicePixelRatio) * * Device pixel ratio for high-definition screens, default is [window.devicePixelRatio](https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio) */ devicePixelRatio?: number; /** * 指针样式 * * cursor style */ cursor?: Cursor; /** * 画布配置 * * canvas config * @remarks * GraphOptions 下相关配置项为快捷配置项,会被转换为 canvas 配置项 * * The related configuration items under GraphOptions are shortcut configuration items, which will be converted to canvas configuration items */ canvas?: CanvasConfig; }