From 1074ec41d37d9573e2f6d61b57726f4d607a6c79 Mon Sep 17 00:00:00 2001 From: Jelte Fennema Date: Tue, 12 Aug 2014 18:36:19 +0200 Subject: [PATCH] Src attribute of a row gets passed to the barColors function as well --- lib/morris.bar.coffee | 2 +- spec/lib/bar/colours.coffee | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/morris.bar.coffee b/lib/morris.bar.coffee index fba8037..2b5debb 100644 --- a/lib/morris.bar.coffee +++ b/lib/morris.bar.coffee @@ -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 diff --git a/spec/lib/bar/colours.coffee b/spec/lib/bar/colours.coffee index ebe5469..636df48 100644 --- a/spec/lib/bar/colours.coffee +++ b/spec/lib/bar/colours.coffee @@ -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')