2014-10-03 70 views
3

如果空间太紧,轴标签被截断。我正在处理变量类别,所以我宁愿让它们重叠而不是消失。如何防止Highcharts截断类别?

实施例: http://jsfiddle.net/z1axtk31/

$(function() { 
    $('#container').highcharts({ 
     chart: { 
      type: 'bar' 
     }, 
     title: { 
      text: 'Historic World Population by Region' 
     }, 
     subtitle: { 
      text: 'Source: Wikipedia.org' 
     }, 
     xAxis: { 
      categories: ['Sub-saharan Africa', 'North America', 'South America', 'East Asia', 'Middle East', 'Europe', 'Oceania', 'Ancapistan', 'North Africa', 'Mordor', 'Atlantis'], 
      title: { 
       text: null 
      } 
     }, 
     yAxis: { 
      min: 0, 
      title: { 
       text: 'Population (millions)', 
       align: 'high' 
      }, 
      labels: { 
       overflow: 'justify' 
      } 
     }, 
     tooltip: { 
      valueSuffix: ' millions' 
     }, 
     plotOptions: { 
      bar: { 
       dataLabels: { 
        enabled: true 
       } 
      } 
     }, 
     legend: { 
      layout: 'vertical', 
      align: 'right', 
      verticalAlign: 'top', 
      x: -40, 
      y: 100, 
      floating: true, 
      borderWidth: 1, 
      backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'), 
      shadow: true 
     }, 
     credits: { 
      enabled: false 
     }, 
     series: [{ 
      name: 'Year 1800', 
      data: [107, 31, 635, 203, 2, 45, 23, 201, 50, 89, 210] 
     }/*, { 
      name: 'Year 1900', 
      data: [133, 156, 947, 408, 6, 45, 23, 166, 50, 20, 110] 
     }, { 
      name: 'Year 2008', 
      data: [973, 914, 4054, 732, 34, 45, 23, 20, 50, 133, 100] 
     }*/] 
    }); 
}); 

回答

4

只需设置:

xAxis: { 
    labels: { 
     step: 1 
    } 
} 

Example