【问题标题】:how to hide highchart x - axis data values如何隐藏highchart x轴数据值
【发布时间】:2011-12-17 06:03:48
【问题描述】:

我正在使用highchart.js绘制条形图

我不想显示 x 轴数据值。

谁能告诉我是哪个选项?
完整配置:

var chart = new Highcharts.Chart({
                chart: {
                    renderTo: container,
                    defaultSeriesType: 'bar'
                },
                title: {
                    text: null
                },
                subtitle: {
                    text: null
                },
                xAxis: {
                    categories: [''],
                    title: {
                        text: null
                    },
                    labels: {enabled:true,y : 20, rotation: -45, align: 'right' }

                },
                yAxis: {
                    min: 0,
                    gridLineWidth: 0,
                    title: {
                        text: '',
                        align: 'high'
                    }
                },
                tooltip: {
                    formatter: function () {
                        return '';
                    }
                },
                plotOptions: {
                    bar: {
                        dataLabels: {
                            enabled: true
                        },
                        pointWidth: 35,
                        color: '#D9CDC1'
                    }
                },
                legend: {
                    enabled: false
                },
                credits: {
                    enabled: false
                },
                series: [{
                    name: 'Year 1800',
                    data: [107]
                }]
            });

【问题讨论】:

    标签: javascript jquery charts highcharts bar-chart


    【解决方案1】:

    在 HighCharts 中,条形图使用倒轴,所以底轴实际上是 Y 轴。 (另请参见图形旋转 90 度的“柱状图”,在这种情况下,底轴是 X 轴。)

    您需要将以下内容添加到 yAxis 配置中

    yAxis: {
      labels: {
        enabled: false
      }
    }
    

    完整示例请参见以下内容: http://jsfiddle.net/k5yBj/433/

    【讨论】:

      【解决方案2】:

      要隐藏 X 轴上的标签,请设置选项 labels: {enabled:false},如下所示:

          .....
          ........
          ,
                          xAxis: {
                              categories: [''],
                              title: {
                                  text: null
                              },
                              labels: {
                               enabled:false,//default is true
                               y : 20, rotation: -45, align: 'right' }
      
                          }
      
      
      .....
      ....
      

      要隐藏 y 轴上的标签,请设置选项 labels: {enabled:false},如下所示:

      .....
      .......
      ,
                      yAxis: {
                          min: 0,
                          gridLineWidth: 0,
                          title: {
                              text: '',
                              align: 'high'
                          },
                          labels:{
                              enabled:false//default is true
                          }
                      },
      .........
      ......
      

      Refer the documentation进一步了解。

      【讨论】:

        【解决方案3】:

        上面的流行答案只隐藏了标签,这给我留下了我也希望删除的刻度线。

        在这种情况下效果很好

            xAxis: {
                    visible: false
                },
        

        这是一个简单的解决方案,可以为任何感兴趣的人删除 x/y 轴上的所有内容。更多信息请看这里https://api.highcharts.com/highcharts/xAxis.visible

        【讨论】:

          【解决方案4】:

          如果隐藏 x 数据,那么看看这个 https://jsfiddle.net/anrilafosel/3g4z5kc3/

          chart.xAxis[0].setCategories(newCategories);
          for (i = 0; i < chart.series.length; i++) {
            var newData = [];
            for (j = 0; j < toggler_hc13.length; j++)
              if (toggler_hc13[j] === 1)
                newData.push(series_hc13[i].data[j]);
            chart.series[i].setData(newData);
          }
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2019-10-22
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多