【问题标题】:hide YAxis values in HighChart Solid Gauge在 HighChart Solid Gauge 中隐藏 YAxis 值
【发布时间】:2015-02-03 14:59:25
【问题描述】:

在下面的示例中,是否可以“隐藏” Y 轴值 - 例如 - 不显示 0 和 200(在左侧)。 寻找更清晰的图表..

http://www.highcharts.com/demo/gauge-solid/dark-unica

【问题讨论】:

    标签: highcharts gauge


    【解决方案1】:

    通过 CSS 定位 yAxis 标签,您可以做到这一点

    CSS:

    .highcharts-axis-labels.highcharts-yaxis-labels{
        display:none;   
    }
    

    或者,在仪表的情况下,通过设置yAxis的showFirstLabelshowLastLabel属性具有相同的效果。

    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

    的文档

    【讨论】:

      【解决方案2】:

      以下代码将隐藏 Y 轴标签 (JSfiddle example):

      yAxis: {
          labels: {
              enabled: false
          }
      }
      

      【讨论】:

        【解决方案3】:

        您也可以使用如下所示的“格式化程序”:

        labels: {
                    y: 16,
                    formatter: function () {
                        if(this.value == 0){
                        return '0B'; // your choice of value
                      } else {
                        return '425B'; // you can pass the empty string
                      }
                    }
                }
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2017-09-30
          • 1970-01-01
          • 1970-01-01
          • 2011-04-27
          • 2020-08-24
          • 1970-01-01
          • 2011-12-17
          • 2012-12-23
          相关资源
          最近更新 更多