ShapeStorage()

new ShapeStorage()

管理shape类

Methods

eachShape(func)

遍历shape

Parameters:
Name Type Description
func function

遍历函数

getShape(name, keyopt) → {Object}

根据name获取通过setShape或setShapeGroup方法设置的shape

Parameters:
Name Type Attributes Description
name string
key string <optional>

仅在shape为Group时有效

Returns:
Object -

shape | shapeGroup

remove()

移除全部

removeShape(name)

移除指定的shape

Parameters:
Name Type Description
name string

set(name, shape) → {Object}

直接设置shape

Parameters:
Name Type Description
name string
shape Object
Returns:
Object -

shape

setShape(name, Shape, shapeAttr, animateOption, initCallback) → {Object}

设置单个shape,若不存在则创建,若存在则更新

Parameters:
Name Type Description
name string

存储的名字

Shape Object

要创建的Shape类

shapeAttr Object

要创建shape的相关属性attr

animateOption Object

动画相关属性

Properties
Name Type Attributes Description
animation boolean <optional>

是否动画

animateFrom Object <optional>

动画起始状态属性,

duration number <optional>

动画时长

easing string | function <optional>

动画类型

animateList Object <optional>

要过渡的动画属性列表

initCallback function

初始化shape的回调

Returns:
Object -

shape

setShapeGroup(name, Shape, shapeAttrArray, animateOption, initCallback, createCallback) → {Object}

设置一组shape,根据所设置的key创建新或移除

Parameters:
Name Type Description
name String

存储的名字

Shape Object

要创建的Shape类

shapeAttrArray Array

要创建shape的相关属性attr数组,!!!若需要动画,需指定每个shape的唯一key,以对对应的shape添加过渡动画!!!

animateOption Object

动画相关属性

Properties
Name Type Attributes Description
animation boolean <optional>

是否动画

animateFrom Object <optional>

动画起始状态属性,

duration number <optional>

动画时长

easing string | function <optional>

动画类型

animateList Object <optional>

要过渡的动画属性列表

animateLeave Object <optional>

remove时动画属性列表

initCallback function

shapeGroup创建时的回调

createCallback function

shapeGroup内新增shape时的回调

Returns:
Object -

shapeGroup