Highcharts: return N / A value instead of 0% in the data label

I would like the Y axis data labels to return 'N / A' for null values. Nothing is currently displayed. I tried using the y-formatter function to say that y is null, returns N / A, but for some reason no luck? I am a little new to Highcharts, so please forgive the main point.

formatter: function() {
                    if (this.y !== null)
                        return 'test';

                    var chart = this.series.chart;

                    chart.renderer.text('n/a', this.point.plotX - 10, chart.plotHeight - 10).add(this.series.group)
                },

Here's a link to JSFiddle: http://jsfiddle.net/v5vJR/

0
source share
2 answers

Remove formatdataLabels from the parameters. Then you need to correctly calculate where to put this mark. plotY will be undefined since there is no value, right?

            formatter: function () {
                var str;
                if (this.y !== null) {
                    return this.y + '%';
                } else {
                    var chart = this.series.chart,
                        categoryWidth = chart.plotHeight / chart.xAxis[0].categories.length,
                        offset = (this.point.x + 1) * categoryWidth - this.point.pointWidth + 3; // 

                    chart.renderer.text('n/a', chart.plotLeft, chart.plotTop + offset).add();
                }

                return false;
            },

: http://jsfiddle.net/v5vJR/3/

+1


: http://api.highcharts.com/highcharts#Renderer

Fiddle: http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/members/renderer-text/

             chart.renderer.text('<span style="color: #a2a5a1">N/A</span>', chart.plotLeft, chart.plotTop + offset)
                    .css({
                    color: '#a2a5a1',
                    fontSize: '11px'
                    })
                    .add();
0

All Articles