// Generated by CoffeeScript 1.4.0 (function() { var bar_on_mouseout, bar_on_mouseover, color_scale, height, vis, width, x, y; window.bar_chart = {}; bar_chart.dispatcher = d3.dispatch('focus', 'blur'); vis = null; width = null; height = null; x = d3.scale.ordinal(); y = d3.scale.linear(); color_scale = d3.scale.category10(); bar_chart.init = function(v, w, h) { vis = v; width = w; height = h; return y.range([0, height]); }; bar_chart.update = function(data) { var bars; x.domain(d3.range(0, data.length)).rangeRoundBands([0, width], 0.015, 0); y.domain([0, d3.max(data)]); bars = vis.selectAll('.bar').data(data); bars.enter().append('rect').attr({ "class": 'bar datapoint', fill: function(d, i) { return color_scale(i); }, 'stroke-width': 2 }).on('mouseover', bar_on_mouseover).on('mouseout', bar_on_mouseout); bars.attr({ x: function(d, i) { return x(i); }, y: function(d) { return height - y(d); }, width: function(d) { return x.rangeBand(); }, height: function(d) { return y(d); } }); return bars.exit().remove(); }; bar_on_mouseover = function(d, i) { return bar_chart.dispatcher.focus(i); }; bar_on_mouseout = function(d, i) { return bar_chart.dispatcher.blur(i); }; bar_chart.focus = function(i) { return vis.select(".bar:nth-of-type(" + (i + 1) + ")").classed('focus', true); }; bar_chart.blur = function(i) { return vis.select(".bar:nth-of-type(" + (i + 1) + ")").classed('focus', false); }; }).call(this);