添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
// Zoom out to 0.5x with animation
graph . zoomTo ( 0.5 , {
duration : 500 ,
easing : 'ease' ,
} ) ;
// Zoom in with the viewport center as the origin
graph . zoomTo ( 1.5 , false , graph . getCanvasCenter ( ) ) ;

Graph.zoomBy(ratio, animation, origin)

Zoom based on the current zoom scale (relative zoom).

zoomBy(ratio: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void>;

Parameters

Parameter Description Type Default Required
ratio Zoom ratio (>1 zoom in, <1 zoom out) number -
animation Animation configuration ViewportAnimationEffectTiming -
origin Zoom center point (viewport coordinates) Point -

Example

// Zoom in by 1.2x based on the current scale
graph.zoomBy(1.2);
// Zoom out to 0.8x based on the current scale with animation
graph.zoomBy(0.8, {
duration: 300,
});

Graph.translateTo(position, animation)

Pan the graph to a specified position (absolute pan).

translateTo(position: Point, animation?: ViewportAnimationEffectTiming): Promise<void>;

Parameters

Parameter Description Type Default Required
position Target position coordinates Point -
animation Animation configuration ViewportAnimationEffectTiming -

Example

// Pan to a specified position
graph.translateTo([100, 100]);
// Pan with animation
graph.translateTo([200, 200], {
duration: 1000,
easing: 'ease-in-out',
});

Graph.translateBy(offset, animation)

Pan the graph by a specified distance relative to the current position (relative pan).

translateBy(offset: Point, animation?: ViewportAnimationEffectTiming): Promise<void>;

Parameters

Parameter Description Type Default Required
offset Pan offset Point -
animation Animation configuration ViewportAnimationEffectTiming -

Example

// Pan right by 100 pixels and down by 50 pixels
graph.translateBy([100, 50]);
// Relative pan with animation
graph.translateBy([-50, -50], {
duration: 500,
});

Graph.rotateTo(angle, animation, origin)

Rotate the canvas to a specified angle (absolute rotation).

rotateTo(angle: number, animation?: ViewportAnimationEffectTiming, origin?: Point): Promise<void>;

Parameters

Parameter Description Type Default Required
angle Target rotation angle (radians) number -
animation Animation configuration ViewportAnimationEffectTiming -
origin Rotation center point (viewport coordinates) Point -

Example

// Rotate to 45 degrees
graph.rotateTo(Math.PI / 4);