Src attribute of a row gets passed to the barColors function as well

This commit is contained in:
Jelte Fennema 2014-08-12 18:36:19 +02:00
parent a9076b2cc4
commit 1074ec41d3
2 changed files with 3 additions and 3 deletions

View File

@ -188,7 +188,7 @@ class Morris.Bar extends Morris.Grid
# @param type [String] "bar", "hover" or "label"
colorFor: (row, sidx, type) ->
if typeof @options.barColors is 'function'
r = { x: row.x, y: row.y[sidx], label: row.label }
r = { x: row.x, y: row.y[sidx], label: row.label, src: row.src}
s = { index: sidx, key: @options.ykeys[sidx], label: @options.labels[sidx] }
@options.barColors.call(@, r, s, type)
else

View File

@ -25,12 +25,12 @@ describe 'Morris.Bar#colorFor', ->
chart.colorFor(chart.data[0], 0, 'bar')
stub.should.have.been.calledWith(
{x:0, y:2, label:'foo'},
{x:0, y:2, label:'foo', src: { x: "foo", y: 2, z: 3 }},
{index:0, key:'y', label:'Y'},
'bar')
chart.colorFor(chart.data[0], 1, 'hover')
stub.should.have.been.calledWith(
{x:0, y:3, label:'foo'},
{x:0, y:3, label:'foo', src: { x: "foo", y: 2, z: 3 }},
{index:1, key:'z', label:'Z'},
'hover')