AmMaps 具有为区域创建热图的酷而简单的功能: https ://www.amcharts.com/demos/us-heat-map/
是否可以将它也用于点(图像) - 根据值、colorSteps 等计算图像颜色?
AmMaps 具有为区域创建热图的酷而简单的功能: https ://www.amcharts.com/demos/us-heat-map/
是否可以将它也用于点(图像) - 根据值、colorSteps 等计算图像颜色?
从技术上讲,热图特征不适用于图像。但是,使用一个非常基本的插件很容易应用相同的原理:
AmCharts.addInitHandler(function(map) {
// check if `colorSolid` is set for `imagesSettings`
if (map.imagesSettings.colorSolid === undefined)
return;
// calculate minimum and maximum value
var minValue,
maxValue;
if (map.minValue === undefined || map.maxValue === undefined) {
for (var i = 0; i < map.dataProvider.images.length; i++) {
var image = map.dataProvider.images[i];
if (image.value !== undefined) {
if (minValue === undefined || (image.value < minValue))
minValue = image.value;
if (maxValue === undefined || (image.value > maxValue))
maxValue = image.value;
}
}
}
// use map overrides if set
if (map.minValue !== undefined)
minValue = map.minValue;
if (map.maxValue !== undefined)
maxValue = map.maxValue;
// set colors for each area
for (var i = 0; i < map.dataProvider.images.length; i++) {
var image = map.dataProvider.images[i];
if (image.color === undefined && image.value !== undefined) {
// we set colors for those images that don't have color set explicitly
var percent = (image.value - minValue) / (maxValue - minValue);
image.color = AmCharts.getColorFade(
map.imagesSettings.color,
map.imagesSettings.colorSolid,
percent);
}
}
}, ["map"]);
将其添加到地图代码之前的某个位置。还要确保两者color
都colorSolid
设置在imagesSettings
.
这是一个完整的工作示例。