Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
if(!dojo._hasResource["dojox.charting.plot2d.ClusteredColumns"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2
dojo._hasResource["dojox.charting.plot2d.ClusteredColumns"] = true;
3
dojo.provide("dojox.charting.plot2d.ClusteredColumns");
4
 
5
dojo.require("dojox.charting.plot2d.common");
6
dojo.require("dojox.charting.plot2d.Columns");
7
 
8
dojo.require("dojox.lang.functional");
9
 
10
(function(){
11
	var df = dojox.lang.functional, dc = dojox.charting.plot2d.common,
12
		purgeGroup = df.lambda("item.purgeGroup()");
13
 
14
	dojo.declare("dojox.charting.plot2d.ClusteredColumns", dojox.charting.plot2d.Columns, {
15
		render: function(dim, offsets){
16
			if(this.dirty){
17
				dojo.forEach(this.series, purgeGroup);
18
				this.cleanGroup();
19
				var s = this.group;
20
				df.forEachReversed(this.series, function(item){ item.cleanGroup(s); });
21
			}
22
			var t = this.chart.theme, color, stroke, fill, f,
23
				gap = this.opt.gap < this._hScaler.scale / 3 ? this.opt.gap : 0,
24
				thickness = (this._hScaler.scale - 2 * gap) / this.series.length;
25
			for(var i = 0; i < this.series.length; ++i){
26
				var run = this.series[i];
27
				if(!this.dirty && !run.dirty){ continue; }
28
				run.cleanGroup();
29
				var s = run.group;
30
				if(!run.fill || !run.stroke){
31
					// need autogenerated color
32
					color = run.dyn.color = new dojo.Color(t.next("color"));
33
				}
34
				stroke = run.stroke ? run.stroke : dc.augmentStroke(t.series.stroke, color);
35
				fill = run.fill ? run.fill : dc.augmentFill(t.series.fill, color);
36
				var baseline = Math.max(0, this._vScaler.bounds.lower),
37
					xoff = offsets.l + this._hScaler.scale * (0.5 - this._hScaler.bounds.lower) + gap + thickness * i,
38
					yoff = dim.height - offsets.b - this._vScaler.scale * (baseline - this._vScaler.bounds.lower);
39
				for(var j = 0; j < run.data.length; ++j){
40
					var v = run.data[j],
41
						width  = thickness,
42
						height = this._vScaler.scale * (v - baseline),
43
						h = Math.abs(height);
44
					if(width >= 1 && h >= 1){
45
						var shape = s.createRect({
46
							x: xoff + this._hScaler.scale * j,
47
							y: yoff - (height < 0 ? 0 : height),
48
							width: width, height: h
49
						}).setFill(fill).setStroke(stroke);
50
						run.dyn.fill   = shape.getFill();
51
						run.dyn.stroke = shape.getStroke();
52
					}
53
				}
54
				run.dirty = false;
55
			}
56
			this.dirty = false;
57
			return this;
58
		}
59
	});
60
})();
61
 
62
}