2016-03-01 27 views

回答

1

從技術上說,熱圖特徵不適用於圖像。然而,使用非常基本的插件應用相同的原理相當容易:

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"]); 

將它添加到地圖代碼之前的某處。還要確保colorcolorSolid設置在imagesSettings

這是一個完整的working example

+0

正是我在找的東西!謝謝! – matcygan