Yaxis Values on High Chart Customization

浪子不回头ぞ 提交于 2019-12-11 09:41:44

问题


I have been trying to populate yaxis values on my highchart as per defined by me and results should be shown accordingly but all my efforts are in vain i am not able to manually set this.value of yaxis of highchart . Following is a link to my Jsfiddle . Kindly help..

http://jsfiddle.net/CzHyC/12/

In the following JS COde I have been trying to set the this.value of yaxis to the arrayed values of yAxisLabels but values are not being labled and chart is not dislayed accordingly.

JS CODE FOR YAXIS

var yAxisLabels = ['5','10','20','30','40','50'];


yAxis: {
    labels: {
        formatter: function () {
            for (i=0; i<=5; i++) {
                this.value=yAxisLabels[i];
                return this.value;
            }
        }
    },

    title: {
        text: 'Total fruit consumption'
    },
    stackLabels: {
        enabled: true,
        style: {
            fontWeight: 'bold',
            color: (Highcharts.theme && Highcharts.theme.textColor) || 'blue'
        }
    }
}

回答1:


You can use the Tick Positioner to define your axis tick values:

See jsfiddle

The important parts are:

var yAxisLabels = [0, 5, 10, 20, 30, 40, 50];

your axis label array containing numbers and not strings

and

tickPositioner: function() {
                return yAxisLabels;
            },

the tickPositioner returning your array.

TickPositioner Documentation




回答2:


you can also set like this

tickPositions: [0, 5, 10, 20, 30, 40, 50],


来源:https://stackoverflow.com/questions/11683695/yaxis-values-on-high-chart-customization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!