graphThemeLayer Class

graphThemeLayer(name, chartsType, options)

统计专题图层。

Fx构造函数

# new graphThemeLayer(name, chartsType, options)

参数:
名称 类型 属性 默认值 描述
name string

图层名。

chartsType string

图表类别。

options Object

参数。

id string <optional>

专题图层 ID。

loadWhileAnimating boolean <optional>
true

是否实时重绘。

map mapboxgl.Map

当前mapboxgl map对象。

opacity number <optional>
1

图层透明度。

themeFields string

指定创建专题图字段。

isOverLay boolean <optional>
true

是否进行压盖处理,如果设为 true,图表绘制过程中将隐藏对已在图层中绘制的图表产生压盖的图表。

chartsType string <optional>

图表类型。目前可用:"Bar", "Line", "Pie"。

chartsSetting Object

符号 Circle 配置对象。

chartsSetting.codomain Array.<number>

图表允许展示的数据值域,长度为 2 的一维数组,第一个元素表示值域下限,第二个元素表示值域上限。

chartsSetting.maxR number <optional>

圆形的最大半径。

chartsSetting.minR number <optional>

圆形的最小半径。

chartsSetting.fillColor string

圆形的填充色,如:fillColor: "#FFB980"。

chartsSetting.circleStyle Object

圆形的基础 style,此参数控制圆形基础样式,优先级低于 circleStyleByFields 和 circleStyleByCodomain。

chartsSetting.decimalNumber number

数据值数组 dataValues 元素值小数位数,数据的小数位处理参数,取值范围:[0, 16]。如果不设置此参数,在取数据值时不对数据做小数位处理。

chartsSetting.circleHoverStyle Object

圆形 hover 状态时的样式,circleHoverAble 为 true 时有效。

chartsSetting.circleHoverAble boolean <optional>
true

是否允许圆形使用 hover 状态。同时设置 circleHoverAble 和 circleClickAble 为 false,可以直接屏蔽图形对专题图层事件的响应。

chartsSetting.circleClickAble boolean <optional>
true

是否允许圆形被点击。同时设置 circleHoverAble 和 circleClickAble 为 false,可以直接屏蔽图形对专题图层事件的响应。

查看源代码 mapboxgl/theme/GraphThemeLayer.js, line 8

  • Zondy.Map.graphThemeLayer#event:beforefeaturesadded

继承关系

成员变量

string

# id Optional

专题图图层 id。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 31

boolean

# loadWhileAnimating Optional

是否实时重绘。(当绘制大数据量要素的情况下会出现卡顿,建议把该参数设为 false)。

Inherited From:
Default Value:
  • true

查看源代码 mapboxgl/theme/ThemeLayer.js, line 48

mapboxgl.Map

# map

map 对象。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 54

string

# name

专题图图层名称。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 25

float

# opacity Optional

图层透明度。

Inherited From:
Default Value:
  • 1

查看源代码 mapboxgl/theme/ThemeLayer.js, line 36

boolean

# visibility Optional

图层是否可见。

Inherited From:
Default Value:
  • true

查看源代码 mapboxgl/theme/ThemeLayer.js, line 42

方法

# addFeatures(features)

向专题图图层中添加数据,支持的 feature 类型为:iServer 返回的 feature JSON 对象。

参数:
名称 类型 描述
features Object

待添加的要素。

Overrides:

查看源代码 mapboxgl/theme/GraphThemeLayer.js, line 59

# clear()

清除的内容包括数据(features) 、专题要素、缓存。

查看源代码 mapboxgl/theme/GraphThemeLayer.js, line 511

# createThematicFeature(feature)

向专题图图层中添加数据, 支持的 feature 类型为:iServer 返回的 feature json 对象。

参数:
名称 类型 描述
feature Object

待添加的要素。

查看源代码 mapboxgl/theme/GraphThemeLayer.js, line 154

# destroyFeatures(features)

销毁某个要素。

参数:
名称 类型 描述
features Zondy.Feature.Vector

将被销毁的要素。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 128

# display(displayopt)

临时隐藏或者显示图层。通过对 CSS 控制产生即时效果,重新渲染失效。一般用 setVisibility 方法来动态控制图层的显示和隐藏。

参数:
名称 类型 属性 描述
display boolean <optional>

是否显示图层。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 159

# drawCharts()

绘制图表。包含压盖处理。

查看源代码 mapboxgl/theme/GraphThemeLayer.js, line 186

# getFeatureBy(property, value) → {Zondy.Feature.Vector}

在专题图的要素数组 features 里面遍历每一个 feature,当 feature[property] === value 时, 返回此 feature(并且只返回第一个)。

参数:
名称 类型 描述
property string

feature 的某个属性名称。

value string

property 所对应的值。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 287

第一个匹配属性和值的矢量要素。

Zondy.Feature.Vector

# getFeatureById(featureId) → {Zondy.Feature.Vector}

通过给定一个 id,返回对应的矢量要素。

参数:
名称 类型 描述
featureId string

矢量要素的属性 id。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 306

