[Chartjs]-Using chart-dataset-override option in angular-chart.js

5👍

Hoping that yourquestion is, you want a fill color/label/something to each individual data (for each bar).

Above (your) code snippet is used when you have two data sets.
All these dataset properties will accept String when the same property value has to set for all data, and they will also accept Array[String] – when you want to set different property values for different data in the same dataset. (like below).

$scope.data = [65,11];
$scope.datasetOverride = [
{
  label: ['something', 'otherthing'],
  borderWidth: [1,2],
  backgroundColor: ['#FF4242','#2291ff']
}
]

so now I understood that you might be adding dynamically data.
so you have to push data into DATASET something like this:

$scope.data.push(345);

So if you want to set different properties for these you need to push the properties (arrays).

$scope.datasetOverride[0][label].push('someother thing');
$scope.datasetOverride[0][borderWidth].push(2);
$scope.datesetOverride[0][backgroundColor].push('#46bfb8');

This will add a bar with new color/label/etc beside the previous bars.

I hope I understood your question and this will help.

Leave a comment