Skip to content

Not enough colours (default or pre-defined) causes an array out of range exception #54

@ghost

Description

getData or getDataSeries loops through an array of colors with a possible array out of range exception(when data.length is > than scope.colours.length(or default colors length).
A possible (but ugly fix might be):

//Prevent an undefined compilation error
colours: '=?',
//Remove colour array assignment in getdata and getdata series
function createChart()
    scope.colours = scope.colours || Chart.defaults.global.colours;
        if(scope.colours.length < scope.data.length)
        {
            var itemsToAdd = scope.data.length - scope.colours.length;      
            for(var i=0; i<=itemsToAdd; i++)
            {
                var color = getRandomColor();
                scope.colours.push({
                    fillColor: color,
                    strokeColor: color,
                    pointColor: color,
                    pointStrokeColor: "#fff",
                    pointHighlightFill: "#fff",
                    pointHighlightStroke: "rgba(151,187,205,0.8)"
                });
            }
        }

getRandomColor() is a matter of a flavour.
Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions