添加系列后启用 Highcharts 系列悬停状态
Highcharts series hover state enables after adding series
如果我以编程方式将系列添加到已禁用悬停的图形,它将启用它。添加新系列后我似乎无法禁用它。
我在这里重新创建了代码https://jsfiddle.net/alexros/cxeh0po8/1/
将鼠标悬停在加载的系列上,看到它保持静态。然后单击添加系列,然后将鼠标悬停在系列上,它们将变为透明。这是一个错误还是我应该在一切之后调用一个函数来重置它?
// create the chart
const chart = Highcharts.chart('container', {
chart: {
},
plotOptions: {
series: {
states: {
hover: {
enabled: false
}
}
}
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
// activate the button
document.getElementById('button').addEventListener('click', e => {
chart.addSeries({
data: [216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5]
});
e.target.disabled = true;
});
您还需要禁用非活动状态:
plotOptions: {
series: {
states: {
hover: {
enabled: false
},
inactive: {
enabled: false
}
}
}
}
现场演示: https://jsfiddle.net/BlackLabel/hL4bx91e/
API参考:https://api.highcharts.com/highcharts/plotOptions.series.states.inactive
如果我以编程方式将系列添加到已禁用悬停的图形,它将启用它。添加新系列后我似乎无法禁用它。
我在这里重新创建了代码https://jsfiddle.net/alexros/cxeh0po8/1/ 将鼠标悬停在加载的系列上,看到它保持静态。然后单击添加系列,然后将鼠标悬停在系列上,它们将变为透明。这是一个错误还是我应该在一切之后调用一个函数来重置它?
// create the chart
const chart = Highcharts.chart('container', {
chart: {
},
plotOptions: {
series: {
states: {
hover: {
enabled: false
}
}
}
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
// activate the button
document.getElementById('button').addEventListener('click', e => {
chart.addSeries({
data: [216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5]
});
e.target.disabled = true;
});
您还需要禁用非活动状态:
plotOptions: {
series: {
states: {
hover: {
enabled: false
},
inactive: {
enabled: false
}
}
}
}
现场演示: https://jsfiddle.net/BlackLabel/hL4bx91e/
API参考:https://api.highcharts.com/highcharts/plotOptions.series.states.inactive