BN83
BN83

Reputation: 902

Displaying Stack name as legend key

Using a stacked bar at the moment to display "Attended" and "Unattended" along with linkedTo:previous to group the legends together... but the legend is showing "unattended" I want these groups to be called "Location 1" "Location 2" etc. I was thinking I could perhaps use:

    tooltip: {
        formatter: function () {
            return '<b>' + this.series.options.stack + '</b><br/>' +
                this.series.name + ': ' + this.y + '<br/>' +
                'Total: ' + this.point.stackTotal;
        }
    },
    legend: {
        labelFormatter: function () {
            return this.series.options.stack;
        }
    },

However I get the error "Uncaught TypeError: Cannot read property 'options' of undefined" I assume as the legend is seeing the series when calling this rather than the stack?

Upvotes: 0

Views: 55

Answers (1)

Deep 3015
Deep 3015

Reputation: 10075

Legend should be

legend: {
    labelFormatter: function () {
        return this.userOptions.stack
    }
},

Fiddle demo

Upvotes: 1

Related Questions