A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/chartjs/Chart.js/issues/2143 below:

Doughnut/Pie generateLabels assumes backgroundColor is always set on dataset · Issue #2143 · chartjs/Chart.js · GitHub

In the doughnut chart defaults, the generateLabels function assumes that data.datasets[0].backgroundColor is always set, resulting in the classic Cannot read property '0' of undefined error

labels: {
    generateLabels: function(data) {
        if (data.labels.length && data.datasets.length) {
            return data.labels.map(function(label, i) {
                return {
                    text: label,
                    fillStyle: data.datasets[0].backgroundColor[i],
                    hidden: isNaN(data.datasets[0].data[i]),

                    // Extra data used for toggling the correct item
                    index: i
                };
            });
        } else {
            return [];
        }
    }
},

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4