在 HighChart Solid Gauge 中隐藏 YAxis 值
hide YAxis values in HighChart Solid Gauge
在下面的示例中,是否可以 "hide" Y 轴值 - 例如 - 不显示 0 和 200(在左侧)。
寻找更清晰的图表..
以下代码将隐藏 Y 轴标签 (JSfiddle example):
yAxis: {
labels: {
enabled: false
}
}
通过 CSS 定位 yAxis 标签,您就可以做到这一点
CSS:
.highcharts-axis-labels.highcharts-yaxis-labels{
display:none;
}
或者,通过设置yAxis的showFirstLabel
和showLastLabel
属性在gauge的情况下也有同样的效果。
JS:
yAxis: {
showFirstLabel:false,
showLastLabel:false,
min: 0,
max: 5,
title: {
text: 'RPM'
}
}
这是一个展示两者的演示 http://jsfiddle.net/robschmuecker/yra3mex6/
这是有关属性 http://api.highcharts.com/highcharts#yAxis.showFirstLabel
的文档
您还可以使用 'formatter' 如下所示:
labels: {
y: 16,
formatter: function () {
if(this.value == 0){
return '0B'; // your choice of value
} else {
return '425B'; // you can pass the empty string
}
}
}
在下面的示例中,是否可以 "hide" Y 轴值 - 例如 - 不显示 0 和 200(在左侧)。 寻找更清晰的图表..
以下代码将隐藏 Y 轴标签 (JSfiddle example):
yAxis: {
labels: {
enabled: false
}
}
通过 CSS 定位 yAxis 标签,您就可以做到这一点
CSS:
.highcharts-axis-labels.highcharts-yaxis-labels{
display:none;
}
或者,通过设置yAxis的showFirstLabel
和showLastLabel
属性在gauge的情况下也有同样的效果。
JS:
yAxis: {
showFirstLabel:false,
showLastLabel:false,
min: 0,
max: 5,
title: {
text: 'RPM'
}
}
这是一个展示两者的演示 http://jsfiddle.net/robschmuecker/yra3mex6/ 这是有关属性 http://api.highcharts.com/highcharts#yAxis.showFirstLabel
的文档您还可以使用 'formatter' 如下所示:
labels: {
y: 16,
formatter: function () {
if(this.value == 0){
return '0B'; // your choice of value
} else {
return '425B'; // you can pass the empty string
}
}
}