1 if(!dojo._hasResource["dojox.charting.plot2d.Columns"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.charting.plot2d.Columns"] = true;
3 dojo.provide("dojox.charting.plot2d.Columns");
5 dojo.require("dojox.charting.plot2d.common");
6 dojo.require("dojox.charting.plot2d.Base");
8 dojo.require("dojox.lang.utils");
9 dojo.require("dojox.lang.functional");
10 dojo.require("dojox.lang.functional.reversed");
13 var df = dojox.lang.functional, du = dojox.lang.utils,
14 dc = dojox.charting.plot2d.common,
15 purgeGroup = df.lambda("item.purgeGroup()");
17 dojo.declare("dojox.charting.plot2d.Columns", dojox.charting.plot2d.Base, {
19 hAxis: "x", // use a horizontal axis named "x"
20 vAxis: "y", // use a vertical axis named "y"
21 gap: 0, // gap between columns in pixels
22 shadows: null // draw shadows
24 optionalParams: {}, // no optional parameters
26 constructor: function(chart, kwArgs){
27 this.opt = dojo.clone(this.defaultParams);
28 du.updateWithObject(this.opt, kwArgs);
30 this.hAxis = this.opt.hAxis;
31 this.vAxis = this.opt.vAxis;
34 calculateAxes: function(dim){
35 var stats = dc.collectSimpleStats(this.series);
38 this._calc(dim, stats);
41 render: function(dim, offsets){
43 dojo.forEach(this.series, purgeGroup);
46 df.forEachRev(this.series, function(item){ item.cleanGroup(s); });
48 var t = this.chart.theme, color, stroke, fill, f,
49 gap = this.opt.gap < this._hScaler.scale / 3 ? this.opt.gap : 0;
50 for(var i = this.series.length - 1; i >= 0; --i){
51 var run = this.series[i];
52 if(!this.dirty && !run.dirty){ continue; }
55 if(!run.fill || !run.stroke){
56 // need autogenerated color
57 color = run.dyn.color = new dojo.Color(t.next("color"));
59 stroke = run.stroke ? run.stroke : dc.augmentStroke(t.series.stroke, color);
60 fill = run.fill ? run.fill : dc.augmentFill(t.series.fill, color);
61 var baseline = Math.max(0, this._vScaler.bounds.lower),
62 xoff = offsets.l + this._hScaler.scale * (0.5 - this._hScaler.bounds.lower) + gap,
63 yoff = dim.height - offsets.b - this._vScaler.scale * (baseline - this._vScaler.bounds.lower);
64 for(var j = 0; j < run.data.length; ++j){
66 width = this._hScaler.scale - 2 * gap,
67 height = this._vScaler.scale * (v - baseline),
69 if(width >= 1 && h >= 1){
71 x: xoff + this._hScaler.scale * j,
72 y: yoff - (height < 0 ? 0 : height),
73 width: width, height: h
75 shape = s.createRect(rect).setFill(fill).setStroke(stroke);
76 run.dyn.fill = shape.getFill();
77 run.dyn.stroke = shape.getStroke();