网格线在 y 轴可见性关闭时被删除
GridLines getting removed on y-axis visibility off
我将 y 轴的可见性设置为 false,因为我不想显示 y 轴,因此设置为 visible false,但这里的问题是网格线也被删除了,需要保留在图表中。如何通过保留网格线来关闭 y 轴可见性?
请在此处找到工作演示 => JSFiddle Demo如有任何帮助,我们将不胜感激。
这是我的代码部分:
Highcharts.chart('container', {
chart: {
type: 'scatter',
zoomType: 'xy'
},
title: {
text: 'Height Versus Weight of 507 Individuals by Gender'
},
subtitle: {
text: 'Source: Subhojit'
},
xAxis: {
title: {
enabled: true,
text: 'Height (cm)'
},
startOnTick: true,
endOnTick: true,
showLastLabel: true
},
yAxis: {
title: {
text: 'Weight (kg)'
},
visible: false
},
legend: {
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 100,
y: 70,
floating: true,
backgroundColor: Highcharts.defaultOptions.chart.backgroundColor,
borderWidth: 1
},
plotOptions: {
scatter: {
marker: {
radius: 5,
states: {
hover: {
enabled: true,
lineColor: 'rgb(100,100,100)'
}
}
},
states: {
hover: {
marker: {
enabled: false
}
}
},
tooltip: {
headerFormat: '<b>{series.name}</b><br>',
pointFormat: '{point.x} cm, {point.y} kg'
}
}
},
series: [{
name: 'Female',
color: 'rgba(223, 83, 83, .5)',
data: <data>
}]
});
根据此 document 要隐藏标签,我们需要 labels
对象并且在该对象中需要传递 enabled: false
yAxis: {
title: {
text: 'Weight (kg)'
},
labels: {
enabled: false
}
},
Highcharts Demo
我找到了我一直在寻找的解决方案,如果有一天它对任何人有帮助,我想与大家分享。
请在此处找到可行的解决方案 => JSFiddle Solution
下面是在不影响网格线的情况下隐藏轴线和标签的解决方案:
yAxis: {
title: {
text: 'Weight (kg)'
},
labels: {
enabled: false
},
lineColor: 'transparent'
},
我将 y 轴的可见性设置为 false,因为我不想显示 y 轴,因此设置为 visible false,但这里的问题是网格线也被删除了,需要保留在图表中。如何通过保留网格线来关闭 y 轴可见性?
请在此处找到工作演示 => JSFiddle Demo如有任何帮助,我们将不胜感激。
这是我的代码部分:
Highcharts.chart('container', {
chart: {
type: 'scatter',
zoomType: 'xy'
},
title: {
text: 'Height Versus Weight of 507 Individuals by Gender'
},
subtitle: {
text: 'Source: Subhojit'
},
xAxis: {
title: {
enabled: true,
text: 'Height (cm)'
},
startOnTick: true,
endOnTick: true,
showLastLabel: true
},
yAxis: {
title: {
text: 'Weight (kg)'
},
visible: false
},
legend: {
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 100,
y: 70,
floating: true,
backgroundColor: Highcharts.defaultOptions.chart.backgroundColor,
borderWidth: 1
},
plotOptions: {
scatter: {
marker: {
radius: 5,
states: {
hover: {
enabled: true,
lineColor: 'rgb(100,100,100)'
}
}
},
states: {
hover: {
marker: {
enabled: false
}
}
},
tooltip: {
headerFormat: '<b>{series.name}</b><br>',
pointFormat: '{point.x} cm, {point.y} kg'
}
}
},
series: [{
name: 'Female',
color: 'rgba(223, 83, 83, .5)',
data: <data>
}]
});
根据此 document 要隐藏标签,我们需要 labels
对象并且在该对象中需要传递 enabled: false
yAxis: {
title: {
text: 'Weight (kg)'
},
labels: {
enabled: false
}
},
Highcharts Demo
我找到了我一直在寻找的解决方案,如果有一天它对任何人有帮助,我想与大家分享。
请在此处找到可行的解决方案 => JSFiddle Solution
下面是在不影响网格线的情况下隐藏轴线和标签的解决方案:
yAxis: {
title: {
text: 'Weight (kg)'
},
labels: {
enabled: false
},
lineColor: 'transparent'
},