Merge pull request #479 from JelteF/pass-src-barColor-function

Src attribute of a row gets passed to the barColors function as well
This commit is contained in:
Jelte Fennema 2015-01-08 12:53:44 +01:00
commit cbd5f8c636
2 changed files with 3 additions and 3 deletions

View File

@ -201,7 +201,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')