Skip to content

Background Color scriptable option and legend item color is black  #6135

@stockiNail

Description

@stockiNail

Expected Behavior

I used the Chart.js sample of Doughnut and I used Patternomaly to create canvas pattern. This is what I'm expecting:

correct

This is the code of scriptable options :

backgroundColor: function(context) {
	var index = context.dataIndex;
	if (index === 0){
		return pattern.draw('square', '#ff6384');
	}
	if (index === 1){
		return pattern.draw('circle', '#36a2eb');
	}
	if (index === 2){
		return pattern.draw('diamond', '#cc65fe');
	}
	if (index === 3){
		return pattern.draw('triangle', '#ffce56');
	}
	return pattern.draw('zigzag', '#fcc465');
},

Current Behavior

Using scriptable options, the result is the legend item color is black.

error

If, instead of using scriptable options, I'm passing the array of pattern, it works.

backgroundColor: [
	pattern.draw('square', '#ff6384'),
	pattern.draw('circle', '#36a2eb'),
	pattern.draw('diamond', '#cc65fe'),
	pattern.draw('triangle', '#ffce56'),
	pattern.draw('zigzag', '#fcc465')
],

I've tested also my canvas pattern (not by Patternomaly) and the result is the same.

Environment

  • Chart.js version: 2.8.0
  • Browser name and version: FF 65.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions