1 if(!dojo._hasResource["dojox.charting.plot2d.StackedColumns"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.charting.plot2d.StackedColumns"] = true;
3 dojo.provide("dojox.charting.plot2d.StackedColumns");
5 dojo.require("dojox.charting.plot2d.common");
6 dojo.require("dojox.charting.plot2d.Columns");
8 dojo.require("dojox.lang.functional");
9 dojo.require("dojox.lang.functional.reversed");
12 var df = dojox.lang.functional, dc = dojox.charting.plot2d.common,
13 purgeGroup = df.lambda("item.purgeGroup()");
15 dojo.declare("dojox.charting.plot2d.StackedColumns", dojox.charting.plot2d.Columns, {
16 calculateAxes: function(dim){
17 var stats = dc.collectStackedStats(this.series);
18 this._maxRunLength = stats.hmax;
21 this._calc(dim, stats);
24 render: function(dim, offsets){
26 var acc = df.repeat(this._maxRunLength, "-> 0", 0);
27 for(var i = 0; i < this.series.length; ++i){
28 var run = this.series[i];
29 for(var j = 0; j < run.data.length; ++j){
31 if(isNaN(v)){ v = 0; }
35 // draw runs in backwards
37 dojo.forEach(this.series, purgeGroup);
40 df.forEachRev(this.series, function(item){ item.cleanGroup(s); });
42 var t = this.chart.theme, color, stroke, fill, f,
43 gap = this.opt.gap < this._hScaler.scale / 3 ? this.opt.gap : 0;
44 for(var i = this.series.length - 1; i >= 0; --i){
45 var run = this.series[i];
46 if(!this.dirty && !run.dirty){ continue; }
49 if(!run.fill || !run.stroke){
50 // need autogenerated color
51 color = run.dyn.color = new dojo.Color(t.next("color"));
53 stroke = run.stroke ? run.stroke : dc.augmentStroke(t.series.stroke, color);
54 fill = run.fill ? run.fill : dc.augmentFill(t.series.fill, color);
55 for(var j = 0; j < acc.length; ++j){
57 width = this._hScaler.scale - 2 * gap,
58 height = this._vScaler.scale * (v - this._vScaler.bounds.lower);
59 if(width >= 1 && height >= 1){
60 var shape = s.createRect({
61 x: offsets.l + this._hScaler.scale * (j + 0.5 - this._hScaler.bounds.lower) + gap,
62 y: dim.height - offsets.b - this._vScaler.scale * (v - this._vScaler.bounds.lower),
63 width: width, height: height
64 }).setFill(fill).setStroke(stroke);
65 run.dyn.fill = shape.getFill();
66 run.dyn.stroke = shape.getStroke();
70 // update the accumulator
71 for(var j = 0; j < run.data.length; ++j){
73 if(isNaN(v)){ v = 0; }