util/graphic

图形相关函数

Methods

static extendPath()

Extend path

static extendShape()

Extend shape with parameters

static makePath(pathData, opts, rect, layoutopt)

Create a path element from path data string

Parameters:
Name Type Attributes Default Description
pathData string
opts Object
rect module:zrender/core/BoundingRect
layout string <optional>
cover

'center' or 'cover'

static resizePath(path, rect)

Resize a path to fit the rect

Parameters:
Name Type Description
path module:zrender/graphic/Path
rect Object

static setHoverStyle(el, hoverStyleopt, optopt)

Set hover style of element. This method can be called repeatly without side-effects.

Parameters:
Name Type Attributes Description
el module:zrender/Element
hoverStyle Object <optional>
opt Object <optional>
Properties
Name Type Attributes Default Description
hoverSilentOnTouch boolean <optional>
false

In touch device, mouseover event will be trigger on touchstart event (see module:zrender/dom/HandlerProxy). By this mechanism, we can conviniently use hoverStyle when tap on touch screen without additional code for compatibility. But if the chart/component has select feature, which usually also use hoverStyle, there might be conflict between 'select-highlight' and 'hover-highlight' especially when roam is enabled (see geo for example). In this case, hoverSilentOnTouch should be used to disable hover-highlight on touch device.

static subPixelOptimize(xOrY, lineWidth, positiveOrNegativeopt) → {number}

Sub pixel optimize for canvas

Parameters:
Name Type Attributes Description
xOrY number

Coordinate, such as x, y

lineWidth number

Should be nonnegative integer.

positiveOrNegative boolean <optional>

Default false (negative).

Returns:
number -

Optimized position.

static subPixelOptimizeLine(param) → {Object}

Sub pixel optimize line for canvas

Parameters:
Name Type Description
param Object
Properties
Name Type Attributes Description
shape Object <optional>
Properties
Name Type Attributes Description
x1 number <optional>
y1 number <optional>
x2 number <optional>
y2 number <optional>
style Object <optional>
Properties
Name Type Attributes Description
lineWidth number <optional>
Returns:
Object -

Modified param

static subPixelOptimizeRect(param) → {Object}

Sub pixel optimize rect for canvas

Parameters:
Name Type Description
param Object
Properties
Name Type Attributes Description
shape Object <optional>
Properties
Name Type Attributes Description
x number <optional>
y number <optional>
width number <optional>
height number <optional>
style Object <optional>
Properties
Name Type Attributes Description
lineWidth number <optional>
Returns:
Object -

Modified param

inner doEnterHover()

inner doSingleLeaveHover()

inner enterEmphasis()

inner leaveEmphasis()

inner onElementMouseOut()

inner onElementMouseOver()

inner setElementHoverStl()