如何在Highcharts中以相等的间隔设置Y轴?

时间:2017-07-13 07:44:28

标签: highcharts

我知道之前在StackOverflow上已经提出了这个问题。但是,我的问题略有不同,所以请在将其标记为重复之前阅读。

我试图将y轴设置为0,1,2,4,8,16,32,64,128 ....同样,这些tickPoints之间的间距应相等。我已尝试设置各种间隔,但下面的代码没有帮助。

 $("#ClickSmu_man").click(function () {
        var theModal = $("#ModalSmu_man").modal({
            show: false
        });

        Highcharts.chart('container_man', {
            chart: {
                type: 'column'
            },
            title: {
                text: 'In Progress weekly pending Avg. Age per DE Manager Count'
            },
            xAxis: {
                categories: [
                    <?php foreach($smu_top_manager as $topma){ ?>
                        '<?php echo $topma['name']; ?>',                
                    <?php } ?>                    
                ]
            },
            yAxis: {
                min: 0,
                tickInterval: 1,

                title: {
                    text: 'Platform'
                },
                stackLabels: {
                    enabled: false,
                    style: {
                        fontWeight: 'bold',
                        color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
                    }
                }
            },
            tooltip: {
                headerFormat: '<b>{point.x}</b><br/>',
                pointFormat: '{series.name}: {point.y}<br/>'
            },
            plotOptions: {
                column: {
                    stacking: 'normal',
                    dataLabels: {
                        enabled: false,
                        color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
                    }
                }
            },
            series: [
                    {
                    name: 'Age',
                    data: [<?php echo implode(',', $age_manager); ?>],
                    },
                    {
                    name: 'asr9k_px',
                    data: [<?php echo implode(',', $asr9k_px_manager); ?>],
                    },
                    {
                    name: 'asr9k_x64',
                    data: [<?php echo implode(',', $asr9k_x64_manager); ?>],
                    },
                    {
                    name: 'crs_px',
                    data: [<?php echo implode(',', $crs_px_manager); ?>],
                    },
                    {
                    name: 'ncs5500',
                    data: [<?php echo implode(',', $ncs5500_manager); ?>],
                    },
                    {
                    name: 'ncs5500_sysadmin',
                    data: [<?php echo implode(',', $s5500_sysadmin_manager); ?>],
                    },
                    {
                    name: 'ncs5k',
                    data: [<?php echo implode(',', $ncs5k_manager); ?>],
                    },
                    {
                    name: 'ncs6k',
                    data: [<?php echo implode(',', $ncs6k_manager); ?>],
                    },
                    {
                    name: 'xr12000',
                    data: [<?php echo implode(',', $xr12000_manager); ?>],
                    },
                    {
                    name: 'xrv9k',
                    data: [<?php echo implode(',', $xrv9k_manager); ?>],
                    },
                    {
                    name: 'xrv9k_sysadmin',
                    data: [<?php echo implode(',', $xrv9k_sysadmin_manager); ?>],
                    }                        
                ]
        });
    });

1 个答案:

答案 0 :(得分:1)

使用yAxis.tickPositions定义图表中的刻度。

xAxis: {
    tickPositions: [0,2,4,8,16,32,64],
},

示例:http://jsfiddle.net/f94hdLqt/

如果要动态设置刻度,可以使用tickPositioner