2011-10-28 98 views
40

我用画highchart.js如何隐藏highchart X - 轴数据值

我不想显示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] 
       }] 
      }); 

回答

72

在HighCharts,条形图使用倒轴,所以底轴是真Y轴。 (参见其中的图形旋转90度也“列”的曲线图,在这种情况下,底部轴为X轴。)

您需要将以下添加到Y轴配置

labels: 
{ 
    enabled: false 
} 

见以下为完整的例子: http://jsfiddle.net/k5yBj/433/

17

要隐藏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获得进一步的了解。

0

如果隐藏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); 
}