我有以下amchart map
var latlong = data.geo;
var mapData = data.regions;
var minBulletSize = 1;
var maxBulletSize = 50;
var min = Infinity;
var max = -Infinity;
// get min and max values
for (var i = 0; i < mapData.length; i++) {
var value = mapData[i].value;
if (value < min) {
min = value;
}
if (value > max) {
max = value;
}
}
AmCharts.theme = AmCharts.themes.light;
window.map = new AmCharts.AmMap();
window.map.areasSettings = {
unlistedAreasColor: "#000000",
unlistedAreasAlpha: 0.1,
autoZoom: true,
selectedColor: "#CC0000"
};
window.map.smallMap = {
mapColor: "#3faba4"
};
window.map.mouseWheelZoomEnabled = true;
window.map.zoomOnDoubleClick = true;
window.map.imagesSettings.balloonText = "<span style='font-size:14px;'><b>[[title]]</b>: [[value]]</span>";
window.map.imagesSettings.alpha = 0.8;
var dataProvider = {
mapVar: AmCharts.maps.worldLow,
images: [],
getAreasFromMap: true
}
for (var i = 0; i < mapData.length; i++) {
var dataItem = mapData[i];
var value = dataItem.value;
// calculate size of a bubble
var size = (value - min) / (max - min) * (maxBulletSize - minBulletSize) + minBulletSize;
if (size < minBulletSize) {
size = minBulletSize;
}
var id = dataItem.code;
dataProvider.images.push({
type: "circle",
width: size,
height: size,
color: dataItem.color,
longitude: latlong[id].longitude,
latitude: latlong[id].latitude,
title: dataItem.name,
value: value
});
}
window.map.dataProvider = dataProvider;
window.map.export = {
enabled: true
}
window.map.projection = "Miller";
window.map.write("chartdiv");
和填充地图的数据是这样的
{"data":{
"geo":{
"liège":{
"latitude":50.6244465,
"longitude":5.5285034
},
"sarthe":{
"latitude":47.9925739,
"longitude":0.2093181
},
"mersch":{
"latitude":49.724161,
"longitude":6.1242871
},
"greater_manchester":{
"latitude":53.47108559999999,
"longitude":-2.2943756
},
"córdoba":{
"latitude":37.89183,
"longitude":-4.819809999999999
},
"coimbra":{
"latitude":40.1585918,
"longitude":-8.8696372
},
"soest":{
"latitude":52.1590547,
"longitude":5.3067835
}
},
"regions":[
{
"code":"liège",
"name":"Liège",
"value":3,
"color":"#eea638"
},
{
"code":"sarthe",
"name":"Sarthe",
"value":3,
"color":"#eea638"
},
{
"code":"mersch",
"name":"Mersch",
"value":6,
"color":"#eea638"
},
{
"code":"greater_manchester",
"name":"Greater Manchester",
"value":5,
"color":"#eea638"
},
{
"code":"córdoba",
"name":"Córdoba",
"value":3,
"color":"#eea638"
},
{
"code":"coimbra",
"name":"Coimbra",
"value":4,
"color":"#eea638"
},
{
"code":"soest",
"name":"Soest",
"value":1,
"color":"#eea638"
}
]
}
}
如果有办法做一个包含所有气球的自动缩放,我想知道什么。