I founded this question here on stackoverflow: Varying bar colors with morris.js bar chart?
I want if the data in bar B is higher or lower then 70 to change it color.
I only can't figure out what I am doing wrong over here to make it work?
here is my code:
new Morris.Bar({
element: 'bar-example',
gridTextColor: '#00ff55',
data: [
{ y: '2006', a: 100, b: 90 },
{ y: '2007', a: 75, b: 65 },
{ y: '2008', a: 50, b: 40 },
{ y: '2009', a: 75, b: 65 },
{ y: '2010', a: 50, b: 40 },
{ y: '2011', a: 75, b: 65 },
{ y: '2012', a: 100, b: 90 }
],
barColors : function(row, series, type) {
if(data.b <70) return ['black', 'white'];
else if(data.b >= 70) return ['white', 'black'];
},
xkey: 'y',
ykeys: ['a', 'b'],
labels: ['Series A', 'Series B']
});