1 if(!dojo._hasResource["dojox.charting.plot2d.StackedBars"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.charting.plot2d.StackedBars"] = true;
3 dojo.provide("dojox.charting.plot2d.StackedBars");
5 dojo.require("dojox.charting.plot2d.common");
6 dojo.require("dojox.charting.plot2d.Bars");
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.StackedBars", dojox.charting.plot2d.Bars, {
16 calculateAxes: function(dim){
17 var stats = dc.collectStackedStats(this.series), t;
18 this._maxRunLength = stats.hmax;
21 t = stats.hmin, stats.hmin = stats.vmin, stats.vmin = t;
22 t = stats.hmax, stats.hmax = stats.vmax, stats.vmax = t;
23 this._calc(dim, stats);
26 render: function(dim, offsets){
28 var acc = df.repeat(this._maxRunLength, "-> 0", 0);
29 for(var i = 0; i < this.series.length; ++i){
30 var run = this.series[i];
31 for(var j = 0; j < run.data.length; ++j){
33 if(isNaN(v)){ v = 0; }
37 // draw runs in backwards
39 dojo.forEach(this.series, purgeGroup);
42 df.forEachRev(this.series, function(item){ item.cleanGroup(s); });
44 var t = this.chart.theme, color, stroke, fill, f,
45 gap = this.opt.gap < this._vScaler.scale / 3 ? this.opt.gap : 0;
46 for(var i = this.series.length - 1; i >= 0; --i){
47 var run = this.series[i];
48 if(!this.dirty && !run.dirty){ continue; }
51 if(!run.fill || !run.stroke){
52 // need autogenerated color
53 color = run.dyn.color = new dojo.Color(t.next("color"));
55 stroke = run.stroke ? run.stroke : dc.augmentStroke(t.series.stroke, color);
56 fill = run.fill ? run.fill : dc.augmentFill(t.series.fill, color);
57 for(var j = 0; j < acc.length; ++j){
59 width = this._hScaler.scale * (v - this._hScaler.bounds.lower),
60 height = this._vScaler.scale - 2 * gap;
61 if(width >= 1 && height >= 1){
62 var shape = s.createRect({
64 y: dim.height - offsets.b - this._vScaler.scale * (j + 1.5 - this._vScaler.bounds.lower) + gap,
65 width: width, height: height
66 }).setFill(fill).setStroke(stroke);
67 run.dyn.fill = shape.getFill();
68 run.dyn.stroke = shape.getStroke();
72 // update the accumulator
73 for(var j = 0; j < run.data.length; ++j){
75 if(isNaN(v)){ v = 0; }