function weekTotalGraph(myData, binder) { Array.prototype.max = function () { return Math.max.apply(Math, this); }; data = myData.data; itemCount = data.length; var w = 1000, h = 100, x = pv.Scale.ordinal(pv.range(itemCount)).splitBanded(0, w, 4/5), y = pv.Scale.linear(0, myData.data.max()).range(0, h); var vis = new pv.Panel().canvas(binder) .width(w) .height(h) .bottom(20) .left(20) .right(5) .top(5); var bar = vis.add(pv.Bar) .data(data) .left(function() x(this.index)) .width(x.range().band) .bottom(0) .height(y); bar.anchor("top").add(pv.Label) .textStyle("white") .text(function(d) d.toFixed(1)); bar.anchor("bottom").add(pv.Label) .textMargin(5) .textBaseline("top") .text(function() myData.label[this.index]); vis.add(pv.Rule) .data(y.ticks()) .bottom(function(d) Math.round(y(d)) - .5) .strokeStyle(function(d) d ? "rgba(255,255,255,.3)" : "#000") .add(pv.Rule) .left(0) .width(5) .strokeStyle("#000") .anchor("left").add(pv.Label) vis.render(); }