Highcharts X轴类别

时间:2015-10-07 07:54:26

标签: javascript highcharts

使用highcharts并想知道如何根据值对x轴进行分类。

这是我的代码,我想将0-25分类为A,25-50分类为B,50-75分类为C,75-100分类为D.

请您告诉我如何实现这一目标。

$(function () {
    $('#container').highcharts({
        title: {
            text: 'Chart reflow is set to true'
        },

      


        xAxis: {
            min:0,
            max:100,
            tickInterval: 25,
            
        },
          yAxis: {
			min:0,
            max:10,
            tickInterval:2,
            title: {
                text: 'values'
            },
          
        },

        series: [{
            data: [[2,1], [15,3], [30,6], [50,9.5], [60,9.8],
                  [83,5], [90,3],[99,0.2]]
        }]
    });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/highcharts-more.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

1 个答案:

答案 0 :(得分:1)

使用此:Here is your updated fiddle

  labels: { 
    formatter: function() {
       if(this.value == 0 )
        return "A";
        if(this.value == 25)
             return "B";
         if(this.value == 50)
             return "C";
    } 
}