Highcharts 如果数据>;高图表中的1
插入新数据后,当数据>1时,如何禁用标记?我真的很困惑 在本例中,我想制作一个增长图表(图表示例来源:CDC年龄百分比权重) 我应该用这个吗Highcharts 如果数据>;高图表中的1,highcharts,Highcharts,插入新数据后,当数据>1时,如何禁用标记?我真的很困惑 在本例中,我想制作一个增长图表(图表示例来源:CDC年龄百分比权重) 我应该用这个吗 if(dataChartWeight.length > 1) { chart.series[19].update({ marker: { enabled: false } }, true); } if(dataChartLength.length > 1) { chart.series[18]
if(dataChartWeight.length > 1)
{
chart.series[19].update({
marker: {
enabled: false
}
}, true);
}
if(dataChartLength.length > 1)
{
chart.series[18].update({
marker: {
enabled: false
}
}, true);
}
通常不能对单点禁用标记,但可以使用隐藏SVG元素的变通方法
$.each(chart.series[0].data, function (point, i) {
if(this.y <10) {
this.graphic.destroy();
}
});
$.each(图表系列[0]。数据,函数(点,i){
如果(this.y不尝试禁用标记,您可以将其隐藏
marker: {
radius:0,
lineWidth:0,
}
Sebastian的很好,但是如果您使用多个系列、使用自定义工具提示,或者在重新绘制图表时,修复它可能会变得有点复杂
我将它包装在一个函数中,然后在第一次加载时调用该函数,也在重画事件时调用该函数。它首先循环遍历每个系列,然后循环遍历数据以“隐藏”以零作为值的标记
$(function () {
function hideZeroDots(chart) {
$.each(chart.series, function (series) {
$.each(chart.series[series].data, function () {
if(this.y === 0 && this.graphic) {
this.graphic.hide();
}
});
});
}
$('#container').highcharts({
title: {
text: 'Hide Zero Dots'
},
chart: {
events: {
redraw: function () {
hideZeroDots(this);
}
}
},
tooltip: {
useHTML: true,
hideDelay: 0,
shared: true,
backgroundColor: '#fff',
borderColor: '#eee',
shadow: false,
crosshairs: {
width: 2,
color: 'gray',
dashStyle: 'shortdot'
}
},
series: [{
name: 'responses',
data: [0, 0, 0, 0, 0, 0, 36.5, 33.3, 0, 23.9, 0]
}, {
name: 'views',
data: [0, 0, 0, 0, 0, 0, 26.5, 23.3, 0, 13.9, 0]
}]
}, hideZeroDots);
});
看