Chart.js: [BUG] labelColor when rendering an array of labels is not working

Created on 15 Feb 2017  路  5Comments  路  Source: chartjs/Chart.js

Expected Behavior


When returning an array of objects from labelColor on tooltips.callbacks, the squares should get the colour returned from the function.

Current Behavior


When returning an array from labelColor on tooltips callbacks, all squares appear black.

Possible Solution


N/A

Steps to Reproduce (for bugs)



http://jsbin.com/xuqalax/edit?html,js,output

Context


I was trying to add thousand separators, and for that I needed to edit the label callback on tooltips. I then realized I would also need to override labelColor in order to get the previous behaviour, but it didn't work as expected.

Environment

  • Chart.js version: 2.5.0
  • Browser name and version: Google Chrome Version 56.0.2924.87 (64-bit)
bug

Most helpful comment

I'm also experiencing this same issue, all label colours are the same even though I am specifying an array of different colours.

All 5 comments

@brenolf the labelColor tooltip is called for each item in the tooltip already, so no need to return an array. See http://jsbin.com/rezecuzeju/1/edit?html,js,output

This is still an issue, I believe. If you return an array in the label callback, it makes multiple labels, but there is no way to define multiple colors. They all have to be the same color.

I'm also experiencing this same issue, all label colours are the same even though I am specifying an array of different colours.

Not sure if you guys are still looking for it but here what worked on my end

            ```

tooltips: {
mode: 'index',
intersect: false,
callbacks: {
label: function(tooltipItem, data) {
var val = (data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index] != '') ? data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index] : 'N/A';
var ctg = data.datasets[tooltipItem.datasetIndex]['label']
return ctg + ' : ' + val;
},
}
},
```

but with this, you'll only get what is the current Category color

pls tell if there is any solution or work around for the aforementioned issue?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gouthamrv picture gouthamrv  路  3Comments

akashrajkn picture akashrajkn  路  3Comments

lizbanach picture lizbanach  路  3Comments

joebirkin picture joebirkin  路  3Comments

srijitcoder picture srijitcoder  路  3Comments