简体   繁体   中英

High Charts Column Chart - Y axis Label Formatting

I am using high-charts column chart. Here is my chart options ( y axis portion ).

        yAxis: {
            allowDecimals: false,
            min: 0,
            max: 100,
            tickInterval: 25,
            title: {
                text: ''
            }
//                labels: {
//                    formatter: function () {
//                        
//                    }
//                }
        },

Currently, it is displaying y axis label from 0 to 100. But, I would like to append '%' symbol to only '0' and leave rest of the labels as is. I tried sing label formatter, couldn't figure which values to use. Can any one suggest me any idea ?

Thanks

You can try:

       labels: {
            formatter: function() {
                return this.value === 0 ? '0%' : this.value;
            }
        }

http://jsfiddle.net/6huhbqhj/

Figured it.

                 labels: {
                formatter: function () {
                    if (this.value == 0)
                        return this.value + "%";
                    else
                        return this.value;
                }
            }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM