1.点击一个国家后,如何将其背景颜色更改为红色
this.color
您可以通过设置为来更改单击元素的背景颜色'rgb(255,0,0)
。这里有一个例子plotOptions
plotOptions:{
series:{
point:{
events:{
click: function(){
alert(this.name);
this.color = "rgb(255,0,0)";
}
}
}
}
}
更新
如果你想重置之前选择的元素,这里有一个解决方法(还没有找到另一种方法)将以下代码放在后面alert(this.name)
并查看小提琴示例以便更好地理解。(该oldFill
变量在地图图表之前被初始化,只是临时存储所选元素的原始颜色值)
$(mapChart.find("path")).each(function(){
if($(this)[0].attributes.fill.value === 'rgb(255,0,0)'){
$(this)[0].attributes.fill.value = oldFill;
}
});
oldFill = this.color;
2. 如何从工具提示中删除多余的数据,我只想显示国家名称。
通过使用以下tooltip
设置,您将获得所需的效果。
tooltip: {
headerFormat: '',
pointFormat: '<strong>{point.name}</strong>',
footerFormat: ''
}
更新了 JSFiddle 示例