Move the graph to the center of the viewport
fitCenter(animation?: ViewportAnimationEffectTiming): Promise<void>;
Parameter | Type | Description |
---|---|---|
animation | 动画配置 |
Returns:
Zoom the graph to fit the viewport and move it to the center of the viewport
fitView(options?: FitViewOptions, animation?: ViewportAnimationEffectTiming): Promise<void>;
Parameter | Type | Description |
---|---|---|
options | 适配配置 | |
animation | 动画配置 |
Returns:
Get the viewport coordinates of the viewport center
getCanvasCenter(): Point;
Returns:
Type: [number, number] | [number, number, number] | Float32Array
Description: 视口中心的视口坐标
Get the position of the graph
getPosition(): Point;
That is, the position of the canvas origin in the viewport coordinate system. By default, the position of the graph is [0, 0]
Returns:
Type: [number, number] | [number, number, number] | Float32Array
Description: 图的位置
Get the current rotation angle
getRotation(): number;
Returns:
Type: number
Description: 旋转角度
Get the canvas coordinates of the viewport center
getViewportCenter(): Point;
Returns:
Type: [number, number] | [number, number, number] | Float32Array
Description: 视口中心的画布坐标
Get the current zoom ratio
getZoom(): number;
Returns:
Type: number
Description: 缩放比例
Get the zoom range of the current graph
getZoomRange(): GraphOptions['zoomRange'];
Returns:
Type: ['zoomRange']
Description: 缩放区间
Resize the canvas to the size of the graph container
resize(): void;
Resize the canvas to the specified width and height
resize(width: number, height: number): void;
Parameter | Type | Description |
---|---|---|
width | number | 宽度 |
height | number | 高度 |
Returns:
Rotate based on the current rotation angle (relative rotation)
rotateBy(angle: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void>;
Parameter | Type | Description |
---|---|---|
angle | number | 旋转角度 |
animation | 动画配置 | |
origin | [number, number] | [number, number, number] | Float32Array | 旋转中心(视口坐标) |
Returns:
Rotate the canvas to the specified angle (absolute rotation)
rotateTo(angle: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void>;
Parameter | Type | Description |
---|---|---|
angle | number | 目标角度 |
animation | 动画配置 | |
origin | [number, number] | [number, number, number] | Float32Array | 旋转中心(视口坐标) |
Returns:
Get the zoom range of the current graph
setZoomRange(zoomRange: GraphOptions['zoomRange']): void;
Parameter | Type | Description |
---|---|---|
zoomRange | ['zoomRange'] | 缩放区间 |
Returns:
Translate the graph by the specified distance (relative translation)
translateBy(offset: Point, animation?: ViewportAnimationEffectTiming): Promise<void>;
Parameter | Type | Description |
---|---|---|
offset | [number, number] | [number, number, number] | Float32Array | 偏移量 |
animation | 动画配置 |
Returns:
Translate the graph to the specified position (absolute translation)
translateTo(position: Point, animation?: ViewportAnimationEffectTiming): Promise<void>;
Parameter | Type | Description |
---|---|---|
position | [number, number] | [number, number, number] | Float32Array | 指定位置 |
animation | 动画配置 |
Returns:
Zoom based on the current zoom ratio (relative zoom)
zoomBy(ratio: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void>;
Parameter | Type | Description |
---|---|---|
ratio | number | 缩放比例 |
animation | 动画配置 | |
origin | [number, number] | [number, number, number] | Float32Array | 缩放中心(视口坐标) |
Returns:
Zoom the canvas to the specified ratio (absolute zoom)
zoomTo(zoom: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void>;
Parameter | Type | Description |
---|---|---|
zoom | number | 指定缩放比例 |
animation | 动画配置 | |
origin | [number, number] | [number, number, number] | Float32Array | 缩放中心(视口坐标) |
Returns: