当增加到第六个字段的时候,统计专题图 柱状图出不来。
function addThemeLayer() {
//getAlarmData();
//创建一个柱状图(Bar)统计专题图图层
themeLayer = new SuperMap.Layer.Graph("ThemeLayer", "Bar");
//指定用于专题图制作的属性字段
themeLayer.themeFields = ["CON2009", "CON2010", "CON2011","CON2012","CON2013","CON2014"];
//配置图表参数
themeLayer.chartsSetting = {
// width,height,codomain 分别表示图表宽、高、数据值域;此三项参数为必设参数
width : 800,
height : 400,
codomain : [ 0, 600 ], // 允许图表展示的值域范围,此范围外的数据将不制作图表
barStyle : {
fillOpacity : 0.7
}, // 柱状图中柱条的(表示字段值的图形)样式
barHoverStyle : {
fillOpacity : 1
}, // 柱条 hover 样式
xShapeBlank : [ 30, 30, 30,30,30 ], // 水平方向上的空白间距参数
axisYTick : 6, // y 轴刻度数量
axisYLabels : ["600","500","400", "300", "200", "100", "0" ], // y 轴标签内容
axisXLabels : [ "一键报警", "区域入侵", "智能分析","智能分析","智能分析","智能分析"], // x 轴标签内容
backgroundStyle : {
fillColor : "#CCE8CF"
}, // 背景样式
backgroundRadius : [ 5, 5, 5, 5 ], // 背景框圆角参数
//阴影开关 默认是打开
showShadow : true,
//阴影样式
barShadowStyle : {
shadowBlur : 8,
shadowOffsetX : 2,
shadowOffsetY : 2,
shadowColor : "rgba(100,100,100,0.8)"
},
//按字段设置柱条样式[渐变开始颜色,渐变终止颜色] 与 themeLayer.themeFields 中的字段一一对应)
barLinearGradient : [ [ "#00FF00", "#00CD00" ],
[ "#00CCFF", "#5E87A2" ], [ "#00FF66", "#669985" ],
[ "#CCFF00", "#94A25E" ], [ "#FF9900", "#A2945E" ] ]
};
//注册专题图 mousemove, mouseout 事件(注意:专题图图层对象自带 on函数,没有events对象)
themeLayer.on("mousemove", showInfoWin);
themeLayer.on("mouseout", closeInfoWin);
themeLayer.setOpacity(0.9);
//加载专题图
map.addLayers([themeLayer]);
// 统计图模块要求浏览器支持 Canvas 渲染
if (!document.createElement('canvas').getContext) {
alert("您的浏览器不支持 Canvas,请升级!");
return;
}
clearThemeLayer();
var features = [];
for (var i = 0, len = chinaConsumptionLevel.length; i < len; i++) {
// 省居民消费水平(单位:元)信息
var provinceInfo = chinaConsumptionLevel[i];
var geo = new SuperMap.Geometry.Point(provinceInfo[1], provinceInfo[2]);
var attrs = {};
attrs.NAME0 = 3;
attrs.NAME1 = 3;
attrs.NAME2 = 3;
attrs.NAME3 = 3;
attrs.NAME4 = 3;
attrs.NAME5 = 3;
attrs.CON2009 = 200;
attrs.CON2010 = 300;
attrs.CON2011 = 400;
attrs.CON2012 = 400;
attrs.CON2013 = 400;
attrs.CON2014 = 400;
var fea = new SuperMap.Feature.Vector(geo, attrs);
features.push(fea);
}
themeLayer.addFeatures(features);
}