对应 id 的 feature,如果不存在则返回 null。

Zondy.Feature.Vector

# getFeatures() → {Zondy.Feature.Vector}

查看当前图层中的有效数据。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 273

用户加入图层的有效数据。

Zondy.Feature.Vector

# getFeaturesByAttribute(attrName, attrValue) → {Array.<Zondy.Feature.Vector>}

通过给定一个属性的 key 值和 value 值,返回所有匹配的要素数组。

参数:
名称 类型 描述
attrName string

属性的 key。

attrValue string

矢量要素的属性 id。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 316

一个匹配的 feature 数组。

Array.<Zondy.Feature.Vector>

# getLocalXY(coordinateopt)

地理坐标转为像素坐标。

参数:
名称 类型 属性 描述
coordinate Object <optional>

坐标位置。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 411

# getShapesByFeatureID(featureID)

通过 FeatureID 获取 feature 关联的所有图形。如果不传入此参数,函数将返回所有图形。

参数:
名称 类型 描述
featureID number

要素 ID。

查看源代码 mapboxgl/theme/GraphThemeLayer.js, line 308

# isChartInMap(mapPxBounds, chartPxBounds)

判断图表是否在地图里。

参数:
名称 类型 描述
mapPxBounds Zondy.Bounds

地图像素范围。

chartPxBounds Array.<Object>

图表范围的四边形节点数组。

查看源代码 mapboxgl/theme/GraphThemeLayer.js, line 445

# isPointInPoly(pt, poly)

判断一个点是否在多边形里面。(射线法)

参数:
名称 类型 描述
pt Object

需要判定的点对象,该对象含有属性 x (横坐标),属性 y (纵坐标)。

poly Array.<Object>

多边形节点数组。

查看源代码 mapboxgl/theme/GraphThemeLayer.js, line 426

# isQuadrilateralOverLap(quadrilateral, quadrilateral2)

判断两个四边形是否有压盖。

参数:
名称 类型 描述
quadrilateral Array.<Object>

四边形节点数组。

quadrilateral2 Array.<Object>

第二个四边形节点数组。

查看源代码 mapboxgl/theme/GraphThemeLayer.js, line 328

# moveTo(layerID, beforeopt)

将图层移动到某个图层之前。

参数:
名称 类型 属性 默认值 描述
layerID string

待插入的图层 ID。

before boolean <optional>
true

是否将本图层插入到图层 id 为 layerID 的图层之前(如果为 false 则将本图层插入到图层 id 为 layerID 的图层之后)。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 541

# off(event, callback, context)

移除专题要素事件监听。

参数:
名称 类型 描述
event Event

监听事件。

callback function

回调函数。

context string

信息。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 363

# on(event, callback, context)

添加专题要素事件监听。添加专题要素事件监听。

参数:
名称 类型 描述
event Event

监听事件。

callback function

回调函数。

context string

信息。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 346

# onAdd()

向底图添加该图层。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 69

# redrawThematicFeatures(extent)

重绘所有专题要素。 此方法包含绘制专题要素的所有步骤,包含用户数据到专题要素的转换,抽稀,缓存等步骤。 地图漫游时调用此方法进行图层刷新。

参数:
名称 类型 描述
extent mapboxgl.LngLatBounds

重绘的范围。

Overrides:

查看源代码 mapboxgl/theme/GraphThemeLayer.js, line 98

# refresh()

强制刷新当前热点显示,在图层热点数组发生变化后调用,更新显示。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 94

# removeFeatures(features)

从专题图中删除 feature。这个函数删除所有传递进来的矢量要素。参数中的 features 数组中的每一项,必须是已经添加到当前图层中的 feature。

参数:
名称 类型 描述
features Zondy.Feature.Vector

要删除的要素。

Overrides:

查看源代码 mapboxgl/theme/GraphThemeLayer.js, line 479

# setChartsType(chartsTypeopt)

设置图表类型,此函数可动态改变图表类型。在调用此函数前请通过 chartsSetting 为新类型的图表做相关配置。

参数:
名称 类型 属性 描述
chartsType string <optional>

图表类型。目前可用:"Bar", "Line", "Pie"。

查看源代码 mapboxgl/theme/GraphThemeLayer.js, line 49

# setOpacity(opacityopt)

设置图层的不透明度,取值[0-1]之间。

参数:
名称 类型 属性 描述
opacity number <optional>

不透明度。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 168

# setVisibility(visibilityopt)

设置图层可见性,设置图层的隐藏,显示,重绘的相应的可见标记。

参数:
名称 类型 属性 描述
visibility boolean <optional>

是否显示图层(当前地图的 resolution 在最大最小 resolution 之间)。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 146

事件

# changelayer

图层属性改变之后触发。

属性:
Name Type Description
layer Object

图层。

property string

被改变的属性。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 180

# featuresremoved

要素删除之后触发。

属性:
Name Type Description
features Array.<Zondy.Feature.Vector>

未被成功删除的要素。

succeed boolean

删除成功与否。

Inherited From:

查看源代码 mapboxgl/theme/ThemeLayer.js, line 246