2๐
- Use one dataset for each bar
- Set all data to 0 for the dataset except the data you want to show
- Custom color for each dataset
- BorderWidth = 0 to hide empy data and stacked = true on X axe
- Custom tooltip callback to hide empty dataset
example
https://jsfiddle.net/3qas1ar8/3/
0๐
public barChartColors: Array<any> = [
{
**backgroundColor: ["#36a2eb", "rgba(47, 132, 71, 0.8)", "rgba(30, 50, 71, 0.8)", "green", "blue", "purple", "orange"
],**
borderColor: 'rgba(105,159,177,1)',
pointBackgroundColor: 'rgba(105,159,177,1)',
pointBorderColor: '#fafafa',
pointHoverBackgroundColor: '#fafafa',
pointHoverBorderColor: 'rgba(105,159,177)'
},
];
This will provide different color for each bar in a bar-chart.
- Chartjs-How to target only X or Y value in jsonObj array
- Chartjs-Angular-Chart.js it doesn't display the chart
Source:stackexchange.com