javascript-禁用莫里斯甜甜圈图中的悬停选项
作者:互联网
如何在morris甜甜圈图中禁用悬停选项,以及每当用户将指针移到图表上方时,其值应保持不变.
var m111 = new Morris.Donut({
element: 'donut-chart111',
data: [
{label: "R", value: ra},
{label: "C", value: cp},
{label: "M", value: mp},
{label: "MA", value: map},
{label: "A", value: ap}
],
colors: ['#D9534F','#1CAF9A','#428BCA','#5BC0DE','#428BCA']
});
解决方法:
您可以根据自己的喜好循环遍历和修改段处理程序.
要删除悬停处理程序(并有选择地添加点击处理程序),您可以例如执行以下操作:
var donut = new Morris.Donut({
// ...
});
for(i = 0; i < donut.segments.length; i++) {
// Remove hover handlers:
donut.segments[i].handlers['hover'] = [];
// If you want select functionality through click:
donut.segments[i].handlers['click'] = [donut.select];
}
实际操作中查看this JSFiddle demonstration.
标签:morris-js,javascript,jquery 来源: https://codeday.me/bug/20191027/1942443.html