# new ThemeManager(viewer, options)
统计图
参数:
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
viewer |
Object | 场景视图对象,详见Cesium.Viewer |
|
options |
Object | 附加参数 |
|
queryUrl |
String | null | 用于查询的url |
successCallback |
function | null | 成功回调函数 |
errorCallback |
function | null | 错误回调函数 |
material |
Object | null | 材质 |
width |
Number | 5000 | 显示柱状体或饼状的宽度 |
heightScale |
Number | 1 | 设置柱状图的高度缩放比例 |
addExtrudedHeight |
Boolean | false | 是否为饼状体添加高度 |
addGeoGeometry |
Boolean | false | 解析GeoJson数据时,是否绘制polygon的Geometry |
attributeName |
Array | [] | 用于显示的属性名 |
attributeColor |
Array | [] | 各个属性对应的颜色 |
textFont |
String | '50px Helvetica' | 标注字体 |
textColor |
Cesium.Color | Cesium.Color.RED | 标注颜色,详见Cesium.Color |
nearFarScalar |
Object | new Cesium.NearFarScalar(0, 1, 5000000, 0) | 在指定距离内是否可见 |
textHeightOffset |
Number | 0 | 字体高度的偏移值 |
请参考以下示例:
1、统计图支持如下方法:
[1、查询][1、根据查询结果添加专题图]
[1、根据统一的geoJson格式添加专题图]
[1、删除专题图]
示例
// 参考示例:
http://webclient.smaryun.com/#/modules/cesium/visualization/themeLayer/statistic
// ES5引入方式
const { ThemeManager } = zondy.cesium
// ES6引入方式
import { ThemeManager } from "@mapgis/webclient-cesium-plugin"
// 1 初始化一个统计专题图对象
const themeManager = new Cesium.ThemeManager(
// Cesium场景视图对象
viewer,
// 额外初始化参数
{}
)
// 2 添加水平柱状专题图
// 设置用于显示的属性名
themeManager.attributeName = ['GDP_2007', 'GDP_2008']
// 设置各个属性对应的颜色
themeManager.attributeColor = [
new Cesium.Color(234 / 255, 175 / 255, 200 / 255),
new Cesium.Color(56 / 255, 239 / 255, 125 / 255)
]
// 设置文本颜色
themeManager.textColor = Cesium.Color.GREEN
// 设置文本高度
themeManager.textHeightOffset = 10000
// 设置柱状图宽度
themeManager.width = 50000
// 添加专题图数据
themeManager.addByGeoJson(
// GeoJSON数据
{},
// 统计图类型
'HorizontalColumn'
)
// 3 添加垂直柱状专题图
// 解析GeoJson数据时,是否绘制polygon的Geometry
themeManager.addGeoGeometry = false
// 设置用于显示的属性名
themeManager.attributeName = ['GDP_2007', 'GDP_2008']
// 设置各个属性对应的颜色
themeManager.attributeColor = [
new Cesium.Color(234 / 255, 175 / 255, 200 / 255),
new Cesium.Color(56 / 255, 239 / 255, 125 / 255)
]
// 设置柱状图宽度
themeManager.width = 50000
// 添加专题图数据
themeManager.addByGeoJson(
// GeoJSON数据
{},
// 统计图类型
'VerticalColumn'
)
// 4 添加饼状不带高程专题图
// 解析GeoJson数据时,是否绘制polygon的Geometry
themeManager.addGeoGeometry = false
// 是否为饼状体添加高度
themeManager.addExtrudedHeight = false
// 设置用于显示的属性名
themeManager.attributeName = ['GDP_2007', 'GDP_2008']
// 设置各个属性对应的颜色
themeManager.attributeColor = [
new Cesium.Color(109 / 255, 213 / 255, 250 / 255),
new Cesium.Color(245 / 255, 175 / 255, 25 / 255)
]
// 设置柱状图宽度
themeManager.width = 50000
// 添加专题图数据
themeManager.addByGeoJson(
// GeoJSON数据
{},
// 统计图类型
'Pie'
)
// 5 添加饼状不带高程专题图
// 解析GeoJson数据时,是否绘制polygon的Geometry
themeManager.addGeoGeometry = false
// 是否为饼状体添加高度
themeManager.addExtrudedHeight = true
// 设置用于显示的属性名
themeManager.attributeName = ['GDP_2007', 'GDP_2008']
// 设置各个属性对应的颜色
themeManager.attributeColor = [
new Cesium.Color(109 / 255, 213 / 255, 250 / 255),
new Cesium.Color(245 / 255, 175 / 255, 25 / 255)
]
// 设置柱状图宽度
themeManager.width = 50000
// 添加专题图数据
themeManager.addByGeoJson(
// GeoJSON数据
{},
// 统计图类型
'Pie'
)